@blumintinc/eslint-plugin-blumint v1.12.6
@blumintinc/eslint-plugin-blumint
Custom eslint rules for use at BluMint
Installation
You'll first need to install ESLint:
npm i eslint --save-devNext, install @blumintinc/eslint-plugin-blumint:
npm install @blumintinc/eslint-plugin-blumint --save-devUsage
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-context | Prevent misuse of Array methods in OOP | β | |||
| avoid-utils-directory | Enforce using util/ instead of utils/ directory | β | π§ | ||
| class-methods-read-top-to-bottom | Ensures classes read linearly from top to bottom. | β | π§ | ||
| consistent-callback-naming | Enforce consistent naming conventions for callback props and functions | β | π§ | ||
| dynamic-https-errors | Dynamic 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-throws | Enforce that functions with assert- prefix must throw an error or call process.exit(1) | β | |||
| enforce-assertSafe-object-key | Enforce the use of assertSafe(id) when accessing object properties with computed keys that involve string interpolation or explicit string conversion. | β | π§ | ||
| enforce-callable-types | Enforce Props and Response type exports in callable functions | β | |||
| enforce-callback-memo | Enforce 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-firestore | Enforce usage of centralized mockFirestore from predefined location | β | π§ | ||
| enforce-css-media-queries | Enforce CSS media queries over JS breakpoints | β | |||
| enforce-dynamic-file-naming | Enforce .dynamic.ts(x) file naming when @blumintinc/blumint/enforce-dynamic-imports or @blumintinc/blumint/require-dynamic-firebase-imports rule is disabled | β | |||
| enforce-dynamic-firebase-imports | Enforce 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-imports | Enforce dynamic imports for specified libraries to optimize bundle size | β | |||
| enforce-exported-function-types | Enforce exporting types for function props and return values | β | |||
| enforce-firestore-doc-ref-generic | Enforce generic argument for Firestore DocumentReference, CollectionReference and CollectionGroup | β | π | ||
| enforce-firestore-facade | Enforce usage of Firestore facades instead of direct Firestore methods | β | |||
| enforce-firestore-path-utils | Enforce 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-merge | Enforce 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-capitalization | Enforce the use of "ID" instead of "id" in user-facing text | β | π§ | ||
| enforce-identifiable-firestore-type | Enforce that Firestore type definitions extend Identifiable and match their folder name | β | |||
| enforce-memoize-async | Enforce @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-microdiff | Enforce using microdiff for object and array comparison operations | β | π§ | ||
| enforce-mock-firestore | Enforce 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-icons | Enforce the use of -Rounded variant for MUI icons | β | π§ | ||
| enforce-object-literal-as-const | Enforce that object literals returned from functions should be marked with as const to ensure type safety and immutability. | β | π§ | ||
| enforce-positive-naming | Enforce positive naming for boolean variables and avoid negations | β | |||
| enforce-props-argument-name | Enforce using "Props" suffix in type names for parameter objects | β | π§ | ||
| enforce-react-type-naming | Enforce naming conventions for React types | β | π§ | ||
| enforce-realtimedb-path-utils | Enforce usage of utility functions for Realtime Database paths | β | |||
| enforce-render-hits-memoization | Enforce proper memoization and usage of useRenderHits and renderHits | β | |||
| enforce-safe-stringify | Enforce 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-params | Enforce 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-names | Enforce TypeScript type names to be singular | β | |||
| enforce-timestamp-now | Enforce 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-naming | Enforce verb phrases for functions and methods | β | |||
| ensure-pointer-events-none | Ensure pointer-events: none is added to non-interactive pseudo-elements | β | π§ | ||
| export-if-in-doubt | All top-level const definitions, type definitions, and functions should be exported | ||||
| extract-global-constants | Extract 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-t | Enforce TypeScript generic types to start with T | β | |||
| global-const-style | Enforce UPPER_SNAKE_CASE and as const for global static constants | β | π§ | ||
| key-only-outermost-element | Enforce that only the outermost element in list rendering has a key prop | β | π§ | ||
| no-always-true-false-conditions | Detect conditions that are always truthy or always falsy | β | |||
| no-async-array-filter | Disallow 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-foreach | Disallow 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-destructuring | Disallow destructuring of class instances to prevent loss of this context | β | π§ | ||
| no-complex-cloud-params | Disallow passing complex objects to cloud functions | β | |||
| no-compositing-layer-props | Warn 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-jsx | Disallow use of conditional literals in JSX code | β | |||
| no-entire-object-hook-deps | Avoid 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-type | Disallow 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-return | Disallow Array.filter callbacks without an explicit return (if part of a block statement) | β | |||
| no-firestore-jest-mock | Prevent importing firestore-jest-mock in test files | β | π§ | ||
| no-firestore-object-arrays | Disallow arrays of objects in Firestore type definitions to optimize performance and avoid unnecessary fetches | β | |||
| no-hungarian | Disallow Hungarian notation in locally declared variables, types, and classes | β | |||
| no-jsx-in-hooks | Prevent hooks from returning JSX | β | |||
| no-jsx-whitespace-literal | Disallow the use of {" "} elements in JSX code | β | |||
| no-margin-properties | Discourage 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-static | Prevent using @Memoize() decorator on static methods | β | |||
| no-misused-switch-case | Prevent 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-transactions | Prevent mixing transactional and non-transactional Firestore operations within a transaction | β | |||
| no-mock-firebase-admin | Prevent mocking of functions/src/config/firebaseAdmin | β | |||
| no-object-values-on-strings | Disallow Object.values() on strings as it treats strings as arrays of characters, which is likely unintended behavior. | β | |||
| no-redundant-param-types | Disallow redundant parameter type annotations | β | π§ | ||
| no-type-assertion-returns | Enforce typing variables before returning them, rather than using type assertions or explicit return types | β | π§ | ||
| no-unnecessary-destructuring | Avoid unnecessary object destructuring when there is only one property inside the destructured object | β | π§ | ||
| no-unnecessary-verb-suffix | Prevent unnecessary verb suffixes in function and method names | β | π§ | ||
| no-unpinned-dependencies | Enforces pinned dependencies | β | π§ | ||
| no-unsafe-firestore-spread | Prevent unsafe object/array spreads in Firestore updates | β | π§ | ||
| no-unused-props | Detect unused props in React component type definitions | β | π§ | ||
| no-unused-usestate | Disallow unused useState hooks | β | π§ | ||
| no-useless-fragment | Prevent unnecessary use of React fragments | π§ | |||
| no-uuidv4-base62-as-key | Disallow using uuidv4Base62() to generate keys for elements in a list or loop | β | |||
| omit-index-html | Disallow the use of "index.html" in URLs | β | π§ | ||
| prefer-batch-operations | Enforce using setAll() and overwriteAll() instead of multiple set() or overwrite() calls | β | π§ | ||
| prefer-clone-deep | Prefer using cloneDeep over nested spread copying | β | π§ | ||
| prefer-destructuring-no-class | Enforce destructuring when accessing object properties, except for class instances | β | π§ | ||
| prefer-fragment-component | Enforce using Fragment imported from react over shorthand fragments and React.Fragment | β | π§ | ||
| prefer-fragment-shorthand | Prefer <> shorthand for <React.Fragment> | π§ | |||
| prefer-global-router-state-key | Enforce using global constants or type-safe functions for useRouterState key parameter | β | |||
| prefer-settings-object | Enforce using a settings object for functions with multiple parameters | β | π§ | ||
| prefer-type-over-interface | Prefer using type alias over interface | β | π§ | ||
| prefer-usecallback-over-usememo-for-functions | Enforce using useCallback instead of useMemo for memoizing functions | β | π§ | ||
| prefer-usememo-over-useeffect-usestate | Prefer 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-static | Enforce abstraction of private static methods into utility functions | β | |||
| react-usememo-should-be-component | Enforce that useMemo hooks explicitly returning JSX should be abstracted into separate React components | β | |||
| require-dynamic-firebase-imports | Enforce dynamic imports for Firebase dependencies | β | π§ | ||
| require-hooks-default-params | Enforce React hooks with optional parameters to default to an empty object | β | π§ | ||
| require-https-error | Enforce using proprietary HttpsError instead of throw new Error or firebase-admin HttpsError in functions/src | β | |||
| require-image-optimized | Enforce using ImageOptimized component instead of next/image or img tags | β | π§ | ||
| require-memo | React components must be memoized | β | π§ | ||
| require-usememo-object-literals | Enforce 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-prefixes | Enforce semantic function prefixes over generic ones like "get" and "update" | β | |||
| sync-onwrite-name-func | Ensure that the name field matches the func field in onWrite handlers | β | π§ | ||
| use-custom-link | Enforce using src/components/Link instead of next/link | β | π§ | ||
| use-custom-memo | Enforce using src/util/memo instead of React memo | β | π§ | ||
| use-custom-router | Enforce using src/hooks/routing/useRouter instead of next/router | β | π§ |
8 months ago
10 months ago
1 year ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
9 months ago
9 months ago
9 months ago
10 months ago
12 months ago
10 months ago
12 months ago
10 months ago
1 year ago
9 months ago
11 months ago
11 months ago
8 months ago
9 months ago
9 months ago
10 months ago
10 months ago
9 months ago
9 months ago
10 months ago
10 months ago
9 months ago
10 months ago
10 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
11 months ago
9 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago