eslint-plugin-sweepit
v0.0.21
Published
Opinionated architectural lint rules for Sweepit.
Readme
eslint-plugin-sweepit
Opinionated architectural lint rules.
Install
npm install --save-dev eslint-plugin-sweepit eslintUsage (Flat config)
import sweepit from 'eslint-plugin-sweepit';
export default [...sweepit.configs.core, ...sweepit.configs.react];Type Information (Accuracy Boost)
configs.core and configs.react enable TypeScript project services by default:
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: process.cwd(),
},
}This improves accuracy for rules like:
sweepit/no-array-propssweepit/no-object-propssweepit/no-optional-props-without-defaults@typescript-eslint/no-floating-promises@typescript-eslint/switch-exhaustiveness-check
What configs.core includes
The exported core config enables:
- all rules from
typescript-eslintrecommendedandrecommendedTypeCheckedflat configs functional/immutable-datano-param-reassignwith{ props: true }prefer-const@typescript-eslint/switch-exhaustiveness-checksweepit/no-external-binding-mutationsweepit/complexitywith{ max: 5, variant: 'modified' }
What configs.react includes
The exported React config is opinionated. It enables:
- Third-party React/TS plugins:
eslint-plugin-reacteslint-plugin-react-hookseslint-plugin-react-you-might-not-need-an-effecttypescript-eslint(flat plugin + parser APIs)
- Third-party rules:
react/jsx-handler-namesreact/jsx-no-constructed-context-valuesreact/jsx-no-useless-fragmentreact/jsx-pascal-casereact/no-unstable-nested-components@typescript-eslint/no-floating-promises- all rules from
eslint-plugin-react-hooksrecommendedconfig - all rules from
eslint-plugin-react-you-might-not-need-an-effectrecommendedconfig
- Sweepit rules listed below (all as
errorin the default config)
Customize rule defaults
Override any default rule from sweepit.configs.core and sweepit.configs.react.
import sweepit from 'eslint-plugin-sweepit';
export default [
...sweepit.configs.core,
...sweepit.configs.react,
{
rules: {
// disable a default rule
'react-hooks/exhaustive-deps': 'off',
// tune sweepit rules
'sweepit/no-array-props': 'warn',
'sweepit/no-prefixed-prop-bundles': ['error', { threshold: 4 }],
},
},
];Included rules
| Rule | Description |
| ----------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| sweepit/no-title-case-props | Disallows TitleCase JSX props and enforces camelCase prop names. |
| sweepit/no-custom-kebab-case-props | Disallows custom kebab-case JSX props (except allowed prefixes like aria-* and data-*). |
| sweepit/no-set-prefix-utils | Reserves set* naming for useState setters, not utility/helper functions. |
| sweepit/no-handle-prefix-utils | Reserves handle* naming for functions used in JSX on* props, not general utility/helper functions. |
| sweepit/no-useless-hook | Disallows use* functions that do not call a real React hook. |
| sweepit/no-hook-jsx | Disallows hooks returning JSX; use* should return behavior/data, not markup. |
| sweepit/no-exported-context-hooks | Disallows exporting use*Context hooks to keep context internals private. |
| sweepit/no-handler-return-type | Enforces void return types for on* handler prop contracts. |
| sweepit/jsx-server-action-prop-suffix | Requires async callback props to be named action or end with Action. |
| sweepit/jsx-on-handler-verb-suffix | Ensures on* handler prop names end with a verb (for example onValueChange). |
| sweepit/no-render-helper-functions | Disallows JSX-returning functions unless they use PascalCase component naming. |
| sweepit/no-element-props | Restricts ReactNode/ReactElement prop usage to explicit composition conventions (children/render). |
| sweepit/no-componenttype-props | Disallows ComponentType/FC/FunctionComponent props in component contracts. |
| sweepit/no-object-props | Disallows object-typed members in *Props type definitions (except style). |
| sweepit/no-array-props | Disallows array/tuple-typed members in *Props type definitions. |
| sweepit/no-prefixed-prop-bundles | Treats grouped prefixed prop declarations (for example userName/userEmail/userRole) as a composition-pressure signal once they hit a configured threshold (default 3). |
| sweepit/no-return-object-repetition | Flags repeated object-return key shapes and encourages shared defaults with targeted overrides. |
| sweepit/no-optional-props-without-defaults | Disallows optional component props unless defaulted at the component boundary; type info improves optional-prop detection accuracy. |
| sweepit/no-boolean-capability-props | Disallows boolean props without associated control handlers (for example open without onOpenChange) in component contracts. |
| sweepit/no-external-binding-mutation | Enforces function-level mutation purity by disallowing mutation of outer bindings/parameters and requiring readonly typing for method calls on those bindings. |
| sweepit/complexity | Enforces a maximum cyclomatic complexity threshold for functions and class initialization paths. |
| sweepit/no-inline-call-expressions | Prefers extracting inline call expressions out of loop headers and call arguments into named variables. |
| sweepit/max-custom-props | Limits custom prop count in *Props contracts (default max 8) to surface composition pressure early. |
| sweepit/jsx-bem-compound-naming | Enforces block-prefixed naming for exported compound component parts. |
| sweepit/jsx-compound-part-export-naming | Enforces Root/part alias export naming for compound component modules. |
| sweepit/no-prop-drilling | Disallows props that are only forwarded unchanged to children. |
| sweepit/jsx-flat-owner-tree | Encourages flatter parent component ownership trees by limiting deep handoff chains. |
