eslint-plugin-maintainability 3.0.8 → 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 +21 -21
- 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 -173
- 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
|
@@ -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 {};
|