eslint 9.36.0 → 9.37.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 +2 -2
- package/lib/cli-engine/lint-result-cache.js +47 -29
- package/lib/eslint/eslint-helpers.js +6 -3
- package/lib/eslint/eslint.js +151 -37
- package/lib/eslint/worker.js +1 -3
- package/lib/linter/esquery.js +1 -1
- package/lib/rules/array-bracket-newline.js +1 -1
- package/lib/rules/array-bracket-spacing.js +1 -1
- package/lib/rules/array-element-newline.js +1 -1
- package/lib/rules/arrow-parens.js +1 -1
- package/lib/rules/arrow-spacing.js +1 -1
- package/lib/rules/block-spacing.js +1 -1
- package/lib/rules/brace-style.js +1 -1
- package/lib/rules/comma-dangle.js +1 -1
- package/lib/rules/comma-spacing.js +1 -1
- package/lib/rules/comma-style.js +1 -1
- package/lib/rules/computed-property-spacing.js +1 -1
- package/lib/rules/dot-location.js +1 -1
- package/lib/rules/eol-last.js +1 -1
- package/lib/rules/func-call-spacing.js +2 -2
- package/lib/rules/function-call-argument-newline.js +1 -1
- package/lib/rules/function-paren-newline.js +1 -1
- package/lib/rules/generator-star-spacing.js +1 -1
- package/lib/rules/implicit-arrow-linebreak.js +1 -1
- package/lib/rules/indent-legacy.js +1 -0
- package/lib/rules/indent.js +1 -1
- package/lib/rules/jsx-quotes.js +1 -1
- package/lib/rules/key-spacing.js +1 -1
- package/lib/rules/keyword-spacing.js +1 -1
- package/lib/rules/line-comment-position.js +1 -1
- package/lib/rules/linebreak-style.js +1 -1
- package/lib/rules/lines-around-comment.js +1 -1
- package/lib/rules/lines-around-directive.js +1 -1
- package/lib/rules/lines-between-class-members.js +1 -1
- package/lib/rules/max-len.js +1 -1
- package/lib/rules/max-statements-per-line.js +1 -1
- package/lib/rules/multiline-comment-style.js +1 -1
- package/lib/rules/multiline-ternary.js +1 -1
- package/lib/rules/new-parens.js +1 -1
- package/lib/rules/newline-after-var.js +1 -1
- package/lib/rules/newline-before-return.js +1 -1
- package/lib/rules/newline-per-chained-call.js +1 -1
- package/lib/rules/no-confusing-arrow.js +1 -1
- package/lib/rules/no-extra-parens.js +1 -1
- package/lib/rules/no-extra-semi.js +1 -1
- package/lib/rules/no-floating-decimal.js +1 -1
- package/lib/rules/no-loss-of-precision.js +5 -8
- package/lib/rules/no-mixed-operators.js +1 -1
- package/lib/rules/no-mixed-spaces-and-tabs.js +1 -1
- package/lib/rules/no-multi-spaces.js +1 -1
- package/lib/rules/no-multiple-empty-lines.js +1 -1
- package/lib/rules/no-restricted-imports.js +171 -4
- package/lib/rules/no-spaced-func.js +1 -1
- package/lib/rules/no-tabs.js +1 -1
- package/lib/rules/no-trailing-spaces.js +1 -1
- package/lib/rules/no-whitespace-before-property.js +1 -1
- package/lib/rules/nonblock-statement-body-position.js +1 -1
- package/lib/rules/object-curly-newline.js +1 -1
- package/lib/rules/object-curly-spacing.js +1 -1
- package/lib/rules/object-property-newline.js +1 -1
- package/lib/rules/one-var-declaration-per-line.js +1 -1
- package/lib/rules/operator-linebreak.js +1 -1
- package/lib/rules/padded-blocks.js +1 -1
- package/lib/rules/padding-line-between-statements.js +1 -1
- package/lib/rules/preserve-caught-error.js +1 -5
- package/lib/rules/quote-props.js +1 -1
- package/lib/rules/quotes.js +1 -1
- package/lib/rules/rest-spread-spacing.js +1 -1
- package/lib/rules/semi-spacing.js +1 -1
- package/lib/rules/semi-style.js +1 -1
- package/lib/rules/semi.js +1 -1
- package/lib/rules/space-before-blocks.js +1 -1
- package/lib/rules/space-before-function-paren.js +1 -1
- package/lib/rules/space-in-parens.js +1 -1
- package/lib/rules/space-infix-ops.js +1 -1
- package/lib/rules/space-unary-ops.js +1 -1
- package/lib/rules/spaced-comment.js +1 -1
- package/lib/rules/switch-colon-spacing.js +1 -1
- package/lib/rules/template-curly-spacing.js +1 -1
- package/lib/rules/template-tag-spacing.js +1 -1
- package/lib/rules/wrap-iife.js +1 -1
- package/lib/rules/wrap-regex.js +1 -1
- package/lib/rules/yield-star-spacing.js +1 -1
- package/lib/types/index.d.ts +8 -5
- package/lib/types/rules.d.ts +2 -0
- package/package.json +6 -6
@@ -33,7 +33,7 @@ module.exports = {
|
|
33
33
|
message: "Formatting rules are being moved out of ESLint core.",
|
34
34
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
35
35
|
deprecatedSince: "8.53.0",
|
36
|
-
availableUntil: "
|
36
|
+
availableUntil: "11.0.0",
|
37
37
|
replacedBy: [
|
38
38
|
{
|
39
39
|
message:
|
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
message: "Formatting rules are being moved out of ESLint core.",
|
18
18
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
19
19
|
deprecatedSince: "8.53.0",
|
20
|
-
availableUntil: "
|
20
|
+
availableUntil: "11.0.0",
|
21
21
|
replacedBy: [
|
22
22
|
{
|
23
23
|
message:
|
package/lib/rules/indent.js
CHANGED
@@ -512,7 +512,7 @@ module.exports = {
|
|
512
512
|
message: "Formatting rules are being moved out of ESLint core.",
|
513
513
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
514
514
|
deprecatedSince: "8.53.0",
|
515
|
-
availableUntil: "
|
515
|
+
availableUntil: "11.0.0",
|
516
516
|
replacedBy: [
|
517
517
|
{
|
518
518
|
message:
|
package/lib/rules/jsx-quotes.js
CHANGED
@@ -44,7 +44,7 @@ module.exports = {
|
|
44
44
|
message: "Formatting rules are being moved out of ESLint core.",
|
45
45
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
46
46
|
deprecatedSince: "8.53.0",
|
47
|
-
availableUntil: "
|
47
|
+
availableUntil: "11.0.0",
|
48
48
|
replacedBy: [
|
49
49
|
{
|
50
50
|
message:
|
package/lib/rules/key-spacing.js
CHANGED
@@ -151,7 +151,7 @@ module.exports = {
|
|
151
151
|
message: "Formatting rules are being moved out of ESLint core.",
|
152
152
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
153
153
|
deprecatedSince: "8.53.0",
|
154
|
-
availableUntil: "
|
154
|
+
availableUntil: "11.0.0",
|
155
155
|
replacedBy: [
|
156
156
|
{
|
157
157
|
message:
|
@@ -82,7 +82,7 @@ module.exports = {
|
|
82
82
|
message: "Formatting rules are being moved out of ESLint core.",
|
83
83
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
84
84
|
deprecatedSince: "8.53.0",
|
85
|
-
availableUntil: "
|
85
|
+
availableUntil: "11.0.0",
|
86
86
|
replacedBy: [
|
87
87
|
{
|
88
88
|
message:
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
18
18
|
message: "Formatting rules are being moved out of ESLint core.",
|
19
19
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
20
20
|
deprecatedSince: "9.3.0",
|
21
|
-
availableUntil: "
|
21
|
+
availableUntil: "11.0.0",
|
22
22
|
replacedBy: [
|
23
23
|
{
|
24
24
|
message:
|
@@ -31,7 +31,7 @@ module.exports = {
|
|
31
31
|
message: "Formatting rules are being moved out of ESLint core.",
|
32
32
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
33
33
|
deprecatedSince: "8.53.0",
|
34
|
-
availableUntil: "
|
34
|
+
availableUntil: "11.0.0",
|
35
35
|
replacedBy: [
|
36
36
|
{
|
37
37
|
message:
|
@@ -60,7 +60,7 @@ module.exports = {
|
|
60
60
|
message: "Formatting rules are being moved out of ESLint core.",
|
61
61
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
62
62
|
deprecatedSince: "8.53.0",
|
63
|
-
availableUntil: "
|
63
|
+
availableUntil: "11.0.0",
|
64
64
|
replacedBy: [
|
65
65
|
{
|
66
66
|
message:
|
@@ -56,7 +56,7 @@ module.exports = {
|
|
56
56
|
message: "The rule was replaced with a more general rule.",
|
57
57
|
url: "https://eslint.org/blog/2017/06/eslint-v4.0.0-released/",
|
58
58
|
deprecatedSince: "4.0.0",
|
59
|
-
availableUntil:
|
59
|
+
availableUntil: "11.0.0",
|
60
60
|
replacedBy: [
|
61
61
|
{
|
62
62
|
message: "The new rule moved to a plugin.",
|
@@ -37,7 +37,7 @@ module.exports = {
|
|
37
37
|
message: "Formatting rules are being moved out of ESLint core.",
|
38
38
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
39
39
|
deprecatedSince: "8.53.0",
|
40
|
-
availableUntil: "
|
40
|
+
availableUntil: "11.0.0",
|
41
41
|
replacedBy: [
|
42
42
|
{
|
43
43
|
message:
|
package/lib/rules/max-len.js
CHANGED
@@ -71,7 +71,7 @@ module.exports = {
|
|
71
71
|
message: "Formatting rules are being moved out of ESLint core.",
|
72
72
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
73
73
|
deprecatedSince: "8.53.0",
|
74
|
-
availableUntil: "
|
74
|
+
availableUntil: "11.0.0",
|
75
75
|
replacedBy: [
|
76
76
|
{
|
77
77
|
message:
|
@@ -22,7 +22,7 @@ module.exports = {
|
|
22
22
|
message: "Formatting rules are being moved out of ESLint core.",
|
23
23
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
24
24
|
deprecatedSince: "8.53.0",
|
25
|
-
availableUntil: "
|
25
|
+
availableUntil: "11.0.0",
|
26
26
|
replacedBy: [
|
27
27
|
{
|
28
28
|
message:
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
18
18
|
message: "Formatting rules are being moved out of ESLint core.",
|
19
19
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
20
20
|
deprecatedSince: "9.3.0",
|
21
|
-
availableUntil: "
|
21
|
+
availableUntil: "11.0.0",
|
22
22
|
replacedBy: [
|
23
23
|
{
|
24
24
|
message:
|
@@ -19,7 +19,7 @@ module.exports = {
|
|
19
19
|
message: "Formatting rules are being moved out of ESLint core.",
|
20
20
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
21
21
|
deprecatedSince: "8.53.0",
|
22
|
-
availableUntil: "
|
22
|
+
availableUntil: "11.0.0",
|
23
23
|
replacedBy: [
|
24
24
|
{
|
25
25
|
message:
|
package/lib/rules/new-parens.js
CHANGED
@@ -27,7 +27,7 @@ module.exports = {
|
|
27
27
|
message: "Formatting rules are being moved out of ESLint core.",
|
28
28
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
29
29
|
deprecatedSince: "8.53.0",
|
30
|
-
availableUntil: "
|
30
|
+
availableUntil: "11.0.0",
|
31
31
|
replacedBy: [
|
32
32
|
{
|
33
33
|
message:
|
@@ -42,7 +42,7 @@ module.exports = {
|
|
42
42
|
message: "The rule was replaced with a more general rule.",
|
43
43
|
url: "https://eslint.org/blog/2017/06/eslint-v4.0.0-released/",
|
44
44
|
deprecatedSince: "4.0.0",
|
45
|
-
availableUntil:
|
45
|
+
availableUntil: "11.0.0",
|
46
46
|
replacedBy: [
|
47
47
|
{
|
48
48
|
message: "The new rule moved to a plugin.",
|
@@ -30,7 +30,7 @@ module.exports = {
|
|
30
30
|
message: "The rule was replaced with a more general rule.",
|
31
31
|
url: "https://eslint.org/blog/2017/06/eslint-v4.0.0-released/",
|
32
32
|
deprecatedSince: "4.0.0",
|
33
|
-
availableUntil:
|
33
|
+
availableUntil: "11.0.0",
|
34
34
|
replacedBy: [
|
35
35
|
{
|
36
36
|
message: "The new rule moved to a plugin.",
|
@@ -20,7 +20,7 @@ module.exports = {
|
|
20
20
|
message: "Formatting rules are being moved out of ESLint core.",
|
21
21
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
22
22
|
deprecatedSince: "8.53.0",
|
23
|
-
availableUntil: "
|
23
|
+
availableUntil: "11.0.0",
|
24
24
|
replacedBy: [
|
25
25
|
{
|
26
26
|
message:
|
@@ -33,7 +33,7 @@ module.exports = {
|
|
33
33
|
message: "Formatting rules are being moved out of ESLint core.",
|
34
34
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
35
35
|
deprecatedSince: "8.53.0",
|
36
|
-
availableUntil: "
|
36
|
+
availableUntil: "11.0.0",
|
37
37
|
replacedBy: [
|
38
38
|
{
|
39
39
|
message:
|
@@ -21,7 +21,7 @@ module.exports = {
|
|
21
21
|
message: "Formatting rules are being moved out of ESLint core.",
|
22
22
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
23
23
|
deprecatedSince: "8.53.0",
|
24
|
-
availableUntil: "
|
24
|
+
availableUntil: "11.0.0",
|
25
25
|
replacedBy: [
|
26
26
|
{
|
27
27
|
message:
|
@@ -24,7 +24,7 @@ module.exports = {
|
|
24
24
|
message: "Formatting rules are being moved out of ESLint core.",
|
25
25
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
26
26
|
deprecatedSince: "8.53.0",
|
27
|
-
availableUntil: "
|
27
|
+
availableUntil: "11.0.0",
|
28
28
|
replacedBy: [
|
29
29
|
{
|
30
30
|
message:
|
@@ -23,7 +23,7 @@ module.exports = {
|
|
23
23
|
message: "Formatting rules are being moved out of ESLint core.",
|
24
24
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
25
25
|
deprecatedSince: "8.53.0",
|
26
|
-
availableUntil: "
|
26
|
+
availableUntil: "11.0.0",
|
27
27
|
replacedBy: [
|
28
28
|
{
|
29
29
|
message:
|
@@ -124,14 +124,11 @@ module.exports = {
|
|
124
124
|
* @returns {Object} the object containing the integer's coefficient and order of magnitude
|
125
125
|
*/
|
126
126
|
function normalizeInteger(stringInteger) {
|
127
|
-
const
|
128
|
-
|
129
|
-
);
|
127
|
+
const trimmedInteger = removeLeadingZeros(stringInteger);
|
128
|
+
const significantDigits = removeTrailingZeros(trimmedInteger);
|
130
129
|
|
131
130
|
return {
|
132
|
-
magnitude:
|
133
|
-
? stringInteger.length - 2
|
134
|
-
: stringInteger.length - 1,
|
131
|
+
magnitude: trimmedInteger.length - 1,
|
135
132
|
coefficient: addDecimalPointToNumber(significantDigits),
|
136
133
|
};
|
137
134
|
}
|
@@ -140,7 +137,7 @@ module.exports = {
|
|
140
137
|
*
|
141
138
|
* Converts a float to an object containing the floats's coefficient and order of magnitude
|
142
139
|
* @param {string} stringFloat the string representation of the float being converted
|
143
|
-
* @returns {Object} the object containing the
|
140
|
+
* @returns {Object} the object containing the float's coefficient and order of magnitude
|
144
141
|
*/
|
145
142
|
function normalizeFloat(stringFloat) {
|
146
143
|
const trimmedFloat = removeLeadingZeros(stringFloat);
|
@@ -169,7 +166,7 @@ module.exports = {
|
|
169
166
|
* @returns {string} the number converted to scientific notation
|
170
167
|
*/
|
171
168
|
function convertNumberToScientificNotation(stringNumber) {
|
172
|
-
const splitNumber = stringNumber.
|
169
|
+
const splitNumber = stringNumber.split("e");
|
173
170
|
const originalCoefficient = splitNumber[0];
|
174
171
|
const normalizedNumber = stringNumber.includes(".")
|
175
172
|
? normalizeFloat(originalCoefficient)
|
@@ -90,7 +90,7 @@ module.exports = {
|
|
90
90
|
message: "Formatting rules are being moved out of ESLint core.",
|
91
91
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
92
92
|
deprecatedSince: "8.53.0",
|
93
|
-
availableUntil: "
|
93
|
+
availableUntil: "11.0.0",
|
94
94
|
replacedBy: [
|
95
95
|
{
|
96
96
|
message:
|
@@ -16,7 +16,7 @@ module.exports = {
|
|
16
16
|
message: "Formatting rules are being moved out of ESLint core.",
|
17
17
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
18
18
|
deprecatedSince: "8.53.0",
|
19
|
-
availableUntil: "
|
19
|
+
availableUntil: "11.0.0",
|
20
20
|
replacedBy: [
|
21
21
|
{
|
22
22
|
message:
|
@@ -19,7 +19,7 @@ module.exports = {
|
|
19
19
|
message: "Formatting rules are being moved out of ESLint core.",
|
20
20
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
21
21
|
deprecatedSince: "8.53.0",
|
22
|
-
availableUntil: "
|
22
|
+
availableUntil: "11.0.0",
|
23
23
|
replacedBy: [
|
24
24
|
{
|
25
25
|
message:
|
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
message: "Formatting rules are being moved out of ESLint core.",
|
18
18
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
19
19
|
deprecatedSince: "8.53.0",
|
20
|
-
availableUntil: "
|
20
|
+
availableUntil: "11.0.0",
|
21
21
|
replacedBy: [
|
22
22
|
{
|
23
23
|
message:
|
@@ -41,6 +41,11 @@ const arrayOfStringsOrObjects = {
|
|
41
41
|
type: "string",
|
42
42
|
},
|
43
43
|
},
|
44
|
+
allowTypeImports: {
|
45
|
+
type: "boolean",
|
46
|
+
description:
|
47
|
+
"Whether to allow type-only imports for a path.",
|
48
|
+
},
|
44
49
|
},
|
45
50
|
additionalProperties: false,
|
46
51
|
required: ["name"],
|
@@ -105,6 +110,11 @@ const arrayOfStringsOrObjectPatterns = {
|
|
105
110
|
caseSensitive: {
|
106
111
|
type: "boolean",
|
107
112
|
},
|
113
|
+
allowTypeImports: {
|
114
|
+
type: "boolean",
|
115
|
+
description:
|
116
|
+
"Whether to allow type-only imports for a pattern.",
|
117
|
+
},
|
108
118
|
},
|
109
119
|
additionalProperties: false,
|
110
120
|
not: {
|
@@ -137,6 +147,8 @@ const arrayOfStringsOrObjectPatterns = {
|
|
137
147
|
module.exports = {
|
138
148
|
meta: {
|
139
149
|
type: "suggestion",
|
150
|
+
dialects: ["typescript", "javascript"],
|
151
|
+
language: "javascript",
|
140
152
|
|
141
153
|
docs: {
|
142
154
|
description: "Disallow specified modules when loaded by `import`",
|
@@ -261,6 +273,7 @@ module.exports = {
|
|
261
273
|
message: importSource.message,
|
262
274
|
importNames: importSource.importNames,
|
263
275
|
allowImportNames: importSource.allowImportNames,
|
276
|
+
allowTypeImports: importSource.allowTypeImports,
|
264
277
|
});
|
265
278
|
}
|
266
279
|
return memo;
|
@@ -291,6 +304,7 @@ module.exports = {
|
|
291
304
|
importNamePattern,
|
292
305
|
allowImportNames,
|
293
306
|
allowImportNamePattern,
|
307
|
+
allowTypeImports,
|
294
308
|
}) => ({
|
295
309
|
...(group
|
296
310
|
? {
|
@@ -313,6 +327,7 @@ module.exports = {
|
|
313
327
|
importNamePattern,
|
314
328
|
allowImportNames,
|
315
329
|
allowImportNamePattern,
|
330
|
+
allowTypeImports,
|
316
331
|
}),
|
317
332
|
);
|
318
333
|
|
@@ -324,6 +339,48 @@ module.exports = {
|
|
324
339
|
return {};
|
325
340
|
}
|
326
341
|
|
342
|
+
/**
|
343
|
+
* Check if the node is a type-only import
|
344
|
+
* @param {ASTNode} node The node to check
|
345
|
+
* @returns {boolean} Whether the node is a type-only import
|
346
|
+
*/
|
347
|
+
function isTypeOnlyImport(node) {
|
348
|
+
return (
|
349
|
+
node.importKind === "type" ||
|
350
|
+
(node.specifiers?.length > 0 &&
|
351
|
+
node.specifiers.every(
|
352
|
+
specifier => specifier.importKind === "type",
|
353
|
+
))
|
354
|
+
);
|
355
|
+
}
|
356
|
+
|
357
|
+
/**
|
358
|
+
* Check if a specifier is type-only
|
359
|
+
* @param {ASTNode} specifier The specifier to check
|
360
|
+
* @returns {boolean} Whether the specifier is type-only
|
361
|
+
*/
|
362
|
+
function isTypeOnlySpecifier(specifier) {
|
363
|
+
return (
|
364
|
+
specifier.importKind === "type" ||
|
365
|
+
specifier.exportKind === "type"
|
366
|
+
);
|
367
|
+
}
|
368
|
+
|
369
|
+
/**
|
370
|
+
* Check if the node is a type-only export
|
371
|
+
* @param {ASTNode} node The node to check
|
372
|
+
* @returns {boolean} Whether the node is a type-only export
|
373
|
+
*/
|
374
|
+
function isTypeOnlyExport(node) {
|
375
|
+
return (
|
376
|
+
node.exportKind === "type" ||
|
377
|
+
(node.specifiers?.length > 0 &&
|
378
|
+
node.specifiers.every(
|
379
|
+
specifier => specifier.exportKind === "type",
|
380
|
+
))
|
381
|
+
);
|
382
|
+
}
|
383
|
+
|
327
384
|
/**
|
328
385
|
* Report a restricted path.
|
329
386
|
* @param {string} importSource path of the import
|
@@ -344,6 +401,28 @@ module.exports = {
|
|
344
401
|
restrictedPathEntry.importNames;
|
345
402
|
const allowedImportNames =
|
346
403
|
restrictedPathEntry.allowImportNames;
|
404
|
+
const allowTypeImports =
|
405
|
+
restrictedPathEntry.allowTypeImports;
|
406
|
+
|
407
|
+
// Skip if this is a type-only import and it's allowed for this specific entry
|
408
|
+
if (
|
409
|
+
allowTypeImports &&
|
410
|
+
(node.type === "ImportDeclaration" ||
|
411
|
+
node.type === "TSImportEqualsDeclaration") &&
|
412
|
+
isTypeOnlyImport(node)
|
413
|
+
) {
|
414
|
+
return;
|
415
|
+
}
|
416
|
+
|
417
|
+
// Skip if this is a type-only export and it's allowed for this specific entry
|
418
|
+
if (
|
419
|
+
allowTypeImports &&
|
420
|
+
(node.type === "ExportNamedDeclaration" ||
|
421
|
+
node.type === "ExportAllDeclaration") &&
|
422
|
+
isTypeOnlyExport(node)
|
423
|
+
) {
|
424
|
+
return;
|
425
|
+
}
|
347
426
|
|
348
427
|
if (!restrictedImportNames && !allowedImportNames) {
|
349
428
|
context.report({
|
@@ -400,6 +479,14 @@ module.exports = {
|
|
400
479
|
restrictedImportNames.includes(importName)
|
401
480
|
) {
|
402
481
|
specifiers.forEach(specifier => {
|
482
|
+
// Skip if this is a type-only import specifier and type imports are allowed
|
483
|
+
if (
|
484
|
+
allowTypeImports &&
|
485
|
+
isTypeOnlySpecifier(specifier.specifier)
|
486
|
+
) {
|
487
|
+
return;
|
488
|
+
}
|
489
|
+
|
403
490
|
context.report({
|
404
491
|
node,
|
405
492
|
messageId: customMessage
|
@@ -420,6 +507,14 @@ module.exports = {
|
|
420
507
|
!allowedImportNames.includes(importName)
|
421
508
|
) {
|
422
509
|
specifiers.forEach(specifier => {
|
510
|
+
// Skip if this is a type-only import specifier and type imports are allowed
|
511
|
+
if (
|
512
|
+
allowTypeImports &&
|
513
|
+
isTypeOnlySpecifier(specifier.specifier)
|
514
|
+
) {
|
515
|
+
return;
|
516
|
+
}
|
517
|
+
|
423
518
|
context.report({
|
424
519
|
node,
|
425
520
|
loc: specifier.loc,
|
@@ -446,11 +541,30 @@ module.exports = {
|
|
446
541
|
* @param {Object} group contains an Ignore instance for paths, the customMessage to show on failure,
|
447
542
|
* and any restricted import names that have been specified in the config
|
448
543
|
* @param {Map<string,Object[]>} importNames Map of import names that are being imported
|
544
|
+
* @param {string} importSource the import source string
|
449
545
|
* @returns {void}
|
450
546
|
* @private
|
451
547
|
*/
|
452
|
-
function reportPathForPatterns(node, group, importNames) {
|
453
|
-
|
548
|
+
function reportPathForPatterns(node, group, importNames, importSource) {
|
549
|
+
// Skip if this is a type-only import and it's allowed
|
550
|
+
if (
|
551
|
+
group.allowTypeImports &&
|
552
|
+
(node.type === "ImportDeclaration" ||
|
553
|
+
node.type === "TSImportEqualsDeclaration") &&
|
554
|
+
isTypeOnlyImport(node)
|
555
|
+
) {
|
556
|
+
return;
|
557
|
+
}
|
558
|
+
|
559
|
+
// Skip if this is a type-only export and it's allowed
|
560
|
+
if (
|
561
|
+
group.allowTypeImports &&
|
562
|
+
(node.type === "ExportNamedDeclaration" ||
|
563
|
+
node.type === "ExportAllDeclaration") &&
|
564
|
+
isTypeOnlyExport(node)
|
565
|
+
) {
|
566
|
+
return;
|
567
|
+
}
|
454
568
|
|
455
569
|
const customMessage = group.customMessage;
|
456
570
|
const restrictedImportNames = group.importNames;
|
@@ -553,6 +667,14 @@ module.exports = {
|
|
553
667
|
restrictedImportNamePattern.test(importName))
|
554
668
|
) {
|
555
669
|
specifiers.forEach(specifier => {
|
670
|
+
// Skip if this is a type-only import specifier and type imports are allowed
|
671
|
+
if (
|
672
|
+
group.allowTypeImports &&
|
673
|
+
isTypeOnlySpecifier(specifier.specifier)
|
674
|
+
) {
|
675
|
+
return;
|
676
|
+
}
|
677
|
+
|
556
678
|
context.report({
|
557
679
|
node,
|
558
680
|
messageId: customMessage
|
@@ -573,6 +695,14 @@ module.exports = {
|
|
573
695
|
!allowedImportNames.includes(importName)
|
574
696
|
) {
|
575
697
|
specifiers.forEach(specifier => {
|
698
|
+
// Skip if this is a type-only import specifier and type imports are allowed
|
699
|
+
if (
|
700
|
+
group.allowTypeImports &&
|
701
|
+
isTypeOnlySpecifier(specifier.specifier)
|
702
|
+
) {
|
703
|
+
return;
|
704
|
+
}
|
705
|
+
|
576
706
|
context.report({
|
577
707
|
node,
|
578
708
|
messageId: customMessage
|
@@ -592,6 +722,14 @@ module.exports = {
|
|
592
722
|
!allowedImportNamePattern.test(importName)
|
593
723
|
) {
|
594
724
|
specifiers.forEach(specifier => {
|
725
|
+
// Skip if this is a type-only import specifier and type imports are allowed
|
726
|
+
if (
|
727
|
+
group.allowTypeImports &&
|
728
|
+
isTypeOnlySpecifier(specifier.specifier)
|
729
|
+
) {
|
730
|
+
return;
|
731
|
+
}
|
732
|
+
|
595
733
|
context.report({
|
596
734
|
node,
|
597
735
|
messageId: customMessage
|
@@ -640,7 +778,7 @@ module.exports = {
|
|
640
778
|
} else if (node.specifiers) {
|
641
779
|
for (const specifier of node.specifiers) {
|
642
780
|
let name;
|
643
|
-
const specifierData = { loc: specifier.loc };
|
781
|
+
const specifierData = { loc: specifier.loc, specifier };
|
644
782
|
|
645
783
|
if (specifier.type === "ImportDefaultSpecifier") {
|
646
784
|
name = "default";
|
@@ -665,7 +803,12 @@ module.exports = {
|
|
665
803
|
checkRestrictedPathAndReport(importSource, importNames, node);
|
666
804
|
restrictedPatternGroups.forEach(group => {
|
667
805
|
if (isRestrictedPattern(importSource, group)) {
|
668
|
-
reportPathForPatterns(
|
806
|
+
reportPathForPatterns(
|
807
|
+
node,
|
808
|
+
group,
|
809
|
+
importNames,
|
810
|
+
importSource,
|
811
|
+
);
|
669
812
|
}
|
670
813
|
});
|
671
814
|
}
|
@@ -678,6 +821,30 @@ module.exports = {
|
|
678
821
|
}
|
679
822
|
},
|
680
823
|
ExportAllDeclaration: checkNode,
|
824
|
+
// Add support for TypeScript import equals declarations
|
825
|
+
TSImportEqualsDeclaration(node) {
|
826
|
+
if (node.moduleReference.type === "TSExternalModuleReference") {
|
827
|
+
const importSource = node.moduleReference.expression.value;
|
828
|
+
const importNames = new Map();
|
829
|
+
|
830
|
+
// Use existing logic with the actual node
|
831
|
+
checkRestrictedPathAndReport(
|
832
|
+
importSource,
|
833
|
+
importNames,
|
834
|
+
node,
|
835
|
+
);
|
836
|
+
restrictedPatternGroups.forEach(group => {
|
837
|
+
if (isRestrictedPattern(importSource, group)) {
|
838
|
+
reportPathForPatterns(
|
839
|
+
node,
|
840
|
+
group,
|
841
|
+
importNames,
|
842
|
+
importSource,
|
843
|
+
);
|
844
|
+
}
|
845
|
+
});
|
846
|
+
}
|
847
|
+
},
|
681
848
|
};
|
682
849
|
},
|
683
850
|
};
|
@@ -26,7 +26,7 @@ module.exports = {
|
|
26
26
|
message: "Formatting rules are being moved out of ESLint core.",
|
27
27
|
url: "https://eslint.org/blog/2016/08/eslint-v3.3.0-released/#deprecated-rules",
|
28
28
|
deprecatedSince: "3.3.0",
|
29
|
-
availableUntil: "
|
29
|
+
availableUntil: "11.0.0",
|
30
30
|
replacedBy: [
|
31
31
|
{
|
32
32
|
message:
|
package/lib/rules/no-tabs.js
CHANGED
@@ -24,7 +24,7 @@ module.exports = {
|
|
24
24
|
message: "Formatting rules are being moved out of ESLint core.",
|
25
25
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
26
26
|
deprecatedSince: "8.53.0",
|
27
|
-
availableUntil: "
|
27
|
+
availableUntil: "11.0.0",
|
28
28
|
replacedBy: [
|
29
29
|
{
|
30
30
|
message:
|
@@ -30,7 +30,7 @@ module.exports = {
|
|
30
30
|
message: "Formatting rules are being moved out of ESLint core.",
|
31
31
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
32
32
|
deprecatedSince: "8.53.0",
|
33
|
-
availableUntil: "
|
33
|
+
availableUntil: "11.0.0",
|
34
34
|
replacedBy: [
|
35
35
|
{
|
36
36
|
message:
|
@@ -22,7 +22,7 @@ module.exports = {
|
|
22
22
|
message: "Formatting rules are being moved out of ESLint core.",
|
23
23
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
24
24
|
deprecatedSince: "8.53.0",
|
25
|
-
availableUntil: "
|
25
|
+
availableUntil: "11.0.0",
|
26
26
|
replacedBy: [
|
27
27
|
{
|
28
28
|
message:
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
18
18
|
message: "Formatting rules are being moved out of ESLint core.",
|
19
19
|
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
20
20
|
deprecatedSince: "8.53.0",
|
21
|
-
availableUntil: "
|
21
|
+
availableUntil: "11.0.0",
|
22
22
|
replacedBy: [
|
23
23
|
{
|
24
24
|
message:
|