1.12.6 β€’ Published 8 months ago

@blumintinc/eslint-plugin-blumint v1.12.6

Weekly downloads
-
License
ISC
Repository
github
Last release
8 months ago

@blumintinc/eslint-plugin-blumint

Custom eslint rules for use at BluMint

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install @blumintinc/eslint-plugin-blumint:

npm install @blumintinc/eslint-plugin-blumint --save-dev

Usage

Add @blumintinc/blumint to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "@blumintinc/blumint"
    ]
}

Then configure the rules you want to use under the rules section.

{
    "rules": {
        "blumint/rule-name": "error"
    }
}

Or use the recommended config:

{
    "extends": ["some-other-plugin", "plugin:@blumintinc/blumint/recommended"]
}

Rules

πŸ’Ό Configurations enabled in.\ ⚠️ Configurations set to warn in.\ βœ… Set in the recommended configuration.\ πŸ”§ Automatically fixable by the --fix CLI option.\ πŸ’­ Requires type information.

NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β DescriptionπŸ’Όβš οΈπŸ”§πŸ’­
array-methods-this-contextPrevent misuse of Array methods in OOPβœ…
avoid-utils-directoryEnforce using util/ instead of utils/ directoryβœ…πŸ”§
class-methods-read-top-to-bottomEnsures classes read linearly from top to bottom.βœ…πŸ”§
consistent-callback-namingEnforce consistent naming conventions for callback props and functionsβœ…πŸ”§
dynamic-https-errorsDynamic error details should only be in the third argument of the HttpsError constructor. The second argument is hashed to produce a unique id.βœ…
enforce-assert-throwsEnforce that functions with assert- prefix must throw an error or call process.exit(1)βœ…
enforce-assertSafe-object-keyEnforce the use of assertSafe(id) when accessing object properties with computed keys that involve string interpolation or explicit string conversion.βœ…πŸ”§
enforce-callable-typesEnforce Props and Response type exports in callable functionsβœ…
enforce-callback-memoEnforce useCallback for inline functions and useMemo for objects/arrays containing functions in JSX props to prevent unnecessary re-renders. This improves React component performance by ensuring stable function references across renders and memoizing complex objects.βœ…
enforce-centralized-mock-firestoreEnforce usage of centralized mockFirestore from predefined locationβœ…πŸ”§
enforce-css-media-queriesEnforce CSS media queries over JS breakpointsβœ…
enforce-dynamic-file-namingEnforce .dynamic.ts(x) file naming when @blumintinc/blumint/enforce-dynamic-imports or @blumintinc/blumint/require-dynamic-firebase-imports rule is disabledβœ…
enforce-dynamic-firebase-importsEnforce dynamic importing for modules within the firebaseCloud directory to optimize initial bundle size. This ensures Firebase-related code is only loaded when needed, improving application startup time and reducing the main bundle size.βœ…
enforce-dynamic-importsEnforce dynamic imports for specified libraries to optimize bundle sizeβœ…
enforce-exported-function-typesEnforce exporting types for function props and return valuesβœ…
enforce-firestore-doc-ref-genericEnforce generic argument for Firestore DocumentReference, CollectionReference and CollectionGroupβœ…πŸ’­
enforce-firestore-facadeEnforce usage of Firestore facades instead of direct Firestore methodsβœ…
enforce-firestore-path-utilsEnforce usage of utility functions for Firestore paths to ensure type safety, maintainability, and consistent path construction. This prevents errors from manual string concatenation and makes path changes easier to manage.βœ…
enforce-firestore-set-mergeEnforce using set() with { merge: true } instead of update() for Firestore operations to ensure consistent behavior. The update() method fails if the document does not exist, while set() with { merge: true } creates the document if needed and safely merges fields, making it more reliable and predictable.βœ…πŸ”§
enforce-id-capitalizationEnforce the use of "ID" instead of "id" in user-facing textβœ…πŸ”§
enforce-identifiable-firestore-typeEnforce that Firestore type definitions extend Identifiable and match their folder nameβœ…
enforce-memoize-asyncEnforce @Memoize() decorator on async methods with 0-1 parameters to cache results and prevent redundant API calls or expensive computations. This improves performance by reusing previous results when the same parameters are provided, particularly useful for data fetching methods.βœ…πŸ”§
enforce-microdiffEnforce using microdiff for object and array comparison operationsβœ…πŸ”§
enforce-mock-firestoreEnforce using the standardized mockFirestore utility instead of manual Firestore mocking or third-party mocks. This ensures consistent test behavior across the codebase, reduces boilerplate, and provides type-safe mocking of Firestore operations.βœ…
enforce-mui-rounded-iconsEnforce the use of -Rounded variant for MUI iconsβœ…πŸ”§
enforce-object-literal-as-constEnforce that object literals returned from functions should be marked with as const to ensure type safety and immutability.βœ…πŸ”§
enforce-positive-namingEnforce positive naming for boolean variables and avoid negationsβœ…
enforce-props-argument-nameEnforce using "Props" suffix in type names for parameter objectsβœ…πŸ”§
enforce-react-type-namingEnforce naming conventions for React typesβœ…πŸ”§
enforce-realtimedb-path-utilsEnforce usage of utility functions for Realtime Database pathsβœ…
enforce-render-hits-memoizationEnforce proper memoization and usage of useRenderHits and renderHitsβœ…
enforce-safe-stringifyEnforce using safe-stable-stringify instead of JSON.stringify to handle circular references and ensure deterministic output. JSON.stringify can throw errors on circular references and produce inconsistent output for objects with the same properties in different orders. safe-stable-stringify handles these cases safely.βœ…πŸ”§
enforce-serializable-paramsEnforce serializable parameters in Firebase Callable/HTTPS Cloud Functions to prevent runtime errors. Firebase Functions can only pass JSON-serializable data, so using non-serializable types like Date, DocumentReference, or Map will cause failures. Use primitive types, plain objects, and arrays instead, converting complex types to their serializable representations (e.g., Date to ISO string).βœ…
enforce-singular-type-namesEnforce TypeScript type names to be singularβœ…
enforce-timestamp-nowEnforce the use of Timestamp.now() for getting the current timestamp in backend code. This rule prevents using alternatives like Timestamp.fromDate(new Date()) or other date creation patterns that could lead to inconsistency.βœ…πŸ”§
enforce-verb-noun-namingEnforce verb phrases for functions and methodsβœ…
ensure-pointer-events-noneEnsure pointer-events: none is added to non-interactive pseudo-elementsβœ…πŸ”§
export-if-in-doubtAll top-level const definitions, type definitions, and functions should be exported
extract-global-constantsExtract static constants and functions to the global scope when possible, and enforce type narrowing with as const for numeric literals in loopsβœ…
generic-starts-with-tEnforce TypeScript generic types to start with Tβœ…
global-const-styleEnforce UPPER_SNAKE_CASE and as const for global static constantsβœ…πŸ”§
key-only-outermost-elementEnforce that only the outermost element in list rendering has a key propβœ…πŸ”§
no-always-true-false-conditionsDetect conditions that are always truthy or always falsyβœ…
no-async-array-filterDisallow async callbacks in Array.filter() as they lead to incorrect filtering. Since async functions return Promises which are always truthy, the filter will keep all elements regardless of the async check's result. Use Promise.all() with map() first, then filter based on the resolved results.βœ…
no-async-foreachDisallow Array.forEach with an async callback function as it does not wait for promises to resolve. This can lead to race conditions and unexpected behavior. Use a standard for...of loop for sequential execution or Promise.all with map for concurrent execution.βœ…
no-class-instance-destructuringDisallow destructuring of class instances to prevent loss of this contextβœ…πŸ”§
no-complex-cloud-paramsDisallow passing complex objects to cloud functionsβœ…
no-compositing-layer-propsWarn when using CSS properties that trigger compositing layers, which can impact performance. Properties like transform, opacity, filter, and will-change create new GPU layers. While sometimes beneficial for animations, excessive layer creation can increase memory usage and hurt performance. Consider alternatives or explicitly document intentional layer promotion.βœ…
no-conditional-literals-in-jsxDisallow use of conditional literals in JSX codeβœ…
no-entire-object-hook-depsAvoid using entire objects in React hook dependency arrays when only specific fields are used, as this can cause unnecessary re-renders. When a hook only uses obj.name but obj is in the deps array, any change to obj.age will trigger the hook. Use individual fields (obj.name) instead of the entire object. Requires TypeScript and parserOptions.project to be configured.βœ…πŸ”§πŸ’­
no-explicit-return-typeDisallow explicit return type annotations on functions when TypeScript can infer them. This reduces code verbosity and maintenance burden while leveraging TypeScript's powerful type inference. Exceptions are made for type guard functions (using the is keyword), recursive functions, overloaded functions, interface methods, and abstract methods where explicit types improve clarity.βœ…πŸ”§
no-filter-without-returnDisallow Array.filter callbacks without an explicit return (if part of a block statement)βœ…
no-firestore-jest-mockPrevent importing firestore-jest-mock in test filesβœ…πŸ”§
no-firestore-object-arraysDisallow arrays of objects in Firestore type definitions to optimize performance and avoid unnecessary fetchesβœ…
no-hungarianDisallow Hungarian notation in locally declared variables, types, and classesβœ…
no-jsx-in-hooksPrevent hooks from returning JSXβœ…
no-jsx-whitespace-literalDisallow the use of {" "} elements in JSX codeβœ…
no-margin-propertiesDiscourage using margin properties (margin, marginLeft, marginRight, marginTop, marginBottom, mx, my, etc.) for spacing in MUI components. Instead, prefer defining spacing with padding, gap, or the spacing prop for more predictable layouts.βœ…
no-memoize-on-staticPrevent using @Memoize() decorator on static methodsβœ…
no-misused-switch-casePrevent misuse of logical OR (||) in switch case statements, which can lead to confusing and error-prone code. Instead of using OR operators in case expressions, use multiple case statements in sequence to handle multiple values. This improves code readability and follows the standard switch-case pattern.βœ…
no-mixed-firestore-transactionsPrevent mixing transactional and non-transactional Firestore operations within a transactionβœ…
no-mock-firebase-adminPrevent mocking of functions/src/config/firebaseAdminβœ…
no-object-values-on-stringsDisallow Object.values() on strings as it treats strings as arrays of characters, which is likely unintended behavior.βœ…
no-redundant-param-typesDisallow redundant parameter type annotationsβœ…πŸ”§
no-type-assertion-returnsEnforce typing variables before returning them, rather than using type assertions or explicit return typesβœ…πŸ”§
no-unnecessary-destructuringAvoid unnecessary object destructuring when there is only one property inside the destructured objectβœ…πŸ”§
no-unnecessary-verb-suffixPrevent unnecessary verb suffixes in function and method namesβœ…πŸ”§
no-unpinned-dependenciesEnforces pinned dependenciesβœ…πŸ”§
no-unsafe-firestore-spreadPrevent unsafe object/array spreads in Firestore updatesβœ…πŸ”§
no-unused-propsDetect unused props in React component type definitionsβœ…πŸ”§
no-unused-usestateDisallow unused useState hooksβœ…πŸ”§
no-useless-fragmentPrevent unnecessary use of React fragmentsπŸ”§
no-uuidv4-base62-as-keyDisallow using uuidv4Base62() to generate keys for elements in a list or loopβœ…
omit-index-htmlDisallow the use of "index.html" in URLsβœ…πŸ”§
prefer-batch-operationsEnforce using setAll() and overwriteAll() instead of multiple set() or overwrite() callsβœ…πŸ”§
prefer-clone-deepPrefer using cloneDeep over nested spread copyingβœ…πŸ”§
prefer-destructuring-no-classEnforce destructuring when accessing object properties, except for class instancesβœ…πŸ”§
prefer-fragment-componentEnforce using Fragment imported from react over shorthand fragments and React.Fragmentβœ…πŸ”§
prefer-fragment-shorthandPrefer <> shorthand for <React.Fragment>πŸ”§
prefer-global-router-state-keyEnforce using global constants or type-safe functions for useRouterState key parameterβœ…
prefer-settings-objectEnforce using a settings object for functions with multiple parametersβœ…πŸ”§
prefer-type-over-interfacePrefer using type alias over interfaceβœ…πŸ”§
prefer-usecallback-over-usememo-for-functionsEnforce using useCallback instead of useMemo for memoizing functionsβœ…πŸ”§
prefer-usememo-over-useeffect-usestatePrefer useMemo over useEffect + useState for pure computations. Using useEffect to update state with a pure computation causes unnecessary re-renders.βœ…
prefer-utility-function-over-private-staticEnforce abstraction of private static methods into utility functionsβœ…
react-usememo-should-be-componentEnforce that useMemo hooks explicitly returning JSX should be abstracted into separate React componentsβœ…
require-dynamic-firebase-importsEnforce dynamic imports for Firebase dependenciesβœ…πŸ”§
require-hooks-default-paramsEnforce React hooks with optional parameters to default to an empty objectβœ…πŸ”§
require-https-errorEnforce using proprietary HttpsError instead of throw new Error or firebase-admin HttpsError in functions/srcβœ…
require-image-optimizedEnforce using ImageOptimized component instead of next/image or img tagsβœ…πŸ”§
require-memoReact components must be memoizedβœ…πŸ”§
require-usememo-object-literalsEnforce using useMemo for inline object/array literals passed as props to JSX components to prevent unnecessary re-renders. When object/array literals are defined inline in JSX, they create new references on every render, causing child components to re-render even if the values haven't changed. Wrap them in useMemo to maintain referential equality.βœ…
semantic-function-prefixesEnforce semantic function prefixes over generic ones like "get" and "update"βœ…
sync-onwrite-name-funcEnsure that the name field matches the func field in onWrite handlersβœ…πŸ”§
use-custom-linkEnforce using src/components/Link instead of next/linkβœ…πŸ”§
use-custom-memoEnforce using src/util/memo instead of React memoβœ…πŸ”§
use-custom-routerEnforce using src/hooks/routing/useRouter instead of next/routerβœ…πŸ”§
1.12.3

