eslint-plugin-strict-code
v1.1.1
Published
Strict ESLint rules for clean code: no path aliasing, no complex conditionals, no destructuring, strict naming, and more.
Maintainers
Readme
eslint-plugin-strict-code
Strict ESLint rules for clean code: no path aliasing, no complex conditionals, no destructuring, strict naming, and more.
Installation
npm install --save-dev eslint-plugin-strict-codeUsage
Flat config (ESLint 9+)
// eslint.config.js
import strictCode from "eslint-plugin-strict-code";
export default [
{
plugins: { "strict-code": strictCode },
rules: {
"strict-code/no-path-aliasing": "error",
"strict-code/no-complex-conditionals": "error",
"strict-code/no-fn-on-expression": "error",
"strict-code/strict-naming": "error",
"strict-code/no-complex-arguments": "error",
"strict-code/no-destructuring": "error",
"strict-code/no-unassigned-call": "error",
"strict-code/prefer-signals-no-input": "error",
"strict-code/prefer-takeuntil-destroyed": "error",
"strict-code/no-complex-return": "error",
"strict-code/no-complex-assignment": "error",
"strict-code/no-redundant-type-annotation": "error",
"strict-code/prefer-typeof": "warn",
},
},
];Extends (ESLint 9.19+)
The plugin ships a recommended config that enables the core rule no-negated-condition (if (!x) ... else ...). Use defineConfig from eslint/config — extends in flat config requires it, and the plugin must be registered in the same config object.
// eslint.config.js
import { defineConfig } from "eslint/config";
import strictCode from "eslint-plugin-strict-code";
export default defineConfig([
{
plugins: { "strict-code": strictCode },
extends: ["strict-code/recommended"],
// + ваши индивидуальные правила strict-code/* из Flat config
},
]);Legacy eslintrc (ESLint 8)
The plugin ships a legacy-recommended config — the full overrides set (typescript + Angular templates) ported from web-frontend-dev's .eslintrc.json:
{
"root": true,
"extends": ["plugin:strict-code/legacy-recommended"]
}It requires these plugins installed in the consumer project:
@typescript-eslint/eslint-plugin + @typescript-eslint/parser, @angular-eslint/eslint-plugin, eslint-plugin-unused-imports, @stylistic/eslint-plugin, eslint-plugin-sonarjs, eslint-plugin-prettier, prettier.
parserOptions.project is resolved relative to the consumer's working directory (same as before the move).
ESLintrc (legacy)
{
"plugins": ["strict-code"],
"rules": {
"strict-code/no-path-aliasing": "error",
"strict-code/no-complex-conditionals": "error",
"strict-code/no-fn-on-expression": "error",
"strict-code/strict-naming": "error",
"strict-code/no-complex-arguments": "error",
"strict-code/no-destructuring": "error",
"strict-code/no-effect-outside-component": "error",
"strict-code/no-unassigned-call": "error",
"strict-code/prefer-signals-no-input": "error",
"strict-code/prefer-takeuntil-destroyed": "error",
"strict-code/no-complex-return": "error",
"strict-code/no-complex-assignment": "error",
"strict-code/no-redundant-type-annotation": "error",
"strict-code/prefer-typeof": "warn"
}
}Rules
| Rule | Description |
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------- |
| no-path-aliasing | Path aliasing is forbidden for lines <= 100 chars |
| no-complex-conditionals | No index access, type assertions, or ternary in conditionals |
| no-fn-on-expression | Function calls on non-simple expressions are forbidden |
| strict-naming | iter prefix for loop variables |
| no-complex-arguments | Binary/logical/conditional expressions forbidden as arguments |
| no-complex-assignment | No call/index access/type assertion combined with operators in assignments |
| no-destructuring | Object destructuring is forbidden |
| no-effect-outside-component | Angular: effect()/untracked() only in .component.ts/.directive.ts/.spec.ts files, inside class methods (not constructors/lifecycle hooks) |
| no-unassigned-call | Call results must be assigned before use |
| no-complex-return | Complex return expressions are forbidden |
| no-redundant-type-annotation | Redundant type annotations are forbidden |
| prefer-typeof | Prefer typeof varName over duplicated types |
| no-form-control-name | Angular: formControlName is forbidden (requires @angular-eslint/utils) |
| prefer-signals-no-input | Angular: prefer signals over @Input decorator |
| prefer-takeuntil-destroyed | Angular: subscribe() must use takeUntilDestroyed() or takeUntil() in @Component/@Directive |
License
MIT © Sergey
