eslint 9.28.0 → 9.30.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/conf/ecma-version.js +1 -1
- package/conf/globals.js +10 -0
- package/lib/cli.js +6 -11
- package/lib/config/config-loader.js +2 -29
- package/lib/config/flat-config-array.js +1 -1
- package/lib/eslint/eslint.js +14 -18
- package/lib/languages/js/source-code/source-code.js +81 -27
- package/lib/linter/apply-disable-directives.js +2 -4
- package/lib/linter/code-path-analysis/code-path-analyzer.js +8 -9
- package/lib/linter/linter.js +4 -4
- package/lib/linter/source-code-traverser.js +64 -49
- package/lib/linter/source-code-visitor.js +81 -0
- package/lib/rules/array-bracket-newline.js +3 -3
- package/lib/rules/array-bracket-spacing.js +3 -3
- package/lib/rules/array-element-newline.js +3 -3
- package/lib/rules/arrow-parens.js +3 -3
- package/lib/rules/arrow-spacing.js +3 -3
- package/lib/rules/block-spacing.js +3 -3
- package/lib/rules/brace-style.js +3 -3
- package/lib/rules/class-methods-use-this.js +7 -0
- package/lib/rules/comma-dangle.js +3 -3
- package/lib/rules/comma-spacing.js +3 -3
- package/lib/rules/comma-style.js +3 -3
- package/lib/rules/computed-property-spacing.js +3 -3
- package/lib/rules/dot-location.js +3 -3
- package/lib/rules/eol-last.js +3 -3
- package/lib/rules/func-call-spacing.js +3 -3
- package/lib/rules/function-call-argument-newline.js +3 -3
- package/lib/rules/function-paren-newline.js +3 -3
- package/lib/rules/generator-star-spacing.js +3 -3
- package/lib/rules/implicit-arrow-linebreak.js +3 -3
- package/lib/rules/indent-legacy.js +3 -3
- package/lib/rules/indent.js +3 -3
- package/lib/rules/jsx-quotes.js +3 -3
- package/lib/rules/key-spacing.js +3 -3
- package/lib/rules/keyword-spacing.js +3 -3
- package/lib/rules/line-comment-position.js +3 -3
- package/lib/rules/linebreak-style.js +3 -3
- package/lib/rules/lines-around-comment.js +3 -3
- package/lib/rules/lines-around-directive.js +3 -3
- package/lib/rules/lines-between-class-members.js +3 -3
- package/lib/rules/max-len.js +3 -3
- package/lib/rules/max-statements-per-line.js +3 -3
- package/lib/rules/multiline-comment-style.js +3 -3
- package/lib/rules/multiline-ternary.js +3 -3
- package/lib/rules/new-parens.js +3 -3
- package/lib/rules/newline-after-var.js +3 -3
- package/lib/rules/newline-before-return.js +3 -3
- package/lib/rules/newline-per-chained-call.js +3 -3
- package/lib/rules/no-confusing-arrow.js +3 -3
- package/lib/rules/no-duplicate-imports.js +65 -7
- package/lib/rules/no-extra-parens.js +3 -3
- package/lib/rules/no-extra-semi.js +3 -3
- package/lib/rules/no-floating-decimal.js +3 -3
- package/lib/rules/no-mixed-operators.js +3 -3
- package/lib/rules/no-mixed-spaces-and-tabs.js +3 -3
- package/lib/rules/no-multi-spaces.js +3 -3
- package/lib/rules/no-multiple-empty-lines.js +3 -3
- package/lib/rules/no-promise-executor-return.js +4 -35
- package/lib/rules/no-restricted-globals.js +35 -2
- package/lib/rules/no-restricted-properties.js +35 -12
- package/lib/rules/no-setter-return.js +13 -48
- package/lib/rules/no-spaced-func.js +3 -3
- package/lib/rules/no-tabs.js +3 -3
- package/lib/rules/no-trailing-spaces.js +3 -3
- package/lib/rules/no-unused-vars.js +1 -1
- package/lib/rules/no-use-before-define.js +2 -0
- package/lib/rules/no-var.js +14 -2
- package/lib/rules/no-whitespace-before-property.js +3 -3
- package/lib/rules/nonblock-statement-body-position.js +3 -3
- package/lib/rules/object-curly-newline.js +3 -3
- package/lib/rules/object-curly-spacing.js +3 -3
- package/lib/rules/object-property-newline.js +3 -3
- package/lib/rules/one-var-declaration-per-line.js +3 -3
- package/lib/rules/operator-linebreak.js +3 -3
- package/lib/rules/padded-blocks.js +3 -3
- package/lib/rules/padding-line-between-statements.js +3 -3
- package/lib/rules/prefer-regex-literals.js +1 -18
- package/lib/rules/quote-props.js +3 -3
- package/lib/rules/quotes.js +3 -3
- package/lib/rules/rest-spread-spacing.js +3 -3
- package/lib/rules/semi-spacing.js +3 -3
- package/lib/rules/semi-style.js +3 -3
- package/lib/rules/semi.js +3 -3
- package/lib/rules/space-before-blocks.js +3 -3
- package/lib/rules/space-before-function-paren.js +3 -3
- package/lib/rules/space-in-parens.js +3 -3
- package/lib/rules/space-infix-ops.js +3 -3
- package/lib/rules/space-unary-ops.js +3 -3
- package/lib/rules/spaced-comment.js +3 -3
- package/lib/rules/switch-colon-spacing.js +3 -3
- package/lib/rules/template-curly-spacing.js +3 -3
- package/lib/rules/template-tag-spacing.js +3 -3
- package/lib/rules/utils/ast-utils.js +45 -0
- package/lib/rules/wrap-iife.js +3 -3
- package/lib/rules/wrap-regex.js +3 -3
- package/lib/rules/yield-star-spacing.js +3 -3
- package/lib/services/suppressions-service.js +8 -0
- package/lib/shared/flags.js +9 -1
- package/lib/shared/naming.js +109 -0
- package/lib/shared/relative-module-resolver.js +28 -0
- package/lib/shared/runtime-info.js +1 -1
- package/lib/types/index.d.ts +15 -2
- package/lib/types/rules.d.ts +83 -74
- package/package.json +8 -8
- package/lib/linter/safe-emitter.js +0 -52
@@ -4,6 +4,18 @@
|
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
6
|
|
7
|
+
//------------------------------------------------------------------------------
|
8
|
+
// Helpers
|
9
|
+
//------------------------------------------------------------------------------
|
10
|
+
|
11
|
+
const TYPE_NODES = new Set([
|
12
|
+
"TSTypeReference",
|
13
|
+
"TSInterfaceHeritage",
|
14
|
+
"TSClassImplements",
|
15
|
+
"TSTypeQuery",
|
16
|
+
"TSQualifiedName",
|
17
|
+
]);
|
18
|
+
|
7
19
|
//------------------------------------------------------------------------------
|
8
20
|
// Rule Definition
|
9
21
|
//------------------------------------------------------------------------------
|
@@ -11,6 +23,8 @@
|
|
11
23
|
/** @type {import('../types').Rule.RuleModule} */
|
12
24
|
module.exports = {
|
13
25
|
meta: {
|
26
|
+
dialects: ["javascript", "typescript"],
|
27
|
+
language: "javascript",
|
14
28
|
type: "suggestion",
|
15
29
|
|
16
30
|
docs: {
|
@@ -100,6 +114,18 @@ module.exports = {
|
|
100
114
|
return Object.hasOwn(restrictedGlobalMessages, name);
|
101
115
|
}
|
102
116
|
|
117
|
+
/**
|
118
|
+
* Check if the given reference occurs within a TypeScript type context.
|
119
|
+
* @param {Reference} reference The variable reference to check.
|
120
|
+
* @returns {boolean} Whether the reference is in a type context.
|
121
|
+
* @private
|
122
|
+
*/
|
123
|
+
function isInTypeContext(reference) {
|
124
|
+
const parent = reference.identifier.parent;
|
125
|
+
|
126
|
+
return TYPE_NODES.has(parent.type);
|
127
|
+
}
|
128
|
+
|
103
129
|
return {
|
104
130
|
Program(node) {
|
105
131
|
const scope = sourceCode.getScope(node);
|
@@ -107,13 +133,20 @@ module.exports = {
|
|
107
133
|
// Report variables declared elsewhere (ex: variables defined as "global" by eslint)
|
108
134
|
scope.variables.forEach(variable => {
|
109
135
|
if (!variable.defs.length && isRestricted(variable.name)) {
|
110
|
-
variable.references.forEach(
|
136
|
+
variable.references.forEach(reference => {
|
137
|
+
if (!isInTypeContext(reference)) {
|
138
|
+
reportReference(reference);
|
139
|
+
}
|
140
|
+
});
|
111
141
|
}
|
112
142
|
});
|
113
143
|
|
114
144
|
// Report variables not declared at all
|
115
145
|
scope.through.forEach(reference => {
|
116
|
-
if (
|
146
|
+
if (
|
147
|
+
isRestricted(reference.identifier.name) &&
|
148
|
+
!isInTypeContext(reference)
|
149
|
+
) {
|
117
150
|
reportReference(reference);
|
118
151
|
}
|
119
152
|
});
|
@@ -40,6 +40,13 @@ module.exports = {
|
|
40
40
|
},
|
41
41
|
uniqueItems: true,
|
42
42
|
},
|
43
|
+
allowProperties: {
|
44
|
+
type: "array",
|
45
|
+
items: {
|
46
|
+
type: "string",
|
47
|
+
},
|
48
|
+
uniqueItems: true,
|
49
|
+
},
|
43
50
|
message: {
|
44
51
|
type: "string",
|
45
52
|
},
|
@@ -53,7 +60,10 @@ module.exports = {
|
|
53
60
|
},
|
54
61
|
],
|
55
62
|
not: {
|
56
|
-
|
63
|
+
anyOf: [
|
64
|
+
{ required: ["allowObjects", "object"] },
|
65
|
+
{ required: ["allowProperties", "property"] },
|
66
|
+
],
|
57
67
|
},
|
58
68
|
additionalProperties: false,
|
59
69
|
},
|
@@ -63,10 +73,10 @@ module.exports = {
|
|
63
73
|
messages: {
|
64
74
|
restrictedObjectProperty:
|
65
75
|
// eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
|
66
|
-
"'{{objectName}}.{{propertyName}}' is restricted from being used.{{message}}",
|
76
|
+
"'{{objectName}}.{{propertyName}}' is restricted from being used.{{allowedPropertiesMessage}}{{message}}",
|
67
77
|
restrictedProperty:
|
68
78
|
// eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
|
69
|
-
"'{{propertyName}}' is restricted from being used.{{message}}",
|
79
|
+
"'{{propertyName}}' is restricted from being used.{{allowedObjectsMessage}}{{message}}",
|
70
80
|
},
|
71
81
|
},
|
72
82
|
|
@@ -92,6 +102,7 @@ module.exports = {
|
|
92
102
|
});
|
93
103
|
} else if (typeof propertyName === "undefined") {
|
94
104
|
globallyRestrictedObjects.set(objectName, {
|
105
|
+
allowProperties: option.allowProperties,
|
95
106
|
message: option.message,
|
96
107
|
});
|
97
108
|
} else {
|
@@ -106,17 +117,17 @@ module.exports = {
|
|
106
117
|
});
|
107
118
|
|
108
119
|
/**
|
109
|
-
* Checks if
|
110
|
-
* @param {string}
|
111
|
-
* @param {string[]} [
|
112
|
-
* @returns {boolean} True if the
|
120
|
+
* Checks if a name is in the allowed list.
|
121
|
+
* @param {string} name The name to check
|
122
|
+
* @param {string[]} [allowedList] The list of allowed names
|
123
|
+
* @returns {boolean} True if the name is allowed, false otherwise
|
113
124
|
*/
|
114
|
-
function
|
115
|
-
if (!
|
125
|
+
function isAllowed(name, allowedList) {
|
126
|
+
if (!allowedList) {
|
116
127
|
return false;
|
117
128
|
}
|
118
129
|
|
119
|
-
return
|
130
|
+
return allowedList.includes(name);
|
120
131
|
}
|
121
132
|
|
122
133
|
/**
|
@@ -137,10 +148,17 @@ module.exports = {
|
|
137
148
|
const globalMatchedProperty =
|
138
149
|
globallyRestrictedProperties.get(propertyName);
|
139
150
|
|
140
|
-
if (
|
151
|
+
if (
|
152
|
+
matchedObjectProperty &&
|
153
|
+
!isAllowed(propertyName, matchedObjectProperty.allowProperties)
|
154
|
+
) {
|
141
155
|
const message = matchedObjectProperty.message
|
142
156
|
? ` ${matchedObjectProperty.message}`
|
143
157
|
: "";
|
158
|
+
const allowedPropertiesMessage =
|
159
|
+
matchedObjectProperty.allowProperties
|
160
|
+
? ` Only these properties are allowed: ${matchedObjectProperty.allowProperties.join(", ")}.`
|
161
|
+
: "";
|
144
162
|
|
145
163
|
context.report({
|
146
164
|
node,
|
@@ -149,15 +167,19 @@ module.exports = {
|
|
149
167
|
objectName,
|
150
168
|
propertyName,
|
151
169
|
message,
|
170
|
+
allowedPropertiesMessage,
|
152
171
|
},
|
153
172
|
});
|
154
173
|
} else if (
|
155
174
|
globalMatchedProperty &&
|
156
|
-
!
|
175
|
+
!isAllowed(objectName, globalMatchedProperty.allowObjects)
|
157
176
|
) {
|
158
177
|
const message = globalMatchedProperty.message
|
159
178
|
? ` ${globalMatchedProperty.message}`
|
160
179
|
: "";
|
180
|
+
const allowedObjectsMessage = globalMatchedProperty.allowObjects
|
181
|
+
? ` Property '${propertyName}' is only allowed on these objects: ${globalMatchedProperty.allowObjects.join(", ")}.`
|
182
|
+
: "";
|
161
183
|
|
162
184
|
context.report({
|
163
185
|
node,
|
@@ -165,6 +187,7 @@ module.exports = {
|
|
165
187
|
data: {
|
166
188
|
propertyName,
|
167
189
|
message,
|
190
|
+
allowedObjectsMessage,
|
168
191
|
},
|
169
192
|
});
|
170
193
|
}
|
@@ -10,33 +10,16 @@
|
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
12
|
const astUtils = require("./utils/ast-utils");
|
13
|
-
const { findVariable } = require("@eslint-community/eslint-utils");
|
14
13
|
|
15
14
|
//------------------------------------------------------------------------------
|
16
15
|
// Helpers
|
17
16
|
//------------------------------------------------------------------------------
|
18
17
|
|
19
|
-
/**
|
20
|
-
* Determines whether the given identifier node is a reference to a global variable.
|
21
|
-
* @param {ASTNode} node `Identifier` node to check.
|
22
|
-
* @param {Scope} scope Scope to which the node belongs.
|
23
|
-
* @returns {boolean} True if the identifier is a reference to a global variable.
|
24
|
-
*/
|
25
|
-
function isGlobalReference(node, scope) {
|
26
|
-
const variable = findVariable(scope, node);
|
27
|
-
|
28
|
-
return (
|
29
|
-
variable !== null &&
|
30
|
-
variable.scope.type === "global" &&
|
31
|
-
variable.defs.length === 0
|
32
|
-
);
|
33
|
-
}
|
34
|
-
|
35
18
|
/**
|
36
19
|
* Determines whether the given node is an argument of the specified global method call, at the given `index` position.
|
37
20
|
* E.g., for given `index === 1`, this function checks for `objectName.methodName(foo, node)`, where objectName is a global variable.
|
38
21
|
* @param {ASTNode} node The node to check.
|
39
|
-
* @param {
|
22
|
+
* @param {SourceCode} sourceCode Source code to which the node belongs.
|
40
23
|
* @param {string} objectName Name of the global object.
|
41
24
|
* @param {string} methodName Name of the method.
|
42
25
|
* @param {number} index The given position.
|
@@ -44,7 +27,7 @@ function isGlobalReference(node, scope) {
|
|
44
27
|
*/
|
45
28
|
function isArgumentOfGlobalMethodCall(
|
46
29
|
node,
|
47
|
-
|
30
|
+
sourceCode,
|
48
31
|
objectName,
|
49
32
|
methodName,
|
50
33
|
index,
|
@@ -59,9 +42,8 @@ function isArgumentOfGlobalMethodCall(
|
|
59
42
|
objectName,
|
60
43
|
methodName,
|
61
44
|
) &&
|
62
|
-
isGlobalReference(
|
45
|
+
sourceCode.isGlobalReference(
|
63
46
|
astUtils.skipChainExpression(callNode.callee).object,
|
64
|
-
scope,
|
65
47
|
)
|
66
48
|
);
|
67
49
|
}
|
@@ -69,21 +51,21 @@ function isArgumentOfGlobalMethodCall(
|
|
69
51
|
/**
|
70
52
|
* Determines whether the given node is used as a property descriptor.
|
71
53
|
* @param {ASTNode} node The node to check.
|
72
|
-
* @param {
|
54
|
+
* @param {SourceCode} sourceCode Source code to which the node belongs.
|
73
55
|
* @returns {boolean} `true` if the node is a property descriptor.
|
74
56
|
*/
|
75
|
-
function isPropertyDescriptor(node,
|
57
|
+
function isPropertyDescriptor(node, sourceCode) {
|
76
58
|
if (
|
77
59
|
isArgumentOfGlobalMethodCall(
|
78
60
|
node,
|
79
|
-
|
61
|
+
sourceCode,
|
80
62
|
"Object",
|
81
63
|
"defineProperty",
|
82
64
|
2,
|
83
65
|
) ||
|
84
66
|
isArgumentOfGlobalMethodCall(
|
85
67
|
node,
|
86
|
-
|
68
|
+
sourceCode,
|
87
69
|
"Reflect",
|
88
70
|
"defineProperty",
|
89
71
|
2,
|
@@ -101,14 +83,14 @@ function isPropertyDescriptor(node, scope) {
|
|
101
83
|
grandparent.type === "ObjectExpression" &&
|
102
84
|
(isArgumentOfGlobalMethodCall(
|
103
85
|
grandparent,
|
104
|
-
|
86
|
+
sourceCode,
|
105
87
|
"Object",
|
106
88
|
"create",
|
107
89
|
1,
|
108
90
|
) ||
|
109
91
|
isArgumentOfGlobalMethodCall(
|
110
92
|
grandparent,
|
111
|
-
|
93
|
+
sourceCode,
|
112
94
|
"Object",
|
113
95
|
"defineProperties",
|
114
96
|
1,
|
@@ -124,10 +106,10 @@ function isPropertyDescriptor(node, scope) {
|
|
124
106
|
/**
|
125
107
|
* Determines whether the given function node is used as a setter function.
|
126
108
|
* @param {ASTNode} node The node to check.
|
127
|
-
* @param {
|
109
|
+
* @param {SourceCode} sourceCode Source code to which the node belongs.
|
128
110
|
* @returns {boolean} `true` if the node is a setter.
|
129
111
|
*/
|
130
|
-
function isSetter(node,
|
112
|
+
function isSetter(node, sourceCode) {
|
131
113
|
const parent = node.parent;
|
132
114
|
|
133
115
|
if (
|
@@ -144,7 +126,7 @@ function isSetter(node, scope) {
|
|
144
126
|
parent.value === node &&
|
145
127
|
astUtils.getStaticPropertyName(parent) === "set" &&
|
146
128
|
parent.parent.type === "ObjectExpression" &&
|
147
|
-
isPropertyDescriptor(parent.parent,
|
129
|
+
isPropertyDescriptor(parent.parent, sourceCode)
|
148
130
|
) {
|
149
131
|
// Setter in a property descriptor
|
150
132
|
return true;
|
@@ -153,21 +135,6 @@ function isSetter(node, scope) {
|
|
153
135
|
return false;
|
154
136
|
}
|
155
137
|
|
156
|
-
/**
|
157
|
-
* Finds function's outer scope.
|
158
|
-
* @param {Scope} scope Function's own scope.
|
159
|
-
* @returns {Scope} Function's outer scope.
|
160
|
-
*/
|
161
|
-
function getOuterScope(scope) {
|
162
|
-
const upper = scope.upper;
|
163
|
-
|
164
|
-
if (upper.type === "function-expression-name") {
|
165
|
-
return upper.upper;
|
166
|
-
}
|
167
|
-
|
168
|
-
return upper;
|
169
|
-
}
|
170
|
-
|
171
138
|
//------------------------------------------------------------------------------
|
172
139
|
// Rule Definition
|
173
140
|
//------------------------------------------------------------------------------
|
@@ -200,11 +167,9 @@ module.exports = {
|
|
200
167
|
* @returns {void}
|
201
168
|
*/
|
202
169
|
function enterFunction(node) {
|
203
|
-
const outerScope = getOuterScope(sourceCode.getScope(node));
|
204
|
-
|
205
170
|
funcInfo = {
|
206
171
|
upper: funcInfo,
|
207
|
-
isSetter: isSetter(node,
|
172
|
+
isSetter: isSetter(node, sourceCode),
|
208
173
|
};
|
209
174
|
}
|
210
175
|
|
@@ -33,12 +33,12 @@ module.exports = {
|
|
33
33
|
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
34
34
|
url: "https://eslint.style/guide/migration",
|
35
35
|
plugin: {
|
36
|
-
name: "@stylistic/eslint-plugin
|
37
|
-
url: "https://eslint.style
|
36
|
+
name: "@stylistic/eslint-plugin",
|
37
|
+
url: "https://eslint.style",
|
38
38
|
},
|
39
39
|
rule: {
|
40
40
|
name: "function-call-spacing",
|
41
|
-
url: "https://eslint.style/rules/
|
41
|
+
url: "https://eslint.style/rules/function-call-spacing",
|
42
42
|
},
|
43
43
|
},
|
44
44
|
],
|
package/lib/rules/no-tabs.js
CHANGED
@@ -31,12 +31,12 @@ module.exports = {
|
|
31
31
|
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
32
32
|
url: "https://eslint.style/guide/migration",
|
33
33
|
plugin: {
|
34
|
-
name: "@stylistic/eslint-plugin
|
35
|
-
url: "https://eslint.style
|
34
|
+
name: "@stylistic/eslint-plugin",
|
35
|
+
url: "https://eslint.style",
|
36
36
|
},
|
37
37
|
rule: {
|
38
38
|
name: "no-tabs",
|
39
|
-
url: "https://eslint.style/rules/
|
39
|
+
url: "https://eslint.style/rules/no-tabs",
|
40
40
|
},
|
41
41
|
},
|
42
42
|
],
|
@@ -37,12 +37,12 @@ module.exports = {
|
|
37
37
|
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
38
38
|
url: "https://eslint.style/guide/migration",
|
39
39
|
plugin: {
|
40
|
-
name: "@stylistic/eslint-plugin
|
41
|
-
url: "https://eslint.style
|
40
|
+
name: "@stylistic/eslint-plugin",
|
41
|
+
url: "https://eslint.style",
|
42
42
|
},
|
43
43
|
rule: {
|
44
44
|
name: "no-trailing-spaces",
|
45
|
-
url: "https://eslint.style/rules/
|
45
|
+
url: "https://eslint.style/rules/no-trailing-spaces",
|
46
46
|
},
|
47
47
|
},
|
48
48
|
],
|
@@ -1152,7 +1152,7 @@ module.exports = {
|
|
1152
1152
|
|
1153
1153
|
// fix for { a: { b } }
|
1154
1154
|
if (parentNode.parent.type === "ObjectPattern") {
|
1155
|
-
// fix for unused variables in
|
1155
|
+
// fix for unused variables in destructured object with single property in variable declaration and function parameter
|
1156
1156
|
if (parentNode.parent.properties.length === 1) {
|
1157
1157
|
return fixVariables(parentNode.parent);
|
1158
1158
|
}
|
@@ -269,6 +269,8 @@ function isClassRefInClassDecorator(variable, reference) {
|
|
269
269
|
/** @type {import('../types').Rule.RuleModule} */
|
270
270
|
module.exports = {
|
271
271
|
meta: {
|
272
|
+
dialects: ["javascript", "typescript"],
|
273
|
+
language: "javascript",
|
272
274
|
type: "problem",
|
273
275
|
|
274
276
|
docs: {
|
package/lib/rules/no-var.js
CHANGED
@@ -199,6 +199,8 @@ function hasNameDisallowedForLetDeclarations(variable) {
|
|
199
199
|
module.exports = {
|
200
200
|
meta: {
|
201
201
|
type: "suggestion",
|
202
|
+
dialects: ["typescript", "javascript"],
|
203
|
+
language: "javascript",
|
202
204
|
|
203
205
|
docs: {
|
204
206
|
description: "Require `let` or `const` instead of `var`",
|
@@ -346,9 +348,19 @@ module.exports = {
|
|
346
348
|
|
347
349
|
return {
|
348
350
|
"VariableDeclaration:exit"(node) {
|
349
|
-
if (node.kind
|
350
|
-
|
351
|
+
if (node.kind !== "var") {
|
352
|
+
return;
|
351
353
|
}
|
354
|
+
|
355
|
+
if (
|
356
|
+
node.parent.type === "TSModuleBlock" &&
|
357
|
+
node.parent.parent.type === "TSModuleDeclaration" &&
|
358
|
+
node.parent.parent.global
|
359
|
+
) {
|
360
|
+
return;
|
361
|
+
}
|
362
|
+
|
363
|
+
report(node);
|
352
364
|
},
|
353
365
|
};
|
354
366
|
},
|
@@ -29,12 +29,12 @@ module.exports = {
|
|
29
29
|
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
30
30
|
url: "https://eslint.style/guide/migration",
|
31
31
|
plugin: {
|
32
|
-
name: "@stylistic/eslint-plugin
|
33
|
-
url: "https://eslint.style
|
32
|
+
name: "@stylistic/eslint-plugin",
|
33
|
+
url: "https://eslint.style",
|
34
34
|
},
|
35
35
|
rule: {
|
36
36
|
name: "no-whitespace-before-property",
|
37
|
-
url: "https://eslint.style/rules/
|
37
|
+
url: "https://eslint.style/rules/no-whitespace-before-property",
|
38
38
|
},
|
39
39
|
},
|
40
40
|
],
|
@@ -25,12 +25,12 @@ module.exports = {
|
|
25
25
|
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
26
26
|
url: "https://eslint.style/guide/migration",
|
27
27
|
plugin: {
|
28
|
-
name: "@stylistic/eslint-plugin
|
29
|
-
url: "https://eslint.style
|
28
|
+
name: "@stylistic/eslint-plugin",
|
29
|
+
url: "https://eslint.style",
|
30
30
|
},
|
31
31
|
rule: {
|
32
32
|
name: "nonblock-statement-body-position",
|
33
|
-
url: "https://eslint.style/rules/
|
33
|
+
url: "https://eslint.style/rules/nonblock-statement-body-position",
|
34
34
|
},
|
35
35
|
},
|
36
36
|
],
|
@@ -169,12 +169,12 @@ module.exports = {
|
|
169
169
|
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
170
170
|
url: "https://eslint.style/guide/migration",
|
171
171
|
plugin: {
|
172
|
-
name: "@stylistic/eslint-plugin
|
173
|
-
url: "https://eslint.style
|
172
|
+
name: "@stylistic/eslint-plugin",
|
173
|
+
url: "https://eslint.style",
|
174
174
|
},
|
175
175
|
rule: {
|
176
176
|
name: "object-curly-newline",
|
177
|
-
url: "https://eslint.style/rules/
|
177
|
+
url: "https://eslint.style/rules/object-curly-newline",
|
178
178
|
},
|
179
179
|
},
|
180
180
|
],
|
@@ -25,12 +25,12 @@ module.exports = {
|
|
25
25
|
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
26
26
|
url: "https://eslint.style/guide/migration",
|
27
27
|
plugin: {
|
28
|
-
name: "@stylistic/eslint-plugin
|
29
|
-
url: "https://eslint.style
|
28
|
+
name: "@stylistic/eslint-plugin",
|
29
|
+
url: "https://eslint.style",
|
30
30
|
},
|
31
31
|
rule: {
|
32
32
|
name: "object-curly-spacing",
|
33
|
-
url: "https://eslint.style/rules/
|
33
|
+
url: "https://eslint.style/rules/object-curly-spacing",
|
34
34
|
},
|
35
35
|
},
|
36
36
|
],
|
@@ -24,12 +24,12 @@ module.exports = {
|
|
24
24
|
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
25
25
|
url: "https://eslint.style/guide/migration",
|
26
26
|
plugin: {
|
27
|
-
name: "@stylistic/eslint-plugin
|
28
|
-
url: "https://eslint.style
|
27
|
+
name: "@stylistic/eslint-plugin",
|
28
|
+
url: "https://eslint.style",
|
29
29
|
},
|
30
30
|
rule: {
|
31
31
|
name: "object-property-newline",
|
32
|
-
url: "https://eslint.style/rules/
|
32
|
+
url: "https://eslint.style/rules/object-property-newline",
|
33
33
|
},
|
34
34
|
},
|
35
35
|
],
|
@@ -23,12 +23,12 @@ module.exports = {
|
|
23
23
|
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
24
24
|
url: "https://eslint.style/guide/migration",
|
25
25
|
plugin: {
|
26
|
-
name: "@stylistic/eslint-plugin
|
27
|
-
url: "https://eslint.style
|
26
|
+
name: "@stylistic/eslint-plugin",
|
27
|
+
url: "https://eslint.style",
|
28
28
|
},
|
29
29
|
rule: {
|
30
30
|
name: "one-var-declaration-per-line",
|
31
|
-
url: "https://eslint.style/rules/
|
31
|
+
url: "https://eslint.style/rules/one-var-declaration-per-line",
|
32
32
|
},
|
33
33
|
},
|
34
34
|
],
|
@@ -30,12 +30,12 @@ module.exports = {
|
|
30
30
|
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
31
31
|
url: "https://eslint.style/guide/migration",
|
32
32
|
plugin: {
|
33
|
-
name: "@stylistic/eslint-plugin
|
34
|
-
url: "https://eslint.style
|
33
|
+
name: "@stylistic/eslint-plugin",
|
34
|
+
url: "https://eslint.style",
|
35
35
|
},
|
36
36
|
rule: {
|
37
37
|
name: "operator-linebreak",
|
38
|
-
url: "https://eslint.style/rules/
|
38
|
+
url: "https://eslint.style/rules/operator-linebreak",
|
39
39
|
},
|
40
40
|
},
|
41
41
|
],
|
@@ -30,12 +30,12 @@ module.exports = {
|
|
30
30
|
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
31
31
|
url: "https://eslint.style/guide/migration",
|
32
32
|
plugin: {
|
33
|
-
name: "@stylistic/eslint-plugin
|
34
|
-
url: "https://eslint.style
|
33
|
+
name: "@stylistic/eslint-plugin",
|
34
|
+
url: "https://eslint.style",
|
35
35
|
},
|
36
36
|
rule: {
|
37
37
|
name: "padded-blocks",
|
38
|
-
url: "https://eslint.style/rules/
|
38
|
+
url: "https://eslint.style/rules/padded-blocks",
|
39
39
|
},
|
40
40
|
},
|
41
41
|
],
|
@@ -400,12 +400,12 @@ module.exports = {
|
|
400
400
|
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
401
401
|
url: "https://eslint.style/guide/migration",
|
402
402
|
plugin: {
|
403
|
-
name: "@stylistic/eslint-plugin
|
404
|
-
url: "https://eslint.style
|
403
|
+
name: "@stylistic/eslint-plugin",
|
404
|
+
url: "https://eslint.style",
|
405
405
|
},
|
406
406
|
rule: {
|
407
407
|
name: "padding-line-between-statements",
|
408
|
-
url: "https://eslint.style/rules/
|
408
|
+
url: "https://eslint.style/rules/padding-line-between-statements",
|
409
409
|
},
|
410
410
|
},
|
411
411
|
],
|
@@ -14,7 +14,6 @@ const {
|
|
14
14
|
CALL,
|
15
15
|
CONSTRUCT,
|
16
16
|
ReferenceTracker,
|
17
|
-
findVariable,
|
18
17
|
} = require("@eslint-community/eslint-utils");
|
19
18
|
const {
|
20
19
|
RegExpValidator,
|
@@ -167,22 +166,6 @@ module.exports = {
|
|
167
166
|
const [{ disallowRedundantWrapping }] = context.options;
|
168
167
|
const sourceCode = context.sourceCode;
|
169
168
|
|
170
|
-
/**
|
171
|
-
* Determines whether the given identifier node is a reference to a global variable.
|
172
|
-
* @param {ASTNode} node `Identifier` node to check.
|
173
|
-
* @returns {boolean} True if the identifier is a reference to a global variable.
|
174
|
-
*/
|
175
|
-
function isGlobalReference(node) {
|
176
|
-
const scope = sourceCode.getScope(node);
|
177
|
-
const variable = findVariable(scope, node);
|
178
|
-
|
179
|
-
return (
|
180
|
-
variable !== null &&
|
181
|
-
variable.scope.type === "global" &&
|
182
|
-
variable.defs.length === 0
|
183
|
-
);
|
184
|
-
}
|
185
|
-
|
186
169
|
/**
|
187
170
|
* Determines whether the given node is a String.raw`` tagged template expression
|
188
171
|
* with a static template literal.
|
@@ -193,7 +176,7 @@ module.exports = {
|
|
193
176
|
return (
|
194
177
|
node.type === "TaggedTemplateExpression" &&
|
195
178
|
astUtils.isSpecificMemberAccess(node.tag, "String", "raw") &&
|
196
|
-
isGlobalReference(
|
179
|
+
sourceCode.isGlobalReference(
|
197
180
|
astUtils.skipChainExpression(node.tag).object,
|
198
181
|
) &&
|
199
182
|
astUtils.isStaticTemplateLiteral(node.quasi)
|
package/lib/rules/quote-props.js
CHANGED
@@ -31,12 +31,12 @@ module.exports = {
|
|
31
31
|
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
32
32
|
url: "https://eslint.style/guide/migration",
|
33
33
|
plugin: {
|
34
|
-
name: "@stylistic/eslint-plugin
|
35
|
-
url: "https://eslint.style
|
34
|
+
name: "@stylistic/eslint-plugin",
|
35
|
+
url: "https://eslint.style",
|
36
36
|
},
|
37
37
|
rule: {
|
38
38
|
name: "quote-props",
|
39
|
-
url: "https://eslint.style/rules/
|
39
|
+
url: "https://eslint.style/rules/quote-props",
|
40
40
|
},
|
41
41
|
},
|
42
42
|
],
|
package/lib/rules/quotes.js
CHANGED
@@ -108,12 +108,12 @@ module.exports = {
|
|
108
108
|
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
109
109
|
url: "https://eslint.style/guide/migration",
|
110
110
|
plugin: {
|
111
|
-
name: "@stylistic/eslint-plugin
|
112
|
-
url: "https://eslint.style
|
111
|
+
name: "@stylistic/eslint-plugin",
|
112
|
+
url: "https://eslint.style",
|
113
113
|
},
|
114
114
|
rule: {
|
115
115
|
name: "quotes",
|
116
|
-
url: "https://eslint.style/rules/
|
116
|
+
url: "https://eslint.style/rules/quotes",
|
117
117
|
},
|
118
118
|
},
|
119
119
|
],
|