eslint 10.0.0-beta.0 → 10.0.0-rc.0
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/README.md +1 -1
- package/lib/languages/js/index.js +0 -1
- package/lib/linter/linter.js +14 -22
- package/lib/rule-tester/rule-tester.js +562 -287
- package/lib/rules/max-params.js +29 -10
- package/lib/types/index.d.ts +51 -12
- package/lib/types/rules.d.ts +5 -0
- package/package.json +5 -5
- package/lib/linter/rules.js +0 -71
package/lib/rules/max-params.js
CHANGED
|
@@ -53,8 +53,14 @@ module.exports = {
|
|
|
53
53
|
description:
|
|
54
54
|
"Whether to count a `this` declaration when the type is `void`.",
|
|
55
55
|
},
|
|
56
|
+
countThis: {
|
|
57
|
+
enum: ["never", "except-void", "always"],
|
|
58
|
+
description:
|
|
59
|
+
"Whether to count a `this` declaration.",
|
|
60
|
+
},
|
|
56
61
|
},
|
|
57
62
|
additionalProperties: false,
|
|
63
|
+
not: { required: ["countVoidThis", "countThis"] },
|
|
58
64
|
},
|
|
59
65
|
],
|
|
60
66
|
},
|
|
@@ -68,7 +74,7 @@ module.exports = {
|
|
|
68
74
|
const sourceCode = context.sourceCode;
|
|
69
75
|
const option = context.options[0];
|
|
70
76
|
let numParams = 3;
|
|
71
|
-
let
|
|
77
|
+
let countThis = "except-void";
|
|
72
78
|
|
|
73
79
|
if (typeof option === "object") {
|
|
74
80
|
if (
|
|
@@ -77,7 +83,12 @@ module.exports = {
|
|
|
77
83
|
) {
|
|
78
84
|
numParams = option.maximum || option.max;
|
|
79
85
|
}
|
|
80
|
-
|
|
86
|
+
|
|
87
|
+
countThis = option.countThis;
|
|
88
|
+
if (!countThis && Object.hasOwn(option, "countVoidThis")) {
|
|
89
|
+
countThis = option.countVoidThis ? "always" : "except-void";
|
|
90
|
+
}
|
|
91
|
+
countThis ||= "except-void";
|
|
81
92
|
}
|
|
82
93
|
if (typeof option === "number") {
|
|
83
94
|
numParams = option;
|
|
@@ -90,17 +101,25 @@ module.exports = {
|
|
|
90
101
|
* @private
|
|
91
102
|
*/
|
|
92
103
|
function checkFunction(node) {
|
|
93
|
-
const
|
|
104
|
+
const thisParam =
|
|
94
105
|
node.params.length > 0 &&
|
|
95
106
|
node.params[0].type === "Identifier" &&
|
|
96
|
-
node.params[0].name === "this"
|
|
97
|
-
|
|
98
|
-
|
|
107
|
+
node.params[0].name === "this"
|
|
108
|
+
? node.params[0]
|
|
109
|
+
: null;
|
|
99
110
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
111
|
+
let effectiveParamCount = node.params.length;
|
|
112
|
+
if (thisParam) {
|
|
113
|
+
if (countThis === "never") {
|
|
114
|
+
effectiveParamCount = node.params.length - 1;
|
|
115
|
+
} else if (
|
|
116
|
+
countThis === "except-void" &&
|
|
117
|
+
thisParam.typeAnnotation?.typeAnnotation.type ===
|
|
118
|
+
"TSVoidKeyword"
|
|
119
|
+
) {
|
|
120
|
+
effectiveParamCount = node.params.length - 1;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
104
123
|
|
|
105
124
|
if (effectiveParamCount > numParams) {
|
|
106
125
|
context.report({
|
package/lib/types/index.d.ts
CHANGED
|
@@ -53,7 +53,6 @@ import type {
|
|
|
53
53
|
EcmaVersion as CoreEcmaVersion,
|
|
54
54
|
ConfigOverride as CoreConfigOverride,
|
|
55
55
|
ProcessorFile as CoreProcessorFile,
|
|
56
|
-
JavaScriptParserOptionsConfig,
|
|
57
56
|
RulesMeta,
|
|
58
57
|
RuleConfig,
|
|
59
58
|
RuleTextEditor,
|
|
@@ -139,7 +138,7 @@ export namespace Scope {
|
|
|
139
138
|
|
|
140
139
|
getDeclaredVariables(node: ESTree.Node): Variable[];
|
|
141
140
|
|
|
142
|
-
addGlobals(names: string
|
|
141
|
+
addGlobals(names: ReadonlyArray<string>): void;
|
|
143
142
|
}
|
|
144
143
|
|
|
145
144
|
interface Scope {
|
|
@@ -155,8 +154,7 @@ export namespace Scope {
|
|
|
155
154
|
| "global"
|
|
156
155
|
| "module"
|
|
157
156
|
| "switch"
|
|
158
|
-
| "with"
|
|
159
|
-
| "TDZ";
|
|
157
|
+
| "with";
|
|
160
158
|
isStrict: boolean;
|
|
161
159
|
upper: Scope | null;
|
|
162
160
|
childScopes: Scope[];
|
|
@@ -185,8 +183,8 @@ export namespace Scope {
|
|
|
185
183
|
identifier: ESTree.Identifier | JSXIdentifier;
|
|
186
184
|
from: Scope;
|
|
187
185
|
resolved: Variable | null;
|
|
188
|
-
writeExpr
|
|
189
|
-
init
|
|
186
|
+
writeExpr?: ESTree.Expression | null;
|
|
187
|
+
init?: boolean;
|
|
190
188
|
|
|
191
189
|
isWrite(): boolean;
|
|
192
190
|
|
|
@@ -235,7 +233,6 @@ export namespace Scope {
|
|
|
235
233
|
| ESTree.ArrowFunctionExpression;
|
|
236
234
|
parent: null;
|
|
237
235
|
}
|
|
238
|
-
| { type: "TDZ"; node: any; parent: null }
|
|
239
236
|
| {
|
|
240
237
|
type: "Variable";
|
|
241
238
|
node: ESTree.VariableDeclarator;
|
|
@@ -812,23 +809,23 @@ export class Linter {
|
|
|
812
809
|
|
|
813
810
|
verify(
|
|
814
811
|
code: SourceCode | string,
|
|
815
|
-
config: Linter.
|
|
812
|
+
config: Linter.Config | Linter.Config[],
|
|
816
813
|
filename?: string,
|
|
817
814
|
): Linter.LintMessage[];
|
|
818
815
|
verify(
|
|
819
816
|
code: SourceCode | string,
|
|
820
|
-
config: Linter.
|
|
817
|
+
config: Linter.Config | Linter.Config[],
|
|
821
818
|
options: Linter.LintOptions,
|
|
822
819
|
): Linter.LintMessage[];
|
|
823
820
|
|
|
824
821
|
verifyAndFix(
|
|
825
822
|
code: string,
|
|
826
|
-
config: Linter.
|
|
823
|
+
config: Linter.Config | Linter.Config[],
|
|
827
824
|
filename?: string,
|
|
828
825
|
): Linter.FixReport;
|
|
829
826
|
verifyAndFix(
|
|
830
827
|
code: string,
|
|
831
|
-
config: Linter.
|
|
828
|
+
config: Linter.Config | Linter.Config[],
|
|
832
829
|
options: Linter.FixOptions,
|
|
833
830
|
): Linter.FixReport;
|
|
834
831
|
|
|
@@ -935,7 +932,43 @@ export namespace Linter {
|
|
|
935
932
|
*
|
|
936
933
|
* @see [Specifying Parser Options](https://eslint.org/docs/latest/use/configure/language-options#specifying-parser-options)
|
|
937
934
|
*/
|
|
938
|
-
|
|
935
|
+
interface ParserOptions {
|
|
936
|
+
/**
|
|
937
|
+
* Allow the use of reserved words as identifiers (if `ecmaVersion` is 3).
|
|
938
|
+
*
|
|
939
|
+
* @default false
|
|
940
|
+
*/
|
|
941
|
+
allowReserved?: boolean | undefined;
|
|
942
|
+
/**
|
|
943
|
+
* An object indicating which additional language features you'd like to use.
|
|
944
|
+
*
|
|
945
|
+
* @see https://eslint.org/docs/latest/use/configure/language-options#specifying-parser-options
|
|
946
|
+
*/
|
|
947
|
+
ecmaFeatures?:
|
|
948
|
+
| {
|
|
949
|
+
/**
|
|
950
|
+
* Allow `return` statements in the global scope.
|
|
951
|
+
*
|
|
952
|
+
* @default false
|
|
953
|
+
*/
|
|
954
|
+
globalReturn?: boolean | undefined;
|
|
955
|
+
/**
|
|
956
|
+
* Enable global [strict mode](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode) (if `ecmaVersion` is 5 or greater).
|
|
957
|
+
*
|
|
958
|
+
* @default false
|
|
959
|
+
*/
|
|
960
|
+
impliedStrict?: boolean | undefined;
|
|
961
|
+
/**
|
|
962
|
+
* Enable [JSX](https://facebook.github.io/jsx/).
|
|
963
|
+
*
|
|
964
|
+
* @default false
|
|
965
|
+
*/
|
|
966
|
+
jsx?: boolean | undefined;
|
|
967
|
+
[key: string]: any;
|
|
968
|
+
}
|
|
969
|
+
| undefined;
|
|
970
|
+
[key: string]: any;
|
|
971
|
+
}
|
|
939
972
|
|
|
940
973
|
/**
|
|
941
974
|
* Options used for linting code with `Linter#verify` and `Linter#verifyAndFix`.
|
|
@@ -1386,6 +1419,12 @@ export class RuleTester {
|
|
|
1386
1419
|
* error does not contain them.
|
|
1387
1420
|
*/
|
|
1388
1421
|
requireLocation?: boolean;
|
|
1422
|
+
/**
|
|
1423
|
+
* If true, each error and suggestion with a `messageId` must specify a `data`
|
|
1424
|
+
* property if the referenced message contains placeholders.
|
|
1425
|
+
* `"error"` and `"suggestion" limit the assertion to errors and suggestions respectively.
|
|
1426
|
+
*/
|
|
1427
|
+
requireData?: boolean | "error" | "suggestion";
|
|
1389
1428
|
};
|
|
1390
1429
|
},
|
|
1391
1430
|
): void;
|
package/lib/types/rules.d.ts
CHANGED
|
@@ -1858,9 +1858,14 @@ export interface ESLintRules extends Linter.RulesRecord {
|
|
|
1858
1858
|
*/
|
|
1859
1859
|
max: number;
|
|
1860
1860
|
/**
|
|
1861
|
+
* @deprecated Replaced with `countThis'
|
|
1861
1862
|
* @default false
|
|
1862
1863
|
*/
|
|
1863
1864
|
countVoidThis: boolean;
|
|
1865
|
+
/**
|
|
1866
|
+
* @default "except-void"
|
|
1867
|
+
*/
|
|
1868
|
+
countThis: "always" | "never" | "except-void";
|
|
1864
1869
|
}>,
|
|
1865
1870
|
]
|
|
1866
1871
|
>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint",
|
|
3
|
-
"version": "10.0.0-
|
|
3
|
+
"version": "10.0.0-rc.0",
|
|
4
4
|
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
|
|
5
5
|
"description": "An AST-based pattern checker for JavaScript.",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -109,9 +109,9 @@
|
|
|
109
109
|
"@eslint-community/eslint-utils": "^4.8.0",
|
|
110
110
|
"@eslint-community/regexpp": "^4.12.2",
|
|
111
111
|
"@eslint/config-array": "^0.23.0",
|
|
112
|
-
"@eslint/config-helpers": "^0.5.
|
|
113
|
-
"@eslint/core": "^1.0.
|
|
114
|
-
"@eslint/plugin-kit": "^0.5.
|
|
112
|
+
"@eslint/config-helpers": "^0.5.1",
|
|
113
|
+
"@eslint/core": "^1.0.1",
|
|
114
|
+
"@eslint/plugin-kit": "^0.5.1",
|
|
115
115
|
"@humanfs/node": "^0.16.6",
|
|
116
116
|
"@humanwhocodes/module-importer": "^1.0.1",
|
|
117
117
|
"@humanwhocodes/retry": "^0.4.2",
|
|
@@ -193,7 +193,7 @@
|
|
|
193
193
|
"semver": "^7.5.3",
|
|
194
194
|
"shelljs": "^0.10.0",
|
|
195
195
|
"sinon": "^11.0.0",
|
|
196
|
-
"typescript": "^5.
|
|
196
|
+
"typescript": "^5.9.3",
|
|
197
197
|
"webpack": "^5.23.0",
|
|
198
198
|
"webpack-cli": "^4.5.0",
|
|
199
199
|
"yorkie": "^2.0.0"
|
package/lib/linter/rules.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Defines a storage for rules.
|
|
3
|
-
* @author Nicholas C. Zakas
|
|
4
|
-
* @author aladdin-add
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
"use strict";
|
|
8
|
-
|
|
9
|
-
//------------------------------------------------------------------------------
|
|
10
|
-
// Requirements
|
|
11
|
-
//------------------------------------------------------------------------------
|
|
12
|
-
|
|
13
|
-
const builtInRules = require("../rules");
|
|
14
|
-
|
|
15
|
-
//------------------------------------------------------------------------------
|
|
16
|
-
// Typedefs
|
|
17
|
-
//------------------------------------------------------------------------------
|
|
18
|
-
|
|
19
|
-
/** @typedef {import("../types").Rule.RuleModule} Rule */
|
|
20
|
-
|
|
21
|
-
//------------------------------------------------------------------------------
|
|
22
|
-
// Public Interface
|
|
23
|
-
//------------------------------------------------------------------------------
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* A storage for rules.
|
|
27
|
-
*/
|
|
28
|
-
class Rules {
|
|
29
|
-
constructor() {
|
|
30
|
-
this._rules = Object.create(null);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Registers a rule module for rule id in storage.
|
|
35
|
-
* @param {string} ruleId Rule id (file name).
|
|
36
|
-
* @param {Rule} rule Rule object.
|
|
37
|
-
* @returns {void}
|
|
38
|
-
*/
|
|
39
|
-
define(ruleId, rule) {
|
|
40
|
-
this._rules[ruleId] = rule;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Access rule handler by id (file name).
|
|
45
|
-
* @param {string} ruleId Rule id (file name).
|
|
46
|
-
* @returns {Rule} Rule object.
|
|
47
|
-
*/
|
|
48
|
-
get(ruleId) {
|
|
49
|
-
if (typeof this._rules[ruleId] === "string") {
|
|
50
|
-
this.define(ruleId, require(this._rules[ruleId]));
|
|
51
|
-
}
|
|
52
|
-
if (this._rules[ruleId]) {
|
|
53
|
-
return this._rules[ruleId];
|
|
54
|
-
}
|
|
55
|
-
if (builtInRules.has(ruleId)) {
|
|
56
|
-
return builtInRules.get(ruleId);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
*[Symbol.iterator]() {
|
|
63
|
-
yield* builtInRules;
|
|
64
|
-
|
|
65
|
-
for (const ruleId of Object.keys(this._rules)) {
|
|
66
|
-
yield [ruleId, this.get(ruleId)];
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
module.exports = Rules;
|