eslint 10.0.0-alpha.0 → 10.0.0-beta.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/api.js +2 -2
- package/lib/cli-engine/formatters/stylish.js +65 -34
- package/lib/cli.js +18 -8
- package/lib/eslint/eslint.js +4 -2
- package/lib/languages/js/index.js +1 -0
- package/lib/languages/js/source-code/source-code.js +27 -165
- package/lib/languages/js/source-code/token-store/index.js +0 -26
- package/lib/linter/linter.js +1 -0
- package/lib/rule-tester/rule-tester.js +117 -43
- package/lib/rules/array-bracket-spacing.js +4 -4
- package/lib/rules/block-spacing.js +1 -1
- package/lib/rules/comma-spacing.js +2 -5
- package/lib/rules/computed-property-spacing.js +4 -4
- package/lib/rules/keyword-spacing.js +4 -4
- package/lib/rules/no-extra-parens.js +1 -1
- package/lib/rules/no-restricted-imports.js +56 -14
- package/lib/rules/no-spaced-func.js +1 -1
- package/lib/rules/no-useless-assignment.js +8 -5
- package/lib/rules/no-useless-constructor.js +13 -3
- package/lib/rules/no-whitespace-before-property.js +1 -1
- package/lib/rules/object-curly-spacing.js +2 -8
- package/lib/rules/require-yield.js +11 -1
- package/lib/rules/rest-spread-spacing.js +1 -4
- package/lib/rules/semi-spacing.js +2 -2
- package/lib/rules/space-before-blocks.js +1 -1
- package/lib/rules/space-before-function-paren.js +1 -4
- package/lib/rules/space-in-parens.js +4 -4
- package/lib/rules/space-infix-ops.js +4 -7
- package/lib/rules/switch-colon-spacing.js +1 -1
- package/lib/rules/template-tag-spacing.js +1 -1
- package/lib/rules/utils/ast-utils.js +117 -22
- package/lib/rules/yield-star-spacing.js +1 -2
- package/lib/types/index.d.ts +59 -36
- package/lib/types/use-at-your-own-risk.d.ts +1 -1
- package/package.json +5 -6
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
+
//------------------------------------------------------------------------------
|
|
9
|
+
// Requirements
|
|
10
|
+
//------------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
const astUtils = require("./utils/ast-utils");
|
|
13
|
+
|
|
8
14
|
//------------------------------------------------------------------------------
|
|
9
15
|
// Rule Definition
|
|
10
16
|
//------------------------------------------------------------------------------
|
|
@@ -29,6 +35,7 @@ module.exports = {
|
|
|
29
35
|
|
|
30
36
|
create(context) {
|
|
31
37
|
const stack = [];
|
|
38
|
+
const sourceCode = context.sourceCode;
|
|
32
39
|
|
|
33
40
|
/**
|
|
34
41
|
* If the node is a generator function, start counting `yield` keywords.
|
|
@@ -55,7 +62,10 @@ module.exports = {
|
|
|
55
62
|
const countYield = stack.pop();
|
|
56
63
|
|
|
57
64
|
if (countYield === 0 && node.body.body.length > 0) {
|
|
58
|
-
context.report({
|
|
65
|
+
context.report({
|
|
66
|
+
loc: astUtils.getFunctionHeadLoc(node, sourceCode),
|
|
67
|
+
messageId: "missingYield",
|
|
68
|
+
});
|
|
59
69
|
}
|
|
60
70
|
}
|
|
61
71
|
|
|
@@ -74,10 +74,7 @@ module.exports = {
|
|
|
74
74
|
function checkWhiteSpace(node) {
|
|
75
75
|
const operator = sourceCode.getFirstToken(node),
|
|
76
76
|
nextToken = sourceCode.getTokenAfter(operator),
|
|
77
|
-
hasWhitespace = sourceCode.
|
|
78
|
-
operator,
|
|
79
|
-
nextToken,
|
|
80
|
-
);
|
|
77
|
+
hasWhitespace = sourceCode.isSpaceBetween(operator, nextToken);
|
|
81
78
|
let type;
|
|
82
79
|
|
|
83
80
|
switch (node.type) {
|
|
@@ -95,7 +95,7 @@ module.exports = {
|
|
|
95
95
|
return (
|
|
96
96
|
tokenBefore &&
|
|
97
97
|
astUtils.isTokenOnSameLine(tokenBefore, token) &&
|
|
98
|
-
sourceCode.
|
|
98
|
+
sourceCode.isSpaceBetween(tokenBefore, token)
|
|
99
99
|
);
|
|
100
100
|
}
|
|
101
101
|
|
|
@@ -110,7 +110,7 @@ module.exports = {
|
|
|
110
110
|
return (
|
|
111
111
|
tokenAfter &&
|
|
112
112
|
astUtils.isTokenOnSameLine(token, tokenAfter) &&
|
|
113
|
-
sourceCode.
|
|
113
|
+
sourceCode.isSpaceBetween(token, tokenAfter)
|
|
114
114
|
);
|
|
115
115
|
}
|
|
116
116
|
|
|
@@ -164,7 +164,7 @@ module.exports = {
|
|
|
164
164
|
!isConflicted(precedingToken, node) &&
|
|
165
165
|
astUtils.isTokenOnSameLine(precedingToken, node)
|
|
166
166
|
) {
|
|
167
|
-
const hasSpace = sourceCode.
|
|
167
|
+
const hasSpace = sourceCode.isSpaceBetween(
|
|
168
168
|
precedingToken,
|
|
169
169
|
node,
|
|
170
170
|
);
|
|
@@ -155,10 +155,7 @@ module.exports = {
|
|
|
155
155
|
astUtils.isOpeningParenToken,
|
|
156
156
|
);
|
|
157
157
|
const leftToken = sourceCode.getTokenBefore(rightToken);
|
|
158
|
-
const hasSpacing = sourceCode.
|
|
159
|
-
leftToken,
|
|
160
|
-
rightToken,
|
|
161
|
-
);
|
|
158
|
+
const hasSpacing = sourceCode.isSpaceBetween(leftToken, rightToken);
|
|
162
159
|
|
|
163
160
|
if (hasSpacing && functionConfig === "never") {
|
|
164
161
|
context.report({
|
|
@@ -153,7 +153,7 @@ module.exports = {
|
|
|
153
153
|
*/
|
|
154
154
|
function openerMissingSpace(openingParenToken, tokenAfterOpeningParen) {
|
|
155
155
|
if (
|
|
156
|
-
sourceCode.
|
|
156
|
+
sourceCode.isSpaceBetween(
|
|
157
157
|
openingParenToken,
|
|
158
158
|
tokenAfterOpeningParen,
|
|
159
159
|
)
|
|
@@ -195,7 +195,7 @@ module.exports = {
|
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
if (
|
|
198
|
-
!sourceCode.
|
|
198
|
+
!sourceCode.isSpaceBetween(
|
|
199
199
|
openingParenToken,
|
|
200
200
|
tokenAfterOpeningParen,
|
|
201
201
|
)
|
|
@@ -220,7 +220,7 @@ module.exports = {
|
|
|
220
220
|
closingParenToken,
|
|
221
221
|
) {
|
|
222
222
|
if (
|
|
223
|
-
sourceCode.
|
|
223
|
+
sourceCode.isSpaceBetween(
|
|
224
224
|
tokenBeforeClosingParen,
|
|
225
225
|
closingParenToken,
|
|
226
226
|
)
|
|
@@ -261,7 +261,7 @@ module.exports = {
|
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
if (
|
|
264
|
-
!sourceCode.
|
|
264
|
+
!sourceCode.isSpaceBetween(
|
|
265
265
|
tokenBeforeClosingParen,
|
|
266
266
|
closingParenToken,
|
|
267
267
|
)
|
|
@@ -87,8 +87,8 @@ module.exports = {
|
|
|
87
87
|
const next = sourceCode.getTokenAfter(operator);
|
|
88
88
|
|
|
89
89
|
if (
|
|
90
|
-
!sourceCode.
|
|
91
|
-
!sourceCode.
|
|
90
|
+
!sourceCode.isSpaceBetween(prev, operator) ||
|
|
91
|
+
!sourceCode.isSpaceBetween(operator, next)
|
|
92
92
|
) {
|
|
93
93
|
return operator;
|
|
94
94
|
}
|
|
@@ -238,11 +238,8 @@ module.exports = {
|
|
|
238
238
|
const rightToken = sourceCode.getTokenAfter(operatorToken);
|
|
239
239
|
|
|
240
240
|
if (
|
|
241
|
-
!sourceCode.
|
|
242
|
-
|
|
243
|
-
operatorToken,
|
|
244
|
-
) ||
|
|
245
|
-
!sourceCode.isSpaceBetweenTokens(operatorToken, rightToken)
|
|
241
|
+
!sourceCode.isSpaceBetween(leftToken, operatorToken) ||
|
|
242
|
+
!sourceCode.isSpaceBetween(operatorToken, rightToken)
|
|
246
243
|
) {
|
|
247
244
|
report(node, operatorToken);
|
|
248
245
|
}
|
|
@@ -66,7 +66,7 @@ module.exports = {
|
|
|
66
66
|
function checkSpacing(node) {
|
|
67
67
|
const tagToken = sourceCode.getTokenBefore(node.quasi);
|
|
68
68
|
const literalToken = sourceCode.getFirstToken(node.quasi);
|
|
69
|
-
const hasWhitespace = sourceCode.
|
|
69
|
+
const hasWhitespace = sourceCode.isSpaceBetween(
|
|
70
70
|
tagToken,
|
|
71
71
|
literalToken,
|
|
72
72
|
);
|
|
@@ -544,28 +544,6 @@ function negate(f) {
|
|
|
544
544
|
return token => !f(token);
|
|
545
545
|
}
|
|
546
546
|
|
|
547
|
-
/**
|
|
548
|
-
* Checks whether or not a node has a `@this` tag in its comments.
|
|
549
|
-
* @param {ASTNode} node A node to check.
|
|
550
|
-
* @param {SourceCode} sourceCode A SourceCode instance to get comments.
|
|
551
|
-
* @returns {boolean} Whether or not the node has a `@this` tag in its comments.
|
|
552
|
-
*/
|
|
553
|
-
function hasJSDocThisTag(node, sourceCode) {
|
|
554
|
-
const jsdocComment = sourceCode.getJSDocComment(node);
|
|
555
|
-
|
|
556
|
-
if (jsdocComment && thisTagPattern.test(jsdocComment.value)) {
|
|
557
|
-
return true;
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
// Checks `@this` in its leading comments for callbacks,
|
|
561
|
-
// because callbacks don't have its JSDoc comment.
|
|
562
|
-
// e.g.
|
|
563
|
-
// sinon.test(/* @this sinon.Sandbox */function() { this.spy(); });
|
|
564
|
-
return sourceCode
|
|
565
|
-
.getCommentsBefore(node)
|
|
566
|
-
.some(comment => thisTagPattern.test(comment.value));
|
|
567
|
-
}
|
|
568
|
-
|
|
569
547
|
/**
|
|
570
548
|
* Determines if a node is surrounded by parentheses.
|
|
571
549
|
* @param {SourceCode} sourceCode The ESLint source code object
|
|
@@ -725,6 +703,123 @@ function isKeywordToken(token) {
|
|
|
725
703
|
return token.type === "Keyword";
|
|
726
704
|
}
|
|
727
705
|
|
|
706
|
+
/**
|
|
707
|
+
* Checks whether the given node represents an ES6 export declaration.
|
|
708
|
+
* @param {ASTNode} node A node to check.
|
|
709
|
+
* @returns {boolean} `true` if the node is an export declaration.
|
|
710
|
+
* @private
|
|
711
|
+
*/
|
|
712
|
+
function isExportDeclaration(node) {
|
|
713
|
+
return (
|
|
714
|
+
node.type === "ExportDefaultDeclaration" ||
|
|
715
|
+
node.type === "ExportNamedDeclaration" ||
|
|
716
|
+
node.type === "ExportAllDeclaration"
|
|
717
|
+
);
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* Checks for the presence of a JSDoc comment for the given node and returns it.
|
|
722
|
+
* @param {ASTNode} node The node to get the comment for.
|
|
723
|
+
* @param {SourceCode} sourceCode A SourceCode instance to get comments.
|
|
724
|
+
* @returns {Token|null} The Block comment token containing the JSDoc comment for the given node or null if not found.
|
|
725
|
+
* @private
|
|
726
|
+
*/
|
|
727
|
+
function findJSDocComment(node, sourceCode) {
|
|
728
|
+
const tokenBefore = sourceCode.getTokenBefore(node, {
|
|
729
|
+
includeComments: true,
|
|
730
|
+
});
|
|
731
|
+
|
|
732
|
+
if (
|
|
733
|
+
tokenBefore &&
|
|
734
|
+
tokenBefore.type === "Block" &&
|
|
735
|
+
tokenBefore.value.charAt(0) === "*" &&
|
|
736
|
+
node.loc.start.line - tokenBefore.loc.end.line <= 1
|
|
737
|
+
) {
|
|
738
|
+
return tokenBefore;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
return null;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
/**
|
|
745
|
+
* Retrieves the JSDoc comment for a given node.
|
|
746
|
+
* @param {ASTNode} node The node to get the comment for.
|
|
747
|
+
* @param {SourceCode} sourceCode A SourceCode instance to get comments.
|
|
748
|
+
* @returns {Token|null} The Block comment token containing the JSDoc comment for the given node or null if not found.
|
|
749
|
+
* @private
|
|
750
|
+
*/
|
|
751
|
+
function getJSDocComment(node, sourceCode) {
|
|
752
|
+
let parent = node.parent;
|
|
753
|
+
|
|
754
|
+
switch (node.type) {
|
|
755
|
+
case "ClassDeclaration":
|
|
756
|
+
case "FunctionDeclaration":
|
|
757
|
+
return findJSDocComment(
|
|
758
|
+
isExportDeclaration(parent) ? parent : node,
|
|
759
|
+
sourceCode,
|
|
760
|
+
);
|
|
761
|
+
|
|
762
|
+
case "ClassExpression":
|
|
763
|
+
return findJSDocComment(parent.parent, sourceCode);
|
|
764
|
+
|
|
765
|
+
case "ArrowFunctionExpression":
|
|
766
|
+
case "FunctionExpression":
|
|
767
|
+
if (
|
|
768
|
+
parent.type !== "CallExpression" &&
|
|
769
|
+
parent.type !== "NewExpression"
|
|
770
|
+
) {
|
|
771
|
+
while (
|
|
772
|
+
!sourceCode.getCommentsBefore(parent).length &&
|
|
773
|
+
!/Function/u.test(parent.type) &&
|
|
774
|
+
parent.type !== "MethodDefinition" &&
|
|
775
|
+
parent.type !== "Property"
|
|
776
|
+
) {
|
|
777
|
+
parent = parent.parent;
|
|
778
|
+
|
|
779
|
+
if (!parent) {
|
|
780
|
+
break;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
if (
|
|
785
|
+
parent &&
|
|
786
|
+
parent.type !== "FunctionDeclaration" &&
|
|
787
|
+
parent.type !== "Program"
|
|
788
|
+
) {
|
|
789
|
+
return findJSDocComment(parent, sourceCode);
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
return findJSDocComment(node, sourceCode);
|
|
794
|
+
|
|
795
|
+
// falls through
|
|
796
|
+
default:
|
|
797
|
+
return null;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
/**
|
|
802
|
+
* Checks whether or not a node has a `@this` tag in its comments.
|
|
803
|
+
* @param {ASTNode} node A node to check.
|
|
804
|
+
* @param {SourceCode} sourceCode A SourceCode instance to get comments.
|
|
805
|
+
* @returns {boolean} Whether or not the node has a `@this` tag in its comments.
|
|
806
|
+
*/
|
|
807
|
+
function hasJSDocThisTag(node, sourceCode) {
|
|
808
|
+
const jsdocComment = getJSDocComment(node, sourceCode);
|
|
809
|
+
|
|
810
|
+
if (jsdocComment && thisTagPattern.test(jsdocComment.value)) {
|
|
811
|
+
return true;
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
// Checks `@this` in its leading comments for callbacks,
|
|
815
|
+
// because callbacks don't have its JSDoc comment.
|
|
816
|
+
// e.g.
|
|
817
|
+
// sinon.test(/* @this sinon.Sandbox */function() { this.spy(); });
|
|
818
|
+
return sourceCode
|
|
819
|
+
.getCommentsBefore(node)
|
|
820
|
+
.some(comment => thisTagPattern.test(comment.value));
|
|
821
|
+
}
|
|
822
|
+
|
|
728
823
|
/**
|
|
729
824
|
* Gets the `(` token of the given function node.
|
|
730
825
|
* @param {ASTNode} node The function node to get.
|
|
@@ -96,8 +96,7 @@ module.exports = {
|
|
|
96
96
|
*/
|
|
97
97
|
function checkSpacing(side, leftToken, rightToken) {
|
|
98
98
|
if (
|
|
99
|
-
sourceCode.
|
|
100
|
-
mode[side]
|
|
99
|
+
sourceCode.isSpaceBetween(leftToken, rightToken) !== mode[side]
|
|
101
100
|
) {
|
|
102
101
|
const after = leftToken.value === "*";
|
|
103
102
|
const spaceRequired = mode[side];
|
package/lib/types/index.d.ts
CHANGED
|
@@ -115,7 +115,7 @@ export namespace AST {
|
|
|
115
115
|
end: ESTree.Position;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
type Range =
|
|
118
|
+
type Range = SourceRange;
|
|
119
119
|
|
|
120
120
|
interface Program extends ESTree.Program {
|
|
121
121
|
comments: ESTree.Comment[];
|
|
@@ -125,6 +125,11 @@ export namespace AST {
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
interface JSXIdentifier extends ESTree.BaseNode {
|
|
129
|
+
type: "JSXIdentifier";
|
|
130
|
+
name: string;
|
|
131
|
+
}
|
|
132
|
+
|
|
128
133
|
export namespace Scope {
|
|
129
134
|
interface ScopeManager {
|
|
130
135
|
scopes: Scope[];
|
|
@@ -177,7 +182,7 @@ export namespace Scope {
|
|
|
177
182
|
}
|
|
178
183
|
|
|
179
184
|
interface Reference {
|
|
180
|
-
identifier: ESTree.Identifier;
|
|
185
|
+
identifier: ESTree.Identifier | JSXIdentifier;
|
|
181
186
|
from: Scope;
|
|
182
187
|
resolved: Variable | null;
|
|
183
188
|
writeExpr: ESTree.Node | null;
|
|
@@ -281,17 +286,8 @@ export class SourceCode
|
|
|
281
286
|
|
|
282
287
|
getDeclaredVariables(node: ESTree.Node): Scope.Variable[];
|
|
283
288
|
|
|
284
|
-
/** @deprecated */
|
|
285
|
-
getJSDocComment(node: ESTree.Node): ESTree.Comment | null;
|
|
286
|
-
|
|
287
289
|
getNodeByRangeIndex(index: number): ESTree.Node | null;
|
|
288
290
|
|
|
289
|
-
/** @deprecated Use `isSpaceBetween()` instead. */
|
|
290
|
-
isSpaceBetweenTokens(
|
|
291
|
-
first: ESTree.Node | AST.Token,
|
|
292
|
-
second: ESTree.Node | AST.Token,
|
|
293
|
-
): boolean;
|
|
294
|
-
|
|
295
291
|
getLocFromIndex(index: number): ESTree.Position;
|
|
296
292
|
|
|
297
293
|
getIndexFromLoc(location: ESTree.Position): number;
|
|
@@ -324,18 +320,6 @@ export class SourceCode
|
|
|
324
320
|
|
|
325
321
|
getTokensAfter: SourceCode.UnaryCursorWithCountOptions;
|
|
326
322
|
|
|
327
|
-
/** @deprecated Use `getTokenBefore()` instead. */
|
|
328
|
-
getTokenOrCommentBefore(
|
|
329
|
-
node: ESTree.Node | AST.Token | ESTree.Comment,
|
|
330
|
-
skip?: number | undefined,
|
|
331
|
-
): AST.Token | ESTree.Comment | null;
|
|
332
|
-
|
|
333
|
-
/** @deprecated Use `getTokenAfter()` instead. */
|
|
334
|
-
getTokenOrCommentAfter(
|
|
335
|
-
node: ESTree.Node | AST.Token | ESTree.Comment,
|
|
336
|
-
skip?: number | undefined,
|
|
337
|
-
): AST.Token | ESTree.Comment | null;
|
|
338
|
-
|
|
339
323
|
getFirstTokenBetween: SourceCode.BinaryCursorWithSkipOptions;
|
|
340
324
|
|
|
341
325
|
getFirstTokensBetween: SourceCode.BinaryCursorWithCountOptions;
|
|
@@ -1277,9 +1261,8 @@ export namespace ESLint {
|
|
|
1277
1261
|
foundWarnings: number;
|
|
1278
1262
|
}
|
|
1279
1263
|
|
|
1280
|
-
interface LintResultData {
|
|
1264
|
+
interface LintResultData extends ResultsMeta {
|
|
1281
1265
|
cwd: string;
|
|
1282
|
-
maxWarningsExceeded?: MaxWarningsExceeded | undefined;
|
|
1283
1266
|
rulesMeta: {
|
|
1284
1267
|
[ruleId: string]: Rule.RuleMetaData;
|
|
1285
1268
|
};
|
|
@@ -1311,6 +1294,14 @@ export namespace ESLint {
|
|
|
1311
1294
|
* Metadata about results for formatters.
|
|
1312
1295
|
*/
|
|
1313
1296
|
interface ResultsMeta {
|
|
1297
|
+
/**
|
|
1298
|
+
* Whether or not to use color in the formatter output.
|
|
1299
|
+
* - If `--color` was set, this property is `true`.
|
|
1300
|
+
* - If `--no-color` was set, it is `false`.
|
|
1301
|
+
* - If neither option was provided, the property is omitted.
|
|
1302
|
+
*/
|
|
1303
|
+
color?: boolean | undefined;
|
|
1304
|
+
|
|
1314
1305
|
/**
|
|
1315
1306
|
* Present if the maxWarnings threshold was exceeded.
|
|
1316
1307
|
*/
|
|
@@ -1322,9 +1313,9 @@ export namespace ESLint {
|
|
|
1322
1313
|
/**
|
|
1323
1314
|
* Used to call the underlying formatter.
|
|
1324
1315
|
* @param results An array of lint results to format.
|
|
1325
|
-
* @param resultsMeta An object with
|
|
1316
|
+
* @param resultsMeta An object with optional `color` and `maxWarningsExceeded` properties that will be
|
|
1326
1317
|
* passed to the underlying formatter function along with other properties set by ESLint.
|
|
1327
|
-
* This argument can be omitted if `maxWarningsExceeded`
|
|
1318
|
+
* This argument can be omitted if `color` and `maxWarningsExceeded` are not needed.
|
|
1328
1319
|
* @return The formatter output.
|
|
1329
1320
|
*/
|
|
1330
1321
|
format(
|
|
@@ -1353,9 +1344,10 @@ export namespace ESLint {
|
|
|
1353
1344
|
|
|
1354
1345
|
// #endregion
|
|
1355
1346
|
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1347
|
+
/**
|
|
1348
|
+
* Loads the correct `ESLint` constructor.
|
|
1349
|
+
*/
|
|
1350
|
+
export function loadESLint(): Promise<typeof ESLint>;
|
|
1359
1351
|
|
|
1360
1352
|
// #region RuleTester
|
|
1361
1353
|
|
|
@@ -1363,6 +1355,9 @@ export class RuleTester {
|
|
|
1363
1355
|
static describe: ((...args: any) => any) | null;
|
|
1364
1356
|
static it: ((...args: any) => any) | null;
|
|
1365
1357
|
static itOnly: ((...args: any) => any) | null;
|
|
1358
|
+
static setDefaultConfig(config: Linter.Config): void;
|
|
1359
|
+
static getDefaultConfig(): Linter.Config;
|
|
1360
|
+
static resetDefaultConfig(): void;
|
|
1366
1361
|
|
|
1367
1362
|
constructor(config?: Linter.Config);
|
|
1368
1363
|
|
|
@@ -1372,6 +1367,26 @@ export class RuleTester {
|
|
|
1372
1367
|
tests: {
|
|
1373
1368
|
valid: Array<string | RuleTester.ValidTestCase>;
|
|
1374
1369
|
invalid: RuleTester.InvalidTestCase[];
|
|
1370
|
+
/**
|
|
1371
|
+
* Additional assertions for the "error" matchers of invalid test cases to enforce consistency.
|
|
1372
|
+
*/
|
|
1373
|
+
assertionOptions?: {
|
|
1374
|
+
/**
|
|
1375
|
+
* If true, each `errors` block must check the expected error
|
|
1376
|
+
* message, either via a string in the `errors` array, or via
|
|
1377
|
+
* `message`/`messageId` in an errors object.
|
|
1378
|
+
* `"message"`/`"messageId"` can be used to further limit the
|
|
1379
|
+
* message assertions to the respective versions.
|
|
1380
|
+
*/
|
|
1381
|
+
requireMessage?: boolean | "message" | "messageId";
|
|
1382
|
+
/**
|
|
1383
|
+
* If true, each `errors` block must be an array of objects,
|
|
1384
|
+
* that each check all location properties `line`, `column`,
|
|
1385
|
+
* `endLine`, `endColumn`, the later may be omitted, if the
|
|
1386
|
+
* error does not contain them.
|
|
1387
|
+
*/
|
|
1388
|
+
requireLocation?: boolean;
|
|
1389
|
+
};
|
|
1375
1390
|
},
|
|
1376
1391
|
): void;
|
|
1377
1392
|
|
|
@@ -1381,14 +1396,22 @@ export class RuleTester {
|
|
|
1381
1396
|
}
|
|
1382
1397
|
|
|
1383
1398
|
export namespace RuleTester {
|
|
1384
|
-
interface ValidTestCase
|
|
1399
|
+
interface ValidTestCase
|
|
1400
|
+
extends Omit<
|
|
1401
|
+
Linter.Config,
|
|
1402
|
+
| "name"
|
|
1403
|
+
| "basePath"
|
|
1404
|
+
| "files"
|
|
1405
|
+
| "ignores"
|
|
1406
|
+
| "linterOptions"
|
|
1407
|
+
| "plugins"
|
|
1408
|
+
| "rules"
|
|
1409
|
+
> {
|
|
1385
1410
|
name?: string;
|
|
1386
1411
|
code: string;
|
|
1387
|
-
options?: any;
|
|
1412
|
+
options?: any[];
|
|
1388
1413
|
filename?: string | undefined;
|
|
1389
1414
|
only?: boolean;
|
|
1390
|
-
languageOptions?: Linter.LanguageOptions | undefined;
|
|
1391
|
-
settings?: { [name: string]: any } | undefined;
|
|
1392
1415
|
before?: () => void;
|
|
1393
1416
|
after?: () => void;
|
|
1394
1417
|
}
|
|
@@ -1401,7 +1424,7 @@ export namespace RuleTester {
|
|
|
1401
1424
|
}
|
|
1402
1425
|
|
|
1403
1426
|
interface InvalidTestCase extends ValidTestCase {
|
|
1404
|
-
errors: number | Array<TestCaseError | string>;
|
|
1427
|
+
errors: number | Array<TestCaseError | string | RegExp>;
|
|
1405
1428
|
output?: string | null | undefined;
|
|
1406
1429
|
}
|
|
1407
1430
|
|
|
@@ -1413,7 +1436,7 @@ export namespace RuleTester {
|
|
|
1413
1436
|
column?: number | undefined;
|
|
1414
1437
|
endLine?: number | undefined;
|
|
1415
1438
|
endColumn?: number | undefined;
|
|
1416
|
-
suggestions?: SuggestionOutput[] | undefined;
|
|
1439
|
+
suggestions?: SuggestionOutput[] | number | undefined;
|
|
1417
1440
|
}
|
|
1418
1441
|
}
|
|
1419
1442
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint",
|
|
3
|
-
"version": "10.0.0-
|
|
3
|
+
"version": "10.0.0-beta.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",
|
|
@@ -107,8 +107,8 @@
|
|
|
107
107
|
"bugs": "https://github.com/eslint/eslint/issues/",
|
|
108
108
|
"dependencies": {
|
|
109
109
|
"@eslint-community/eslint-utils": "^4.8.0",
|
|
110
|
-
"@eslint-community/regexpp": "^4.12.
|
|
111
|
-
"@eslint/config-array": "^0.
|
|
110
|
+
"@eslint-community/regexpp": "^4.12.2",
|
|
111
|
+
"@eslint/config-array": "^0.23.0",
|
|
112
112
|
"@eslint/config-helpers": "^0.5.0",
|
|
113
113
|
"@eslint/core": "^1.0.0",
|
|
114
114
|
"@eslint/plugin-kit": "^0.5.0",
|
|
@@ -117,7 +117,6 @@
|
|
|
117
117
|
"@humanwhocodes/retry": "^0.4.2",
|
|
118
118
|
"@types/estree": "^1.0.6",
|
|
119
119
|
"ajv": "^6.12.4",
|
|
120
|
-
"chalk": "^4.0.0",
|
|
121
120
|
"cross-spawn": "^7.0.6",
|
|
122
121
|
"debug": "^4.3.2",
|
|
123
122
|
"escape-string-regexp": "^4.0.0",
|
|
@@ -134,7 +133,7 @@
|
|
|
134
133
|
"imurmurhash": "^0.1.4",
|
|
135
134
|
"is-glob": "^4.0.0",
|
|
136
135
|
"json-stable-stringify-without-jsonify": "^1.0.1",
|
|
137
|
-
"minimatch": "^
|
|
136
|
+
"minimatch": "^10.1.1",
|
|
138
137
|
"natural-compare": "^1.4.0",
|
|
139
138
|
"optionator": "^0.9.3"
|
|
140
139
|
},
|
|
@@ -144,7 +143,7 @@
|
|
|
144
143
|
"@babel/preset-env": "^7.4.3",
|
|
145
144
|
"@cypress/webpack-preprocessor": "^6.0.2",
|
|
146
145
|
"@eslint/json": "^0.14.0",
|
|
147
|
-
"@eslint/eslintrc": "^3.3.
|
|
146
|
+
"@eslint/eslintrc": "^3.3.3",
|
|
148
147
|
"@trunkio/launcher": "^1.3.4",
|
|
149
148
|
"@types/esquery": "^1.5.4",
|
|
150
149
|
"@types/node": "^22.13.14",
|