@blumintinc/eslint-plugin-blumint
v1.15.0
Published
Custom eslint rules for use within BluMint
Maintainers
Readme
@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.
🚫 Configurations disabled in.
✅ Set in the recommended configuration.
🔧 Automatically fixable by the --fix CLI option.
💡 Manually fixable by editor suggestions.
💭 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 | Enforces a top-to-bottom class layout so callers lead into the helpers they rely on. | ✅ | | | 🔧 | | |
| consistent-callback-naming | Enforce consistent naming conventions for callback props and functions | ✅ | | | 🔧 | | |
| dynamic-https-errors | Keep HttpsError messages static and move request-specific details to the third argument so error identifiers remain stable and debugging context is preserved. | ✅ | | | | | |
| enforce-assert-safe-object-key | Enforce the use of assertSafe(id) when accessing object properties with computed keys that involve string interpolation or explicit string conversion. | ✅ | | | 🔧 | | |
| enforce-assert-throws | Enforce that functions with an assert prefix must throw an error or call process.exit(1), and functions that call assert-prefixed methods should themselves be assert-prefixed | ✅ | | | | | |
| enforce-boolean-naming-prefixes | Enforce consistent naming conventions for boolean values by requiring approved prefixes | ✅ | | | 🔧 | | |
| 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-console-error | Enforce proper logging for useAlertDialog based on severity. When severity is "error", console.error must be included. When severity is "warning", console.warn must be included. This ensures all user-facing errors and warnings are properly logged to observability systems. | ✅ | | | | | |
| enforce-css-media-queries | Enforce CSS media queries over JS breakpoints | ✅ | | | | | |
| enforce-date-ttime | Enforce that any generic type parameter named TTime is explicitly set to Date in frontend code | ✅ | | | 🔧 | | 💭 |
| 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 | Require firebaseCloud modules to be loaded via dynamic import so Firebase code stays out of the initial bundle and only loads when needed. | ✅ | | | 🔧 | 💡 | |
| enforce-dynamic-imports | Enforce dynamic imports for specified libraries to optimize bundle size | ✅ | | | | | |
| enforce-early-destructuring | Hoist object destructuring out of React hooks so dependency arrays track the fields in use instead of the entire object. | ✅ | | | 🔧 | | |
| enforce-empty-object-check | Ensure object existence checks also guard against empty objects so that empty payloads are treated like missing data. | ✅ | | | 🔧 | | |
| enforce-exported-function-types | Enforce exporting types for function props and return values | ✅ | | | | | |
| enforce-f-extension-for-entry-points | Enforce .f.ts extension for entry points | ✅ | | | | | |
| enforce-fieldpath-syntax-in-docsetter | Enforce the use of Firestore FieldPath syntax when passing documentData into DocSetter. Instead of using nested object syntax, developers should use dot notation for deeply nested fields. | ✅ | | | 🔧 | | |
| 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-rules-get-access | Ensure Firestore security rules use .get() with a default value instead of direct field access comparisons (e.g., resource.data.fieldX.fieldY != null). | ✅ | | | 🔧 | | |
| 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-global-constants | Enforce global static constants for React components/hooks | ✅ | | | 🔧 | | |
| 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-memoize-getters | Enforce @Memoize() decorator on private class getters to avoid re-instantiation and preserve state across accesses. | ✅ | | | 🔧 | | |
| 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 | Authoritative rule: parameters with types ending in "Props" should be named "props" (or prefixed variants when multiple Props params exist) | ✅ | | | 🔧 | | |
| enforce-props-naming-consistency | Prefer naming single "Props"-typed parameters as "props"; enforcement defers to enforce-props-argument-name for multi-Props cases | ✅ | | | 🔧 | | |
| enforce-querykey-ts | Enforce using centralized router state key constants from queryKeys.ts for useRouterState key parameter | ✅ | | | 🔧 | | |
| 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 for Firebase callable/HTTPS functions. | ✅ | | | | | |
| enforce-singular-type-names | Enforce TypeScript type names to be singular | ✅ | | | | | |
| enforce-stable-hash-spread-props | Require stableHash wrapping when spread props rest objects are used in React hook dependency arrays to avoid re-renders triggered by new object references on every render. | ✅ | | | 🔧 | | |
| enforce-storage-context | Require storage access to go through the LocalStorage and SessionStorage context providers instead of direct browser APIs | ✅ | | | | | |
| 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-transform-memoization | Enforce memoization of transformValue and transformOnChange in adaptValue | ✅ | | | | | |
| enforce-typescript-markdown-code-blocks | Ensure Markdown fenced code blocks without a language specifier default to typescript for consistent highlighting. | ✅ | | | 🔧 | | |
| enforce-unique-cursor-headers | Ensure files have exactly one cursor header containing required tags (e.g., @fileoverview) before any code | ✅ | | | 🔧 | | |
| 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 variable declarations, 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 | ✅ | | | | | |
| fast-deep-equal-over-microdiff | Enforce using fast-deep-equal for equality checks instead of microdiff | ✅ | | | 🔧 | | |
| firestore-transaction-reads-before-writes | Enforce that all Firestore transaction read operations are performed before any write operations | ✅ | | | | | |
| flatten-push-calls | Consolidate consecutive push calls on the same array into a single push with multiple arguments. | ✅ | | | 🔧 | | |
| generic-starts-with-t | Enforce TypeScript generic type parameters to start with T so they stand out from runtime values. | ✅ | | | | | |
| global-const-style | Enforce UPPER_SNAKE_CASE and as const for global static constants | ✅ | | | 🔧 | | |
| jsdoc-above-field | Require JSDoc blocks to sit above fields instead of trailing inline so IDE hovers surface the documentation. | ✅ | | | 🔧 | | |
| key-only-outermost-element | Enforce that only the outermost element in list rendering has a key prop | ✅ | | | 🔧 | | |
| logical-top-to-bottom-grouping | Enforce logical top-to-bottom grouping of related statements | ✅ | | | 🔧 | | |
| memo-compare-deeply-complex-props | Suggest compareDeeply for memoized components that receive object/array props to avoid shallow comparison re-renders. | ✅ | | | 🔧 | | 💭 |
| memo-nested-react-components | Disallow React components defined in render bodies, hooks, or passed as props | ✅ | | | | | |
| memoize-root-level-hocs | Prevent creating Higher-Order Components at the root level of React components/hooks without wrapping them in useMemo to keep wrapped component identities stable across renders. | ✅ | | | | | |
| no-always-true-false-conditions | Detect conditions that are always truthy or always falsy | ✅ | | | | | |
| no-array-length-in-deps | Detects array.length entries in React hook dependency arrays because length ignores content changes; auto-fixes by memoizing stableHash(array) with useMemo and depending on the hash instead. | ✅ | | | 🔧 | | |
| no-async-array-filter | Disallow async callbacks in Array.filter(). Async predicates return Promises that are always truthy to the filter, so no element is ever removed. Resolve async checks first (Promise.all + map) or use a synchronous predicate to decide which items to keep. | ✅ | | | | | |
| no-async-foreach | Disallow async callbacks to Array.forEach | ✅ | | | | | |
| no-circular-references | Disallow circular references in objects | ✅ | | | | | |
| 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 | Discourage CSS properties that force GPU compositing layers (e.g., transform, filter, will-change). Extra layers consume GPU memory and split rendering work, which slows scrolling and animation when sprinkled across a page. The rule inspects inline style objects and MUI sx props so layer promotion stays intentional rather than incidental. | ✅ | | | | | |
| no-conditional-literals-in-jsx | Disallow conditional string literals beside other JSX text to avoid fragmented text nodes, translation issues, and hydration mismatches. | ✅ | | | | | |
| no-console-error | Disallow console.error so errors flow through structured handling (HttpsError/useErrorAlert on frontend, structured loggers on backend). | | ✅ | | | | |
| no-curly-brackets-around-commented-properties | Disallow curly-brace blocks that only wrap commented-out members inside type declarations | ✅ | | | 🔧 | | |
| no-empty-dependency-use-callbacks | Discourage useCallback([]) or useLatestCallback around static functions. Static callbacks do not need hook machinery—extract them to module-level utilities for clarity and to avoid unnecessary hook overhead. | ✅ | | | 🔧 | | |
| no-entire-object-hook-deps | Avoid using entire objects in React hook dependency arrays. | ✅ | | | 🔧 | | 💭 |
| no-excessive-parent-chain | Discourage excessive use of the ref.parent property chain in Firestore and RealtimeDB change handlers | | | | | 💡 | |
| 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 object types in Firestore models. Prefer Record maps keyed by id with an index field, or subcollections/arrays of IDs. | ✅ | | | | | |
| no-handler-suffix | Disallow the generic "handler" suffix in callback names so names explain the action they perform | ✅ | | | | | |
| 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 | Prevent margin properties (margin, marginLeft, marginRight, marginTop, marginBottom, mx, my, etc.) in MUI styling because margins fight container-controlled spacing, double gutters, and misaligned breakpoints; keep spacing centralized with padding, gap, or spacing props instead. | ✅ | | | | | |
| no-memoize-on-static | Prevent using @Memoize() decorator on static methods | ✅ | | | | | |
| no-misleading-boolean-prefixes | Reserve boolean-style prefixes (is/has/should) for functions that actually return boolean values to avoid misleading call sites. | ✅ | | | | | |
| 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 direct mocking of firebaseAdmin; use shared test helpers instead | ✅ | | | | | |
| no-object-values-on-strings | Disallow Object.values() on strings as it treats strings as arrays of characters, which is likely unintended behavior. | ✅ | | | | | |
| no-overridable-method-calls-in-constructor | Disallow calling overridable methods in constructors to prevent unexpected behavior | ✅ | | | | | |
| no-passthrough-getters | Avoid getter methods that only re-expose nested properties on constructor-injected objects without adding behavior | ✅ | | | | | |
| no-redundant-annotation-assertion | Disallow combining a type annotation with an identical type assertion on the same value. Keep a single source of truth to avoid redundant type declarations that can drift apart. | ✅ | | | 🔧 | | 💭 |
| no-redundant-param-types | Disallow redundant parameter type annotations | ✅ | | | 🔧 | | |
| no-redundant-this-params | Disallow passing class instance members (this.foo) into class instance methods; access the member from this inside the method instead. | ✅ | | | | | |
| no-redundant-usecallback-wrapper | Prevent wrapping already memoized/stable callbacks from hooks/contexts in an extra useCallback() | ✅ | | | 🔧 | | |
| no-res-error-status-in-onrequest | Forbid sending 4xx/5xx Express responses inside onRequest handlers; throw structured HttpsError instances instead so the wrapper can format, log, and map errors consistently. | ✅ | | | | | |
| no-restricted-properties-fix | Disallow certain properties on certain objects, with special handling for Object.keys() and Object.values() | | | | 🔧 | | |
| no-separate-loading-state | Disallow separate loading state variables that track the loading status of other state | ✅ | | | | | |
| no-stale-state-across-await | Prevent stale intermediate state by disallowing useState setter calls both before and after async boundaries (await, .then(), yield) within the same function | ✅ | | | | | |
| no-static-constants-in-dynamic-files | Disallow exporting SCREAMING_SNAKE_CASE constants from .dynamic.ts/.dynamic.tsx files; move static constants to non-dynamic modules instead. | ✅ | | | | | |
| no-try-catch-already-exists-in-transaction | Disallow catching ALREADY_EXISTS errors inside Firestore transaction callbacks | ✅ | | | | | |
| no-type-assertion-returns | Enforce typing variables before returning them, rather than using type assertions or explicit return types | ✅ | | | 🔧 | | |
| no-undefined-null-passthrough | Avoid functions that return undefined or null when their single argument is undefined or null | ✅ | | | | | |
| no-unmemoized-memo-without-props | Prevent wrapping prop-less Unmemoized components in memo since memo provides no benefit without props and adds unnecessary indirection | ✅ | | | | | |
| no-unnecessary-destructuring | Avoid object patterns that only spread an existing object, since they clone the whole value without selecting properties | ✅ | | | 🔧 | | |
| no-unnecessary-destructuring-rename | Disallow destructuring renames that are only used to assign back to the original property name | ✅ | | | 🔧 | | |
| 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-useless-usememo-primitives | Disallow useless useMemo with primitive values.