8 months ago

1.2.0

10 months ago

1.0.2

1 year ago

1.12.2

8 months ago

1.12.1

8 months ago

1.12.0

8 months ago

1.12.6

8 months ago

1.12.5

8 months ago

1.12.4

8 months ago

1.8.2

9 months ago

1.8.1

9 months ago

1.8.0

9 months ago

1.6.0

10 months ago

1.0.5

12 months ago

1.4.0

10 months ago

1.0.4

12 months ago

1.2.1

10 months ago

1.0.3

1 year ago

1.11.0

9 months ago

1.1.1

11 months ago

1.1.0

11 months ago

1.11.1

8 months ago

1.9.1

9 months ago

1.7.3

9 months ago

1.5.5

10 months ago

1.1.9

10 months ago

1.9.0

9 months ago

1.7.2

9 months ago

1.5.4

10 months ago

1.1.8

10 months ago

1.7.1

9 months ago

1.5.3

10 months ago

1.1.7

10 months ago

1.7.0

9 months ago

1.5.2

10 months ago

1.1.6

10 months ago

1.5.1

10 months ago

1.1.5

10 months ago

1.5.0

10 months ago

1.3.2

10 months ago

1.1.4

10 months ago

1.3.1

10 months ago

1.1.3

10 months ago

1.3.0

10 months ago

1.1.2

11 months ago

1.10.0

9 months ago

0.1.24

2 years ago

0.1.15

2 years ago

0.1.20

2 years ago

0.1.21

2 years ago

0.1.22

2 years ago

0.1.23

2 years ago

0.1.16

2 years ago

0.1.17

2 years ago

0.1.18

2 years ago

0.1.19

2 years ago

0.1.11

2 years ago

0.1.12

2 years ago

0.1.13

2 years ago

0.1.14

2 years ago

0.1.10

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4-s

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

3 years ago

0.1.0

3 years ago