eslint-plugin-maintainability 3.0.9 → 3.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -17
- package/src/index.d.ts +15 -250
- package/src/index.js +1 -17
- package/src/oxlint.d.ts +17 -20
- package/src/oxlint.js +0 -18
- package/src/rules/error-handling/error-message.js +0 -17
- package/src/rules/error-handling/no-missing-error-context.js +1 -21
- package/src/rules/error-handling/no-silent-errors.js +1 -21
- package/src/rules/error-handling/no-unhandled-promise.js +4 -100
- package/src/rules/maintainability/cognitive-complexity.js +3 -46
- package/src/rules/maintainability/consistent-function-scoping.js +0 -45
- package/src/rules/maintainability/identical-functions.js +0 -43
- package/src/rules/maintainability/max-parameters.js +2 -17
- package/src/rules/maintainability/nested-complexity-hotspots.js +1 -55
- package/src/rules/maintainability/no-lonely-if.js +0 -15
- package/src/rules/maintainability/no-nested-ternary.js +0 -27
- package/src/rules/maintainability/no-unreadable-iife.js +1 -21
- package/src/types/index.js +0 -5
- package/CHANGELOG.md +0 -192
- package/src/rules/error-handling/error-message.d.ts +0 -20
- package/src/rules/error-handling/no-missing-error-context.d.ts +0 -26
- package/src/rules/error-handling/no-silent-errors.d.ts +0 -24
- package/src/rules/error-handling/no-unhandled-promise.d.ts +0 -41
- package/src/rules/maintainability/cognitive-complexity.d.ts +0 -28
- package/src/rules/maintainability/consistent-function-scoping.d.ts +0 -20
- package/src/rules/maintainability/identical-functions.d.ts +0 -33
- package/src/rules/maintainability/max-parameters.d.ts +0 -29
- package/src/rules/maintainability/nested-complexity-hotspots.d.ts +0 -31
- package/src/rules/maintainability/no-lonely-if.d.ts +0 -19
- package/src/rules/maintainability/no-nested-ternary.d.ts +0 -19
- package/src/rules/maintainability/no-unreadable-iife.d.ts +0 -24
package/CHANGELOG.md
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
## [3.0.3] - 2026-02-08
|
|
2
|
-
|
|
3
|
-
## 3.0.9
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- [#294](https://github.com/ofri-peretz/eslint/pull/294) [`659f6dc`](https://github.com/ofri-peretz/eslint/commit/659f6dc0181b03b675f72b5949fcf123dd066358) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - Rewrite `description` and `keywords` on every published package for npm search discovery. npm ranks on name, description, and keywords, and the registry only picks up these fields at publish — so this is metadata-only and takes effect for each package on its next release.
|
|
8
|
-
|
|
9
|
-
**Descriptions now lead with the search phrase.** Every one starts `ESLint plugin for <the thing you'd search>` instead of a brand-first or category-first framing, and names the concrete vulnerabilities the plugin actually detects. Three were corrected while doing so:
|
|
10
|
-
|
|
11
|
-
- `eslint-plugin-import-next` claimed "100x faster no-cycle detection". No 100x measurement exists: `CLAIMS.md` records **3.1x end-to-end** (8x in pure rule execution) on a 5,483-file React codebase, and the highest number in any benchmark result is 54.9x on the synthetic corpus. The description now states the real-codebase figure.
|
|
12
|
-
- `eslint-plugin-secure-coding` claimed SQL injection, XSS and CSRF coverage — none of which are its rules. It now names what it does detect: LDAP, XPath, XXE, GraphQL and template injection, unsafe deserialization, ReDoS, missing authentication, and PII in logs.
|
|
13
|
-
- `eslint-plugin-secure-coding` ("89 rules") and `eslint-plugin-react-a11y` ("37 rules") hard-coded rule counts that had drifted from reality. Counts are generated into `interlace-numbers.json`; hand-typed copies are removed rather than corrected.
|
|
14
|
-
|
|
15
|
-
**Keywords now match the vocabulary of the plugins that rank.** `eslint-plugin-security`, `eslint-plugin-jsx-a11y`, `eslint-plugin-n` and `eslint-plugin-import` all carry the `eslint` / `eslintplugin` / `eslint-plugin` trio — six of our packages were missing `eslintplugin`, and every one now carries all three plus `static-analysis`, `linting` and `code-quality`. Security plugins add `sast`, `appsec` and `vulnerability`; `node-security` and `secure-coding` also carry `nodesecurity`, the exact keyword `eslint-plugin-security` ranks on. Each plugin gained the CWE identifiers and attack names for what it detects (`cwe-78` command injection, `cwe-22` path traversal, `cwe-89` SQL injection, `cwe-79` XSS, `cwe-347` JWT algorithm confusion, `cwe-352` CSRF, `cwe-943` NoSQL injection), and `node-security` gained the crypto vocabulary it had been missing entirely despite absorbing the crypto rule set (`crypto`, `cryptography`, `weak-hash`, `md5`, `sha1`, `timing-attack`).
|
|
16
|
-
|
|
17
|
-
No rule behavior, exports, or configuration changes.
|
|
18
|
-
|
|
19
|
-
- Updated dependencies [[`e1cdf83`](https://github.com/ofri-peretz/eslint/commit/e1cdf83e3db761907f0ab06f7fc6c1f1da7513a5), [`659f6dc`](https://github.com/ofri-peretz/eslint/commit/659f6dc0181b03b675f72b5949fcf123dd066358)]:
|
|
20
|
-
- @interlace/eslint-devkit@1.4.3
|
|
21
|
-
|
|
22
|
-
## 3.0.8
|
|
23
|
-
|
|
24
|
-
### Patch Changes
|
|
25
|
-
|
|
26
|
-
- [#269](https://github.com/ofri-peretz/eslint/pull/269) [`7028fe2`](https://github.com/ofri-peretz/eslint/commit/7028fe2668a42266d831014184dcef70e73101ad) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - docs: dual-logo README header (Interlace mark + ESLint mark side by side) and closing Interlace footer — refreshes the README rendered on npmjs.com. No runtime changes.
|
|
27
|
-
|
|
28
|
-
- Updated dependencies [[`7028fe2`](https://github.com/ofri-peretz/eslint/commit/7028fe2668a42266d831014184dcef70e73101ad)]:
|
|
29
|
-
- @interlace/eslint-devkit@1.4.2
|
|
30
|
-
|
|
31
|
-
## 3.0.7
|
|
32
|
-
|
|
33
|
-
### Patch Changes
|
|
34
|
-
|
|
35
|
-
- [#252](https://github.com/ofri-peretz/eslint/pull/252) [`d67e395`](https://github.com/ofri-peretz/eslint/commit/d67e3953c2748ad36e6aebe0f24b1d04e518b4d0) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - Fix Codecov badge showing "unknown" — switch from flag to component URL format
|
|
36
|
-
|
|
37
|
-
## 3.0.6
|
|
38
|
-
|
|
39
|
-
### Patch Changes
|
|
40
|
-
|
|
41
|
-
- [#225](https://github.com/ofri-peretz/eslint/pull/225) [`34ff5a8`](https://github.com/ofri-peretz/eslint/commit/34ff5a8e6f5126c5d1c0a524759e0af2b5476b46) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - CI-only: pin all coverage thresholds at 100% (integration target, merges last).
|
|
42
|
-
|
|
43
|
-
## 3.0.5
|
|
44
|
-
|
|
45
|
-
### Patch Changes
|
|
46
|
-
|
|
47
|
-
- [#200](https://github.com/ofri-peretz/eslint/pull/200) [`02e0baf`](https://github.com/ofri-peretz/eslint/commit/02e0baf7a4e8ba83e8b2ec2b82169f733e4f4d87) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - fix: republish `recommended` preset with the correct plugin namespace
|
|
48
|
-
|
|
49
|
-
The published builds of `eslint-plugin-maintainability` and
|
|
50
|
-
`eslint-plugin-operability` shipped a `recommended` config whose plugin KEY
|
|
51
|
-
(`@interlace/maintainability`) did not match its rule PREFIX
|
|
52
|
-
(`@interlace/maintainability/maintainability/…` — doubled). ESLint cannot
|
|
53
|
-
resolve that, so spreading `...configs.recommended` throws
|
|
54
|
-
"could not find plugin" the moment a consumer lints a file — under both
|
|
55
|
-
ESLint 9 and 10.
|
|
56
|
-
|
|
57
|
-
The source was corrected in the 2026-05-16 namespace cleanup (alongside
|
|
58
|
-
`react-features`, which has since been republished via other changesets), but
|
|
59
|
-
these two plugins were never bumped — so npm still serves the broken builds and
|
|
60
|
-
they are the only two doubled-namespace plugins still unfixed downstream. This
|
|
61
|
-
republishes them from the corrected source.
|
|
62
|
-
|
|
63
|
-
Regression lock: `packages/eslint-config-interlace/src/ecosystem-integrity.test.ts`
|
|
64
|
-
loads every plugin's every config preset into a real ESLint instance and fails
|
|
65
|
-
if any rule→plugin reference cannot be resolved. Run it against the built
|
|
66
|
-
`dist/` in the release pipeline (pre-publish) to also catch a stale-artifact
|
|
67
|
-
publish — the failure mode that let these two ship broken.
|
|
68
|
-
|
|
69
|
-
## 3.0.4
|
|
70
|
-
|
|
71
|
-
### Patch Changes
|
|
72
|
-
|
|
73
|
-
- [#197](https://github.com/ofri-peretz/eslint/pull/197) [`ecb8491`](https://github.com/ofri-peretz/eslint/commit/ecb849121833bf63b00256fa837f329bb721fbac) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - fix: republish `recommended` with correctly-namespaced, unscoped rule ids
|
|
74
|
-
|
|
75
|
-
`eslint-plugin-maintainability@3.0.3` and `eslint-plugin-operability@3.0.5`
|
|
76
|
-
shipped a `recommended` preset whose rule ids carried a doubled, scoped plugin
|
|
77
|
-
segment (`@interlace/maintainability/maintainability/cognitive-complexity`)
|
|
78
|
-
that no registered plugin key matched. Enabling the preset alongside any other
|
|
79
|
-
config made ESLint throw at load:
|
|
80
|
-
|
|
81
|
-
```text
|
|
82
|
-
Could not find plugin "@interlace/maintainability/maintainability".
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
(and the equivalent `@interlace/operability/operability` for operability.)
|
|
86
|
-
|
|
87
|
-
The source was already corrected to the bare, unscoped form
|
|
88
|
-
(`maintainability/cognitive-complexity` under a `maintainability` plugin key)
|
|
89
|
-
but was never republished, so npm still served the broken build. This release
|
|
90
|
-
ships the corrected build. `plugin.meta.name` is also fixed to the unscoped
|
|
91
|
-
`eslint-plugin-maintainability` (was `@interlace/eslint-plugin-maintainability`,
|
|
92
|
-
which drifted from the package name and every other plugin).
|
|
93
|
-
|
|
94
|
-
Each plugin is configured on its own — there is no unified config. No rule
|
|
95
|
-
behaviour changes.
|
|
96
|
-
|
|
97
|
-
New regression locks in each plugin's `index.test.ts` reproduce ESLint's rule-id
|
|
98
|
-
resolution, pin the plugin name and key as unscoped, and load each `recommended`
|
|
99
|
-
preset in a real ESLint instance — failing closed if a scoped or doubly
|
|
100
|
-
namespaced config could ship again.
|
|
101
|
-
|
|
102
|
-
### Bug Fixes
|
|
103
|
-
|
|
104
|
-
- align codecov component IDs with full package names ([2831b968](https://github.com/ofri-peretz/eslint/commit/2831b968))
|
|
105
|
-
|
|
106
|
-
### Documentation
|
|
107
|
-
|
|
108
|
-
- fix changelog header format across all packages ([c3a15082](https://github.com/ofri-peretz/eslint/commit/c3a15082))
|
|
109
|
-
|
|
110
|
-
### ❤️ Thank You
|
|
111
|
-
|
|
112
|
-
- Ofri Peretz
|
|
113
|
-
|
|
114
|
-
## [3.0.2] - 2026-02-06
|
|
115
|
-
|
|
116
|
-
### Bug Fixes
|
|
117
|
-
|
|
118
|
-
- align codecov component names and update docs components ([0a59a86c](https://github.com/ofri-peretz/eslint/commit/0a59a86c))
|
|
119
|
-
|
|
120
|
-
### ❤️ Thank You
|
|
121
|
-
|
|
122
|
-
- Ofri Peretz
|
|
123
|
-
|
|
124
|
-
## [3.0.1] - 2026-02-02
|
|
125
|
-
|
|
126
|
-
This was a version bump only for eslint-plugin-maintainability to align it with other projects, there were no code changes.
|
|
127
|
-
|
|
128
|
-
# Changelog
|
|
129
|
-
|
|
130
|
-
All notable changes to `@interlace/eslint-plugin-maintainability` will be documented in this file.
|
|
131
|
-
|
|
132
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
133
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
134
|
-
|
|
135
|
-
### Documentation
|
|
136
|
-
|
|
137
|
-
- 📘 Launched new documentation site: [eslint.interlace.tools](https://eslint.interlace.tools/)
|
|
138
|
-
- 📝 Achieved 100% documentation parity (both .md and .mdx files)
|
|
139
|
-
|
|
140
|
-
## [3.0.0] - 2026-02-02
|
|
141
|
-
|
|
142
|
-
This was a version bump only for eslint-plugin-maintainability to align it with other projects, there were no code changes.
|
|
143
|
-
|
|
144
|
-
## [1.0.0] - 2026-01-26
|
|
145
|
-
|
|
146
|
-
### Added
|
|
147
|
-
|
|
148
|
-
- Initial stable release with 12 maintainability rules
|
|
149
|
-
- LLM-optimized error messages for AI-assisted development
|
|
150
|
-
- 100% test coverage across all rules
|
|
151
|
-
- ESLint 9 flat config support
|
|
152
|
-
- TypeScript type definitions for all rule options
|
|
153
|
-
|
|
154
|
-
### Rules
|
|
155
|
-
|
|
156
|
-
#### Complexity Rules
|
|
157
|
-
|
|
158
|
-
| Rule | Description |
|
|
159
|
-
| :-------------------------- | :------------------------------- |
|
|
160
|
-
| `max-cognitive-complexity` | Limit cognitive complexity score |
|
|
161
|
-
| `max-cyclomatic-complexity` | Limit cyclomatic complexity |
|
|
162
|
-
| `max-depth` | Limit nesting depth |
|
|
163
|
-
| `max-lines` | Limit file length |
|
|
164
|
-
| `max-lines-per-function` | Limit function length |
|
|
165
|
-
| `max-params` | Limit function parameters |
|
|
166
|
-
|
|
167
|
-
#### Code Smell Rules
|
|
168
|
-
|
|
169
|
-
| Rule | Description |
|
|
170
|
-
| :------------------------- | :---------------------------------- |
|
|
171
|
-
| `no-magic-numbers` | Disallow magic numbers |
|
|
172
|
-
| `no-nested-ternary` | Disallow nested ternary expressions |
|
|
173
|
-
| `no-deep-callback-nesting` | Disallow deeply nested callbacks |
|
|
174
|
-
| `no-long-parameter-list` | Disallow long parameter lists |
|
|
175
|
-
|
|
176
|
-
#### Clean Code Rules
|
|
177
|
-
|
|
178
|
-
| Rule | Description |
|
|
179
|
-
| :-------------------- | :------------------------------------------ |
|
|
180
|
-
| `prefer-early-return` | Prefer early returns over nested conditions |
|
|
181
|
-
| `no-duplicate-logic` | Detect duplicated logic blocks (DRY) |
|
|
182
|
-
|
|
183
|
-
### Presets
|
|
184
|
-
|
|
185
|
-
- `recommended` - Balanced maintainability thresholds
|
|
186
|
-
|
|
187
|
-
### SOLID Principles Mapping
|
|
188
|
-
|
|
189
|
-
Rules are annotated with SOLID principle alignment:
|
|
190
|
-
|
|
191
|
-
- Single Responsibility: `max-lines-per-function`, `max-lines`
|
|
192
|
-
- Open/Closed: `prefer-early-return`
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* ESLint Rule: error-message
|
|
8
|
-
* Enforces providing a message when creating built-in Error objects
|
|
9
|
-
*/
|
|
10
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
11
|
-
type MessageIds = 'missingErrorMessage' | 'addErrorMessage';
|
|
12
|
-
export interface Options {
|
|
13
|
-
/** Allow Error() without message (not recommended) */
|
|
14
|
-
allowEmptyCatch?: boolean;
|
|
15
|
-
}
|
|
16
|
-
type RuleOptions = [Options?];
|
|
17
|
-
export declare const errorMessage: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
18
|
-
name: string;
|
|
19
|
-
};
|
|
20
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* ESLint Rule: no-missing-error-context
|
|
8
|
-
* Detects thrown errors without context
|
|
9
|
-
*
|
|
10
|
-
* @see https://rules.sonarsource.com/javascript/RSPEC-1128/
|
|
11
|
-
*/
|
|
12
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
13
|
-
type MessageIds = 'missingErrorContext' | 'addErrorMessage' | 'addErrorStack' | 'useErrorClass';
|
|
14
|
-
export interface Options {
|
|
15
|
-
/** Require error message. Default: true */
|
|
16
|
-
requireMessage?: boolean;
|
|
17
|
-
/** Require stack trace. Default: false */
|
|
18
|
-
requireStackTrace?: boolean;
|
|
19
|
-
/** Ignore in test files. Default: true */
|
|
20
|
-
ignoreInTests?: boolean;
|
|
21
|
-
}
|
|
22
|
-
type RuleOptions = [Options?];
|
|
23
|
-
export declare const noMissingErrorContext: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
24
|
-
name: string;
|
|
25
|
-
};
|
|
26
|
-
export {};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* ESLint Rule: no-silent-errors
|
|
8
|
-
* Detects empty catch blocks
|
|
9
|
-
*
|
|
10
|
-
* @see https://rules.sonarsource.com/javascript/RSPEC-1186/
|
|
11
|
-
*/
|
|
12
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
13
|
-
type MessageIds = 'silentError' | 'addErrorLogging' | 'addErrorHandling' | 'rethrowError';
|
|
14
|
-
export interface Options {
|
|
15
|
-
/** Allow empty catch if comment explains why. Default: false */
|
|
16
|
-
allowWithComment?: boolean;
|
|
17
|
-
/** Ignore in test files. Default: true */
|
|
18
|
-
ignoreInTests?: boolean;
|
|
19
|
-
}
|
|
20
|
-
type RuleOptions = [Options?];
|
|
21
|
-
export declare const noSilentErrors: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
22
|
-
name: string;
|
|
23
|
-
};
|
|
24
|
-
export {};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* ESLint Rule: no-unhandled-promise
|
|
8
|
-
* Detects unhandled Promise rejections
|
|
9
|
-
* CWE-1024: Comparison of Classes by Name
|
|
10
|
-
*
|
|
11
|
-
* @see https://cwe.mitre.org/data/definitions/1024.html
|
|
12
|
-
* @see https://rules.sonarsource.com/javascript/RSPEC-4635/
|
|
13
|
-
*/
|
|
14
|
-
import type { TSESLint, TSESTree } from '@interlace/eslint-devkit';
|
|
15
|
-
type MessageIds = 'unhandledPromise' | 'addCatch' | 'useTryCatch' | 'useAwait';
|
|
16
|
-
export interface Options {
|
|
17
|
-
/** Ignore promises in test files. Default: true */
|
|
18
|
-
ignoreInTests?: boolean;
|
|
19
|
-
/** Ignore promises in void expressions. Default: false */
|
|
20
|
-
ignoreVoidExpressions?: boolean;
|
|
21
|
-
}
|
|
22
|
-
type RuleOptions = [Options?];
|
|
23
|
-
/**
|
|
24
|
-
* Check if a node is a Promise-like expression
|
|
25
|
-
* For now, we check all CallExpressions since we can't statically determine
|
|
26
|
-
* which functions return promises. The isPromiseHandled function will filter out
|
|
27
|
-
* non-promise calls that are inside handled promise chains.
|
|
28
|
-
*/
|
|
29
|
-
export declare function isPromiseExpression(node: TSESTree.Node): boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Check if a CallExpression is inside a promise chain callback
|
|
32
|
-
*/
|
|
33
|
-
export declare function isInsidePromiseCallback(node: TSESTree.CallExpression): boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Check if promise is handled (has .catch, .then, or is in try/catch)
|
|
36
|
-
*/
|
|
37
|
-
export declare function isPromiseHandled(node: TSESTree.Node): boolean;
|
|
38
|
-
export declare const noUnhandledPromise: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
39
|
-
name: string;
|
|
40
|
-
};
|
|
41
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* ESLint Rule: cognitive-complexity
|
|
8
|
-
* Detects high cognitive complexity with refactoring suggestions
|
|
9
|
-
* Inspired by SonarQube RSPEC-3776
|
|
10
|
-
*
|
|
11
|
-
* @see https://rules.sonarsource.com/javascript/RSPEC-3776/
|
|
12
|
-
*/
|
|
13
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
14
|
-
/**
|
|
15
|
-
* Message IDs for cognitive complexity violations and suggestions
|
|
16
|
-
*/
|
|
17
|
-
type MessageIds = 'highCognitiveComplexity' | 'extractMethod' | 'simplifyLogic' | 'useStrategy';
|
|
18
|
-
export interface Options {
|
|
19
|
-
/** Maximum allowed cognitive complexity score. Default: 15 */
|
|
20
|
-
maxComplexity?: number;
|
|
21
|
-
/** Include complexity metrics in error message. Default: false */
|
|
22
|
-
includeMetrics?: boolean;
|
|
23
|
-
}
|
|
24
|
-
type RuleOptions = [Options?];
|
|
25
|
-
export declare const cognitiveComplexity: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
26
|
-
name: string;
|
|
27
|
-
};
|
|
28
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* ESLint Rule: consistent-function-scoping
|
|
8
|
-
* Disallow functions that are declared in a scope which does not capture any variables from the outer scope
|
|
9
|
-
*/
|
|
10
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
11
|
-
type MessageIds = 'inconsistentFunctionScoping' | 'moveToModuleScope';
|
|
12
|
-
export interface Options {
|
|
13
|
-
/** Check arrow functions for scoping issues */
|
|
14
|
-
checkArrowFunctions?: boolean;
|
|
15
|
-
}
|
|
16
|
-
type RuleOptions = [Options?];
|
|
17
|
-
export declare const consistentFunctionScoping: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
18
|
-
name: string;
|
|
19
|
-
};
|
|
20
|
-
export {};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* ESLint Rule: identical-functions
|
|
8
|
-
* Detects functions with identical implementations and suggests DRY refactoring
|
|
9
|
-
* Inspired by SonarQube RSPEC-4144
|
|
10
|
-
*
|
|
11
|
-
* @see https://rules.sonarsource.com/javascript/RSPEC-4144/
|
|
12
|
-
*/
|
|
13
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
14
|
-
type MessageIds = 'identicalFunctions' | 'extractGeneric' | 'useHigherOrder' | 'applyInheritance';
|
|
15
|
-
export interface Options {
|
|
16
|
-
/** Minimum lines to consider for duplicate detection. Default: 3 */
|
|
17
|
-
minLines?: number;
|
|
18
|
-
/** Similarity percentage threshold (0-100). Default: 90 */
|
|
19
|
-
similarityThreshold?: number;
|
|
20
|
-
/** Ignore test files. Default: false */
|
|
21
|
-
ignoreTestFiles?: boolean;
|
|
22
|
-
}
|
|
23
|
-
type RuleOptions = [Options?];
|
|
24
|
-
/**
|
|
25
|
-
* Build the generic extracted-function name suggested for a duplication group.
|
|
26
|
-
* Shared by the unified-function template and the report data so the two can
|
|
27
|
-
* never drift apart.
|
|
28
|
-
*/
|
|
29
|
-
export declare function buildGenericName(firstFunctionName: string): string;
|
|
30
|
-
export declare const identicalFunctions: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
31
|
-
name: string;
|
|
32
|
-
};
|
|
33
|
-
export {};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* ESLint Rule: max-parameters
|
|
8
|
-
* Detects functions with too many parameters
|
|
9
|
-
*
|
|
10
|
-
* Note: ESLint has max-params, but this rule provides LLM-optimized messages
|
|
11
|
-
* and additional context about refactoring to object parameters
|
|
12
|
-
*
|
|
13
|
-
* @see https://rules.sonarsource.com/javascript/RSPEC-107/
|
|
14
|
-
*/
|
|
15
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
16
|
-
type MessageIds = 'tooManyParameters' | 'useObjectParameter' | 'extractToClass' | 'splitFunction';
|
|
17
|
-
export interface Options {
|
|
18
|
-
/** Maximum allowed parameters. Default: 4 */
|
|
19
|
-
max?: number;
|
|
20
|
-
/** Ignore constructors. Default: false */
|
|
21
|
-
ignoreConstructors?: boolean;
|
|
22
|
-
/** Ignore overridden methods. Default: false */
|
|
23
|
-
ignoreOverriddenMethods?: boolean;
|
|
24
|
-
}
|
|
25
|
-
type RuleOptions = [Options?];
|
|
26
|
-
export declare const maxParameters: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
27
|
-
name: string;
|
|
28
|
-
};
|
|
29
|
-
export {};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* ESLint Rule: nested-complexity-hotspots
|
|
8
|
-
* Identifies nested control structures that harm readability
|
|
9
|
-
* Priority 3: Enhanced Complexity Analysis
|
|
10
|
-
*
|
|
11
|
-
* @see https://en.wikipedia.org/wiki/Cyclomatic_complexity
|
|
12
|
-
*/
|
|
13
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
14
|
-
type MessageIds = 'nestedComplexity' | 'useEarlyReturn' | 'useGuardClauses' | 'extractMethod';
|
|
15
|
-
export interface Options {
|
|
16
|
-
/** Maximum nesting depth. Default: 4 */
|
|
17
|
-
maxDepth?: number;
|
|
18
|
-
/** Count nested conditionals. Default: true */
|
|
19
|
-
countConditionals?: boolean;
|
|
20
|
-
/** Count nested loops. Default: true */
|
|
21
|
-
countLoops?: boolean;
|
|
22
|
-
}
|
|
23
|
-
type RuleOptions = [Options?];
|
|
24
|
-
/**
|
|
25
|
-
* Calculate nesting depth for a node
|
|
26
|
-
* Note: Currently unused, keeping for future implementation
|
|
27
|
-
*/
|
|
28
|
-
export declare const nestedComplexityHotspots: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
29
|
-
name: string;
|
|
30
|
-
};
|
|
31
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* ESLint Rule: no-lonely-if
|
|
8
|
-
* Prevent lone if statements inside else blocks
|
|
9
|
-
*/
|
|
10
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
11
|
-
export interface Options {
|
|
12
|
-
/** Allow lonely if in specific contexts */
|
|
13
|
-
allow?: string[];
|
|
14
|
-
}
|
|
15
|
-
type RuleOptions = [Options?];
|
|
16
|
-
export declare const noLonelyIf: TSESLint.RuleModule<"noLonelyIf", RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
17
|
-
name: string;
|
|
18
|
-
};
|
|
19
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* ESLint Rule: no-nested-ternary
|
|
8
|
-
* Prevent nested ternary expressions
|
|
9
|
-
*/
|
|
10
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
11
|
-
export interface Options {
|
|
12
|
-
/** Allow nested ternaries in specific contexts */
|
|
13
|
-
allow?: string[];
|
|
14
|
-
}
|
|
15
|
-
type RuleOptions = [Options?];
|
|
16
|
-
export declare const noNestedTernary: TSESLint.RuleModule<"noNestedTernary", RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
17
|
-
name: string;
|
|
18
|
-
};
|
|
19
|
-
export {};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
-
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
-
* MIT license that can be found in the LICENSE file.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* ESLint Rule: no-unreadable-iife
|
|
8
|
-
* Prevent unreadable Immediately Invoked Function Expressions (unicorn-inspired)
|
|
9
|
-
*/
|
|
10
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
11
|
-
type MessageIds = 'unreadableIIFE' | 'suggestNamedFunction' | 'suggestBlockScope' | 'complexIIFE';
|
|
12
|
-
export interface Options {
|
|
13
|
-
/** Maximum number of statements allowed in IIFE */
|
|
14
|
-
maxStatements?: number;
|
|
15
|
-
/** Maximum depth of nesting allowed in IIFE */
|
|
16
|
-
maxDepth?: number;
|
|
17
|
-
/** Allow IIFEs that return values */
|
|
18
|
-
allowReturningIIFE?: boolean;
|
|
19
|
-
}
|
|
20
|
-
type RuleOptions = [Options?];
|
|
21
|
-
export declare const noUnreadableIife: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
22
|
-
name: string;
|
|
23
|
-
};
|
|
24
|
-
export {};
|