eslint-plugin-svelte 2.22.0 → 2.23.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/lib/rules/indent-helpers/commons.js +2 -3
- package/lib/rules/indent-helpers/es.js +1 -1
- package/lib/rules/indent-helpers/index.js +1 -1
- package/lib/rules/indent-helpers/svelte.js +13 -9
- package/lib/rules/indent-helpers/ts.js +1 -1
- package/lib/rules/infinite-reactive-loop.js +65 -57
- package/lib/rules/mustache-spacing.js +1 -1
- package/lib/rules/no-dom-manipulating.js +1 -1
- package/lib/rules/prefer-destructured-store-props.js +1 -1
- package/lib/rules/reference-helpers/svelte-store.js +1 -1
- package/lib/rules/require-event-dispatcher-types.js +1 -1
- package/lib/shared/svelte-compile-warns/extract-leading-comments.js +1 -1
- package/lib/utils/ast-utils.js +1 -1
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isBeginningOfElement = exports.isBeginningOfLine = exports.getFirstAndLastTokens = void 0;
|
|
4
|
-
const eslint_utils_1 = require("eslint-utils");
|
|
4
|
+
const eslint_utils_1 = require("@eslint-community/eslint-utils");
|
|
5
5
|
const ast_1 = require("./ast");
|
|
6
6
|
function getFirstAndLastTokens(sourceCode, node, borderOffset = 0) {
|
|
7
7
|
let firstToken = sourceCode.getFirstToken(node);
|
|
@@ -47,8 +47,7 @@ function isBeginningOfElement(node) {
|
|
|
47
47
|
if (node.parent.type === "Program") {
|
|
48
48
|
return node.parent.body[0] === node;
|
|
49
49
|
}
|
|
50
|
-
assertNever(node.parent);
|
|
51
|
-
return false;
|
|
50
|
+
return assertNever(node.parent);
|
|
52
51
|
}
|
|
53
52
|
exports.isBeginningOfElement = isBeginningOfElement;
|
|
54
53
|
function assertNever(value) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.defineVisitor = void 0;
|
|
4
4
|
const commons_1 = require("./commons");
|
|
5
|
-
const eslint_utils_1 = require("eslint-utils");
|
|
5
|
+
const eslint_utils_1 = require("@eslint-community/eslint-utils");
|
|
6
6
|
const ast_utils_1 = require("../../utils/ast-utils");
|
|
7
7
|
function defineVisitor(context) {
|
|
8
8
|
const { sourceCode, offsets, options } = context;
|
|
@@ -28,7 +28,7 @@ const SV = __importStar(require("./svelte"));
|
|
|
28
28
|
const ES = __importStar(require("./es"));
|
|
29
29
|
const TS = __importStar(require("./ts"));
|
|
30
30
|
const ast_1 = require("./ast");
|
|
31
|
-
const eslint_utils_1 = require("eslint-utils");
|
|
31
|
+
const eslint_utils_1 = require("@eslint-community/eslint-utils");
|
|
32
32
|
const offset_context_1 = require("./offset-context");
|
|
33
33
|
function parseOptions(options, defaultOptions) {
|
|
34
34
|
const ret = {
|
|
@@ -16,17 +16,21 @@ function defineVisitor(context) {
|
|
|
16
16
|
node.children.forEach((n) => offsets.ignore(n));
|
|
17
17
|
},
|
|
18
18
|
SvelteElement(node) {
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
if (node.name.type === "Identifier" || node.name.type === "SvelteName") {
|
|
20
|
+
if (PREFORMATTED_ELEMENT_NAMES.includes(node.name.name)) {
|
|
21
|
+
const startTagToken = sourceCode.getFirstToken(node);
|
|
22
|
+
const endTagToken = node.endTag && sourceCode.getFirstToken(node.endTag);
|
|
23
|
+
offsets.setOffsetToken(endTagToken, 0, startTagToken);
|
|
24
|
+
node.children.forEach((n) => offsets.ignore(n));
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (node.name.name === "style") {
|
|
28
|
+
node.children.forEach((n) => offsets.ignore(n));
|
|
29
|
+
return;
|
|
23
30
|
}
|
|
24
31
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const endTagToken = node.endTag && sourceCode.getFirstToken(node.endTag);
|
|
28
|
-
offsets.setOffsetToken(endTagToken, 0, startTagToken);
|
|
29
|
-
node.children.forEach((n) => offsets.ignore(n));
|
|
32
|
+
if (node.endTag) {
|
|
33
|
+
offsets.setOffsetElementList(node.children.filter(isNotEmptyTextNode), node.startTag, node.endTag, 1);
|
|
30
34
|
}
|
|
31
35
|
},
|
|
32
36
|
SvelteStartTag(node) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.defineVisitor = void 0;
|
|
4
|
-
const eslint_utils_1 = require("eslint-utils");
|
|
4
|
+
const eslint_utils_1 = require("@eslint-community/eslint-utils");
|
|
5
5
|
const commons_1 = require("./commons");
|
|
6
6
|
const commons_2 = require("./commons");
|
|
7
7
|
function defineVisitor(context) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const eslint_utils_1 = require("eslint-utils");
|
|
3
|
+
const eslint_utils_1 = require("@eslint-community/eslint-utils");
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const ast_utils_1 = require("../utils/ast-utils");
|
|
6
6
|
const svelte_eslint_parser_1 = require("svelte-eslint-parser");
|
|
@@ -166,73 +166,81 @@ function isInsideOfFunction(node) {
|
|
|
166
166
|
return false;
|
|
167
167
|
}
|
|
168
168
|
function doLint(context, ast, callFuncIdentifiers, tickCallExpressions, taskReferences, reactiveVariableNames, reactiveVariableReferences, pIsSameTask) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
if (isChildNode(callExpression, node)) {
|
|
169
|
+
const processed = new Set();
|
|
170
|
+
verifyInternal(ast, callFuncIdentifiers, pIsSameTask);
|
|
171
|
+
function verifyInternal(ast, callFuncIdentifiers, pIsSameTask) {
|
|
172
|
+
if (processed.has(ast)) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
processed.add(ast);
|
|
176
|
+
let isSameMicroTask = pIsSameTask;
|
|
177
|
+
const differentMicroTaskEnterNodes = [];
|
|
178
|
+
(0, svelte_eslint_parser_1.traverseNodes)(ast, {
|
|
179
|
+
enterNode(node) {
|
|
180
|
+
if (isPromiseThenOrCatchBody(node)) {
|
|
182
181
|
differentMicroTaskEnterNodes.push(node);
|
|
183
182
|
isSameMicroTask = false;
|
|
184
183
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const functionDeclarationNode = getFunctionDeclarationNode(context, node);
|
|
194
|
-
if (functionDeclarationNode) {
|
|
195
|
-
doLint(context, functionDeclarationNode, [...callFuncIdentifiers, node], tickCallExpressions, taskReferences, reactiveVariableNames, reactiveVariableReferences, isSameMicroTask);
|
|
184
|
+
for (const { node: callExpression } of [
|
|
185
|
+
...tickCallExpressions,
|
|
186
|
+
...taskReferences,
|
|
187
|
+
]) {
|
|
188
|
+
if (isChildNode(callExpression, node)) {
|
|
189
|
+
differentMicroTaskEnterNodes.push(node);
|
|
190
|
+
isSameMicroTask = false;
|
|
191
|
+
}
|
|
196
192
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
193
|
+
if (node.parent?.type === "AssignmentExpression" &&
|
|
194
|
+
node.parent?.right.type === "AwaitExpression" &&
|
|
195
|
+
node.parent?.left === node) {
|
|
196
|
+
differentMicroTaskEnterNodes.push(node);
|
|
197
|
+
isSameMicroTask = false;
|
|
198
|
+
}
|
|
199
|
+
if (node.type === "Identifier" && isFunctionCall(node)) {
|
|
200
|
+
const functionDeclarationNode = getFunctionDeclarationNode(context, node);
|
|
201
|
+
if (functionDeclarationNode) {
|
|
202
|
+
verifyInternal(functionDeclarationNode, [...callFuncIdentifiers, node], isSameMicroTask);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (!isSameMicroTask) {
|
|
206
|
+
if (isReactiveVariableNode(reactiveVariableReferences, node) &&
|
|
207
|
+
reactiveVariableNames.includes(node.name) &&
|
|
208
|
+
isNodeForAssign(node)) {
|
|
208
209
|
context.report({
|
|
209
|
-
node
|
|
210
|
-
loc:
|
|
211
|
-
messageId: "
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
210
|
+
node,
|
|
211
|
+
loc: node.loc,
|
|
212
|
+
messageId: "unexpected",
|
|
213
|
+
});
|
|
214
|
+
callFuncIdentifiers.forEach((callFuncIdentifier) => {
|
|
215
|
+
context.report({
|
|
216
|
+
node: callFuncIdentifier,
|
|
217
|
+
loc: callFuncIdentifier.loc,
|
|
218
|
+
messageId: "unexpectedCall",
|
|
219
|
+
data: {
|
|
220
|
+
variableName: node.name,
|
|
221
|
+
},
|
|
222
|
+
});
|
|
215
223
|
});
|
|
216
|
-
}
|
|
224
|
+
}
|
|
217
225
|
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
226
|
+
},
|
|
227
|
+
leaveNode(node) {
|
|
228
|
+
if (node.type === "AwaitExpression") {
|
|
229
|
+
if (ast.parent?.type === "SvelteReactiveStatement") {
|
|
230
|
+
if (!isInsideOfFunction(node)) {
|
|
231
|
+
isSameMicroTask = false;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
224
235
|
isSameMicroTask = false;
|
|
225
236
|
}
|
|
226
237
|
}
|
|
227
|
-
|
|
228
|
-
isSameMicroTask =
|
|
238
|
+
if (differentMicroTaskEnterNodes.includes(node)) {
|
|
239
|
+
isSameMicroTask = true;
|
|
229
240
|
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
},
|
|
235
|
-
});
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
}
|
|
236
244
|
}
|
|
237
245
|
exports.default = (0, utils_1.createRule)("infinite-reactive-loop", {
|
|
238
246
|
meta: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const eslint_utils_1 = require("eslint-utils");
|
|
3
|
+
const eslint_utils_1 = require("@eslint-community/eslint-utils");
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const ast_utils_1 = require("../utils/ast-utils");
|
|
6
6
|
const VALUE_SCHEMA = { enum: ["never", "always"] };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("../utils");
|
|
4
4
|
const ast_utils_1 = require("../utils/ast-utils");
|
|
5
|
-
const eslint_utils_1 = require("eslint-utils");
|
|
5
|
+
const eslint_utils_1 = require("@eslint-community/eslint-utils");
|
|
6
6
|
const DOM_MANIPULATING_METHODS = new Set([
|
|
7
7
|
"appendChild",
|
|
8
8
|
"insertBefore",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const eslint_utils_1 = require("eslint-utils");
|
|
3
|
+
const eslint_utils_1 = require("@eslint-community/eslint-utils");
|
|
4
4
|
const esutils_1 = require("esutils");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const ast_utils_1 = require("../utils/ast-utils");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createStoreChecker = exports.extractStoreReferences = void 0;
|
|
4
|
-
const eslint_utils_1 = require("eslint-utils");
|
|
4
|
+
const eslint_utils_1 = require("@eslint-community/eslint-utils");
|
|
5
5
|
const ts_utils_1 = require("../../utils/ts-utils");
|
|
6
6
|
const ast_utils_1 = require("../../utils/ast-utils");
|
|
7
7
|
function* extractStoreReferences(context, storeNames = ["writable", "readable", "derived"]) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const eslint_utils_1 = require("eslint-utils");
|
|
3
|
+
const eslint_utils_1 = require("@eslint-community/eslint-utils");
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const ast_utils_1 = require("../utils/ast-utils");
|
|
6
6
|
exports.default = (0, utils_1.createRule)("require-event-dispatcher-types", {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.extractLeadingComments = void 0;
|
|
4
|
-
const eslint_utils_1 = require("eslint-utils");
|
|
4
|
+
const eslint_utils_1 = require("@eslint-community/eslint-utils");
|
|
5
5
|
function extractLeadingComments(context, node) {
|
|
6
6
|
const sourceCode = context.getSourceCode();
|
|
7
7
|
const beforeToken = sourceCode.getTokenBefore(node, {
|
package/lib/utils/ast-utils.js
CHANGED
|
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.isExpressionIdentifier = exports.isVoidHtmlElement = exports.getNodeName = exports.getDirectiveName = exports.getAttributeKeyText = exports.getMustacheTokens = exports.getAttributeValueQuoteAndRange = exports.getParent = exports.getScope = exports.findVariable = exports.getLangValue = exports.getStaticAttributeValue = exports.findBindDirective = exports.findShorthandAttribute = exports.findAttribute = exports.isHTMLElementLike = exports.needParentheses = exports.getStringIfConstant = exports.equalTokens = void 0;
|
|
30
|
-
const eslintUtils = __importStar(require("eslint-utils"));
|
|
30
|
+
const eslintUtils = __importStar(require("@eslint-community/eslint-utils"));
|
|
31
31
|
const void_elements_1 = __importDefault(require("./void-elements"));
|
|
32
32
|
function equalTokens(left, right, sourceCode) {
|
|
33
33
|
const tokensL = sourceCode.getTokens(left);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-svelte",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.23.0",
|
|
4
4
|
"description": "ESLint plugin for Svelte using AST",
|
|
5
5
|
"repository": "git+https://github.com/ota-meshi/eslint-plugin-svelte.git",
|
|
6
6
|
"homepage": "https://ota-meshi.github.io/eslint-plugin-svelte",
|
|
@@ -65,9 +65,9 @@
|
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
+
"@eslint-community/eslint-utils": "^4.2.0",
|
|
68
69
|
"@jridgewell/sourcemap-codec": "^1.4.14",
|
|
69
70
|
"debug": "^4.3.1",
|
|
70
|
-
"eslint-utils": "^3.0.0",
|
|
71
71
|
"esutils": "^2.0.3",
|
|
72
72
|
"known-css-properties": "^0.27.0",
|
|
73
73
|
"postcss": "^8.4.5",
|