eslint-plugin-svelte 2.11.0 → 2.12.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 +45 -6
- package/lib/rules/indent-helpers/ast.d.ts +3 -3
- package/lib/rules/indent-helpers/es.js +7 -9
- package/lib/rules/no-export-load-in-svelte-module-in-kit-pages.d.ts +2 -0
- package/lib/rules/no-export-load-in-svelte-module-in-kit-pages.js +41 -0
- package/lib/rules/reference-helpers/svelte-store.d.ts +6 -2
- package/lib/rules/reference-helpers/svelte-store.js +99 -1
- package/lib/rules/require-store-callbacks-use-set-param.d.ts +2 -0
- package/lib/rules/require-store-callbacks-use-set-param.js +43 -0
- package/lib/rules/require-store-reactive-access.d.ts +2 -0
- package/lib/rules/require-store-reactive-access.js +205 -0
- package/lib/rules/valid-prop-names-in-kit-pages.d.ts +2 -0
- package/lib/rules/valid-prop-names-in-kit-pages.js +61 -0
- package/lib/types-for-node.d.ts +72 -73
- package/lib/types.d.ts +8 -3
- package/lib/utils/ast-utils.d.ts +5 -5
- package/lib/utils/ast-utils.js +5 -1
- package/lib/utils/cache.d.ts +4 -0
- package/lib/utils/cache.js +32 -0
- package/lib/utils/css-utils/style-attribute.d.ts +4 -4
- package/lib/utils/eslint-core.d.ts +3 -3
- package/lib/utils/get-package-json.d.ts +5 -0
- package/lib/utils/get-package-json.js +55 -0
- package/lib/utils/rules.js +8 -0
- package/lib/utils/svelte-kit.d.ts +2 -0
- package/lib/utils/svelte-kit.js +48 -0
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -188,12 +188,6 @@ See also <https://github.com/ota-meshi/svelte-eslint-parser#readme>.
|
|
|
188
188
|
|
|
189
189
|
You can change the behavior of this plugin with some settings.
|
|
190
190
|
|
|
191
|
-
- `ignoreWarnings` (optional) ... Specifies an array of rules that ignore reports in the template.
|
|
192
|
-
For example, set rules on the template that cannot avoid false positives.
|
|
193
|
-
- `compileOptions` (optional) ... Specifies options for Svelte compile. Effects rules that use Svelte compile. The target rules are [svelte/valid-compile](https://ota-meshi.github.io/eslint-plugin-svelte/rules/valid-compile/) and [svelte/no-unused-svelte-ignore](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-unused-svelte-ignore/). **Note that it has no effect on ESLint's custom parser**.
|
|
194
|
-
- `postcss` (optional) ... Specifies options related to PostCSS. You can disable the PostCSS process by specifying `false`.
|
|
195
|
-
- `configFilePath` (optional) ... Specifies the path of the directory containing the PostCSS configuration.
|
|
196
|
-
|
|
197
191
|
e.g.
|
|
198
192
|
|
|
199
193
|
```js
|
|
@@ -210,6 +204,47 @@ module.exports = {
|
|
|
210
204
|
configFilePath: "./path/to/my/postcss.config.js",
|
|
211
205
|
},
|
|
212
206
|
},
|
|
207
|
+
kit: {
|
|
208
|
+
files: {
|
|
209
|
+
routes: "src/routes",
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
// ...
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
#### settings.svelte.ignoreWarnings
|
|
219
|
+
|
|
220
|
+
Specifies an array of rules that ignore reports in the template.
|
|
221
|
+
For example, set rules on the template that cannot avoid false positives.
|
|
222
|
+
|
|
223
|
+
#### settings.svelte.compileOptions
|
|
224
|
+
|
|
225
|
+
Specifies options for Svelte compile. Effects rules that use Svelte compile. The target rules are [svelte/valid-compile](https://ota-meshi.github.io/eslint-plugin-svelte/rules/valid-compile/) and [svelte/no-unused-svelte-ignore](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-unused-svelte-ignore/). **Note that it has no effect on ESLint's custom parser**.
|
|
226
|
+
|
|
227
|
+
- `postcss` ... Specifies options related to PostCSS. You can disable the PostCSS process by specifying `false`.
|
|
228
|
+
- `configFilePath` ... Specifies the path of the directory containing the PostCSS configuration.
|
|
229
|
+
|
|
230
|
+
#### settings.svelte.kit
|
|
231
|
+
|
|
232
|
+
If you use SvelteKit with not default configuration, you need to set below configurations.
|
|
233
|
+
The schema is subset of SvelteKit's configuration.
|
|
234
|
+
Therefore please check [SvelteKit docs](https://kit.svelte.dev/docs/configuration) for more details.
|
|
235
|
+
|
|
236
|
+
e.g.
|
|
237
|
+
|
|
238
|
+
```js
|
|
239
|
+
module.exports = {
|
|
240
|
+
// ...
|
|
241
|
+
settings: {
|
|
242
|
+
svelte: {
|
|
243
|
+
kit: {
|
|
244
|
+
files: {
|
|
245
|
+
routes: "src/routes",
|
|
246
|
+
},
|
|
247
|
+
},
|
|
213
248
|
},
|
|
214
249
|
},
|
|
215
250
|
// ...
|
|
@@ -266,12 +301,16 @@ These rules relate to possible syntax or logic errors in Svelte code:
|
|
|
266
301
|
| [svelte/no-dupe-else-if-blocks](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-dupe-else-if-blocks/) | disallow duplicate conditions in `{#if}` / `{:else if}` chains | :star: |
|
|
267
302
|
| [svelte/no-dupe-style-properties](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-dupe-style-properties/) | disallow duplicate style properties | :star: |
|
|
268
303
|
| [svelte/no-dynamic-slot-name](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-dynamic-slot-name/) | disallow dynamic slot name | :star::wrench: |
|
|
304
|
+
| [svelte/no-export-load-in-svelte-module-in-kit-pages](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-export-load-in-svelte-module-in-kit-pages/) | disallow exporting load functions in `*.svelte` module in Svelte Kit page components. | |
|
|
269
305
|
| [svelte/no-not-function-handler](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-not-function-handler/) | disallow use of not function in event handler | :star: |
|
|
270
306
|
| [svelte/no-object-in-text-mustaches](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-object-in-text-mustaches/) | disallow objects in text mustache interpolation | :star: |
|
|
271
307
|
| [svelte/no-shorthand-style-property-overrides](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-shorthand-style-property-overrides/) | disallow shorthand style properties that override related longhand properties | :star: |
|
|
272
308
|
| [svelte/no-store-async](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-store-async/) | disallow using async/await inside svelte stores because it causes issues with the auto-unsubscribing features | |
|
|
273
309
|
| [svelte/no-unknown-style-directive-property](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-unknown-style-directive-property/) | disallow unknown `style:property` | :star: |
|
|
310
|
+
| [svelte/require-store-callbacks-use-set-param](https://ota-meshi.github.io/eslint-plugin-svelte/rules/require-store-callbacks-use-set-param/) | store callbacks must use `set` param | |
|
|
311
|
+
| [svelte/require-store-reactive-access](https://ota-meshi.github.io/eslint-plugin-svelte/rules/require-store-reactive-access/) | disallow to use of the store itself as an operand. Need to use $ prefix or get function. | :wrench: |
|
|
274
312
|
| [svelte/valid-compile](https://ota-meshi.github.io/eslint-plugin-svelte/rules/valid-compile/) | disallow warnings when compiling. | :star: |
|
|
313
|
+
| [svelte/valid-prop-names-in-kit-pages](https://ota-meshi.github.io/eslint-plugin-svelte/rules/valid-prop-names-in-kit-pages/) | disallow props other than data or errors in Svelte Kit page components. | |
|
|
275
314
|
|
|
276
315
|
## Security Vulnerability
|
|
277
316
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AST } from "svelte-eslint-parser";
|
|
2
|
-
import type
|
|
2
|
+
import type { TSESTree } from "@typescript-eslint/types";
|
|
3
3
|
declare type AnyToken = AST.Token | AST.Comment;
|
|
4
|
-
export declare function isWhitespace(token: AnyToken |
|
|
5
|
-
export declare function isNotWhitespace(token: AnyToken |
|
|
4
|
+
export declare function isWhitespace(token: AnyToken | TSESTree.Comment | null | undefined): boolean;
|
|
5
|
+
export declare function isNotWhitespace(token: AnyToken | TSESTree.Comment | null | undefined): boolean;
|
|
6
6
|
export {};
|
|
@@ -3,11 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.defineVisitor = void 0;
|
|
4
4
|
const commons_1 = require("./commons");
|
|
5
5
|
const eslint_utils_1 = require("eslint-utils");
|
|
6
|
+
const ast_utils_1 = require("../../utils/ast-utils");
|
|
6
7
|
function defineVisitor(context) {
|
|
7
8
|
const { sourceCode, offsets, options } = context;
|
|
8
9
|
function getRootLeft(node) {
|
|
9
10
|
let target = node;
|
|
10
|
-
let parent = getParent(target);
|
|
11
|
+
let parent = (0, ast_utils_1.getParent)(target);
|
|
11
12
|
while (parent &&
|
|
12
13
|
(parent.type === "AssignmentExpression" ||
|
|
13
14
|
parent.type === "AssignmentPattern" ||
|
|
@@ -18,7 +19,7 @@ function defineVisitor(context) {
|
|
|
18
19
|
break;
|
|
19
20
|
}
|
|
20
21
|
target = parent;
|
|
21
|
-
parent = getParent(target);
|
|
22
|
+
parent = (0, ast_utils_1.getParent)(target);
|
|
22
23
|
}
|
|
23
24
|
return target.left;
|
|
24
25
|
}
|
|
@@ -161,12 +162,12 @@ function defineVisitor(context) {
|
|
|
161
162
|
});
|
|
162
163
|
const alternateToken = sourceCode.getTokenAfter(colonToken);
|
|
163
164
|
let baseNode = node;
|
|
164
|
-
let parent = getParent(baseNode);
|
|
165
|
+
let parent = (0, ast_utils_1.getParent)(baseNode);
|
|
165
166
|
while (parent &&
|
|
166
167
|
parent.type === "ConditionalExpression" &&
|
|
167
168
|
parent.alternate === baseNode) {
|
|
168
169
|
baseNode = parent;
|
|
169
|
-
parent = getParent(baseNode);
|
|
170
|
+
parent = (0, ast_utils_1.getParent)(baseNode);
|
|
170
171
|
}
|
|
171
172
|
const baseToken = sourceCode.getFirstToken(baseNode);
|
|
172
173
|
offsets.setOffsetToken([questionToken, colonToken], 1, baseToken);
|
|
@@ -335,9 +336,9 @@ function defineVisitor(context) {
|
|
|
335
336
|
filter: eslint_utils_1.isOpeningParenToken,
|
|
336
337
|
includeComments: false,
|
|
337
338
|
});
|
|
338
|
-
let bodyBaseToken;
|
|
339
|
+
let bodyBaseToken = null;
|
|
339
340
|
if (firstToken.type === "Punctuator") {
|
|
340
|
-
bodyBaseToken = sourceCode.getFirstToken(getParent(node));
|
|
341
|
+
bodyBaseToken = sourceCode.getFirstToken((0, ast_utils_1.getParent)(node));
|
|
341
342
|
}
|
|
342
343
|
else {
|
|
343
344
|
let tokenOffset = 0;
|
|
@@ -735,9 +736,6 @@ function defineVisitor(context) {
|
|
|
735
736
|
};
|
|
736
737
|
}
|
|
737
738
|
exports.defineVisitor = defineVisitor;
|
|
738
|
-
function getParent(node) {
|
|
739
|
-
return node.parent || null;
|
|
740
|
-
}
|
|
741
739
|
function isOptionalToken(token) {
|
|
742
740
|
return token.type === "Punctuator" && token.value === "?.";
|
|
743
741
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("../utils");
|
|
4
|
+
const svelte_kit_1 = require("../utils/svelte-kit");
|
|
5
|
+
exports.default = (0, utils_1.createRule)("no-export-load-in-svelte-module-in-kit-pages", {
|
|
6
|
+
meta: {
|
|
7
|
+
docs: {
|
|
8
|
+
description: "disallow exporting load functions in `*.svelte` module in Svelte Kit page components.",
|
|
9
|
+
category: "Possible Errors",
|
|
10
|
+
recommended: false,
|
|
11
|
+
},
|
|
12
|
+
schema: [],
|
|
13
|
+
messages: {
|
|
14
|
+
unexpected: "disallow exporting load functions in `*.svelte` module in Svelte Kit page components.",
|
|
15
|
+
},
|
|
16
|
+
type: "problem",
|
|
17
|
+
},
|
|
18
|
+
create(context) {
|
|
19
|
+
if (!(0, svelte_kit_1.isKitPageComponent)(context)) {
|
|
20
|
+
return {};
|
|
21
|
+
}
|
|
22
|
+
let isModule = false;
|
|
23
|
+
return {
|
|
24
|
+
[`Program > SvelteScriptElement > SvelteStartTag > SvelteAttribute[key.name="context"] > SvelteLiteral[value="module"]`]: () => {
|
|
25
|
+
isModule = true;
|
|
26
|
+
},
|
|
27
|
+
"Program > SvelteScriptElement:exit": () => {
|
|
28
|
+
isModule = false;
|
|
29
|
+
},
|
|
30
|
+
[`:matches(ExportNamedDeclaration > FunctionDeclaration, ExportNamedDeclaration > VariableDeclaration > VariableDeclarator) > Identifier.id[name="load"]`]: (node) => {
|
|
31
|
+
if (!isModule)
|
|
32
|
+
return {};
|
|
33
|
+
return context.report({
|
|
34
|
+
node,
|
|
35
|
+
loc: node.loc,
|
|
36
|
+
messageId: "unexpected",
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
});
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { TSESTree } from "@typescript-eslint/types";
|
|
2
2
|
import type { RuleContext } from "../../types";
|
|
3
3
|
declare type StoreName = "writable" | "readable" | "derived";
|
|
4
4
|
export declare function extractStoreReferences(context: RuleContext, storeNames?: StoreName[]): Generator<{
|
|
5
|
-
node:
|
|
5
|
+
node: TSESTree.CallExpression;
|
|
6
6
|
name: string;
|
|
7
7
|
}, void>;
|
|
8
|
+
export declare type StoreChecker = (node: TSESTree.Expression, options?: {
|
|
9
|
+
consistent?: boolean;
|
|
10
|
+
}) => boolean;
|
|
11
|
+
export declare function createStoreChecker(context: RuleContext): StoreChecker;
|
|
8
12
|
export {};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractStoreReferences = void 0;
|
|
3
|
+
exports.createStoreChecker = exports.extractStoreReferences = void 0;
|
|
4
4
|
const eslint_utils_1 = require("eslint-utils");
|
|
5
|
+
const ts_utils_1 = require("../../utils/ts-utils");
|
|
6
|
+
const ast_utils_1 = require("../../utils/ast-utils");
|
|
5
7
|
function* extractStoreReferences(context, storeNames = ["writable", "readable", "derived"]) {
|
|
6
8
|
const referenceTracker = new eslint_utils_1.ReferenceTracker(context.getScope());
|
|
7
9
|
for (const { node, path } of referenceTracker.iterateEsmReferences({
|
|
@@ -25,3 +27,99 @@ function* extractStoreReferences(context, storeNames = ["writable", "readable",
|
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
exports.extractStoreReferences = extractStoreReferences;
|
|
30
|
+
function createStoreChecker(context) {
|
|
31
|
+
const tools = (0, ts_utils_1.getTypeScriptTools)(context);
|
|
32
|
+
const checker = tools
|
|
33
|
+
? createStoreCheckerForTS(tools)
|
|
34
|
+
: createStoreCheckerForES(context);
|
|
35
|
+
return (node, options) => checker(node, {
|
|
36
|
+
consistent: options?.consistent ?? false,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
exports.createStoreChecker = createStoreChecker;
|
|
40
|
+
function createStoreCheckerForES(context) {
|
|
41
|
+
const storeVariables = new Map();
|
|
42
|
+
for (const { node } of extractStoreReferences(context)) {
|
|
43
|
+
const parent = (0, ast_utils_1.getParent)(node);
|
|
44
|
+
if (!parent ||
|
|
45
|
+
parent.type !== "VariableDeclarator" ||
|
|
46
|
+
parent.id.type !== "Identifier") {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const decl = (0, ast_utils_1.getParent)(parent);
|
|
50
|
+
if (!decl || decl.type !== "VariableDeclaration") {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const variable = (0, ast_utils_1.findVariable)(context, parent.id);
|
|
54
|
+
if (variable) {
|
|
55
|
+
storeVariables.set(variable, { const: decl.kind === "const" });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return (node, options) => {
|
|
59
|
+
if (node.type !== "Identifier" || node.name.startsWith("$")) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
const variable = (0, ast_utils_1.findVariable)(context, node);
|
|
63
|
+
if (!variable) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
const info = storeVariables.get(variable);
|
|
67
|
+
if (!info) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
return options.consistent ? info.const : true;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function createStoreCheckerForTS(tools) {
|
|
74
|
+
const { service } = tools;
|
|
75
|
+
const checker = service.program.getTypeChecker();
|
|
76
|
+
const tsNodeMap = service.esTreeNodeToTSNodeMap;
|
|
77
|
+
return (node, options) => {
|
|
78
|
+
const tsNode = tsNodeMap.get(node);
|
|
79
|
+
if (!tsNode) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
const type = checker.getTypeAtLocation(tsNode);
|
|
83
|
+
return isStoreType(checker.getApparentType(type));
|
|
84
|
+
function isStoreType(type) {
|
|
85
|
+
return eachTypeCheck(type, options, (type) => {
|
|
86
|
+
const subscribe = type.getProperty("subscribe");
|
|
87
|
+
if (!subscribe) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
const subscribeType = checker.getTypeOfSymbolAtLocation(subscribe, tsNode);
|
|
91
|
+
return isStoreSubscribeSignatureType(subscribeType);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function isStoreSubscribeSignatureType(type) {
|
|
95
|
+
return eachTypeCheck(type, options, (type) => {
|
|
96
|
+
for (const signature of type.getCallSignatures()) {
|
|
97
|
+
if (signature.parameters.length >= 2 &&
|
|
98
|
+
maybeFunctionSymbol(signature.parameters[0]) &&
|
|
99
|
+
maybeFunctionSymbol(signature.parameters[1])) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return false;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function maybeFunctionSymbol(param) {
|
|
107
|
+
const type = checker.getApparentType(checker.getTypeOfSymbolAtLocation(param, tsNode));
|
|
108
|
+
return maybeFunctionType(type);
|
|
109
|
+
}
|
|
110
|
+
function maybeFunctionType(type) {
|
|
111
|
+
return eachTypeCheck(type, { consistent: false }, (type) => {
|
|
112
|
+
return type.getCallSignatures().length > 0;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function eachTypeCheck(type, options, check) {
|
|
118
|
+
if (type.isUnion()) {
|
|
119
|
+
if (options.consistent) {
|
|
120
|
+
return type.types.every((t) => eachTypeCheck(t, options, check));
|
|
121
|
+
}
|
|
122
|
+
return type.types.some((t) => eachTypeCheck(t, options, check));
|
|
123
|
+
}
|
|
124
|
+
return check(type);
|
|
125
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("../utils");
|
|
4
|
+
const svelte_store_1 = require("./reference-helpers/svelte-store");
|
|
5
|
+
exports.default = (0, utils_1.createRule)("require-store-callbacks-use-set-param", {
|
|
6
|
+
meta: {
|
|
7
|
+
docs: {
|
|
8
|
+
description: "store callbacks must use `set` param",
|
|
9
|
+
category: "Possible Errors",
|
|
10
|
+
recommended: false,
|
|
11
|
+
},
|
|
12
|
+
schema: [],
|
|
13
|
+
messages: {
|
|
14
|
+
unexpected: "Store callbacks must use `set` param.",
|
|
15
|
+
},
|
|
16
|
+
type: "suggestion",
|
|
17
|
+
},
|
|
18
|
+
create(context) {
|
|
19
|
+
return {
|
|
20
|
+
Program() {
|
|
21
|
+
for (const { node } of (0, svelte_store_1.extractStoreReferences)(context, [
|
|
22
|
+
"readable",
|
|
23
|
+
"writable",
|
|
24
|
+
])) {
|
|
25
|
+
const [_, fn] = node.arguments;
|
|
26
|
+
if (!fn ||
|
|
27
|
+
(fn.type !== "ArrowFunctionExpression" &&
|
|
28
|
+
fn.type !== "FunctionExpression")) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const param = fn.params[0];
|
|
32
|
+
if (!param || (param.type === "Identifier" && param.name !== "set")) {
|
|
33
|
+
context.report({
|
|
34
|
+
node: fn,
|
|
35
|
+
loc: fn.loc,
|
|
36
|
+
messageId: "unexpected",
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
});
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("../utils");
|
|
4
|
+
const svelte_store_1 = require("./reference-helpers/svelte-store");
|
|
5
|
+
exports.default = (0, utils_1.createRule)("require-store-reactive-access", {
|
|
6
|
+
meta: {
|
|
7
|
+
docs: {
|
|
8
|
+
description: "disallow to use of the store itself as an operand. Need to use $ prefix or get function.",
|
|
9
|
+
category: "Possible Errors",
|
|
10
|
+
recommended: false,
|
|
11
|
+
},
|
|
12
|
+
fixable: "code",
|
|
13
|
+
schema: [],
|
|
14
|
+
messages: {
|
|
15
|
+
usingRawStoreInText: "Use the $ prefix or the get function to access reactive values instead of accessing the raw store.",
|
|
16
|
+
},
|
|
17
|
+
type: "problem",
|
|
18
|
+
},
|
|
19
|
+
create(context) {
|
|
20
|
+
if (!context.parserServices.isSvelte) {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
const isStore = (0, svelte_store_1.createStoreChecker)(context);
|
|
24
|
+
function verifyExpression(node, options) {
|
|
25
|
+
if (!node)
|
|
26
|
+
return;
|
|
27
|
+
if (isStore(node, { consistent: options?.consistent })) {
|
|
28
|
+
context.report({
|
|
29
|
+
node,
|
|
30
|
+
messageId: "usingRawStoreInText",
|
|
31
|
+
fix: node.type === "Identifier" && !options?.disableFix
|
|
32
|
+
? (fixer) => fixer.insertTextBefore(node, "$")
|
|
33
|
+
: null,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
SvelteMustacheTag(node) {
|
|
39
|
+
if (canAcceptStoreMustache(node)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
verifyExpression(node.expression);
|
|
43
|
+
},
|
|
44
|
+
SvelteShorthandAttribute(node) {
|
|
45
|
+
if (canAcceptStoreAttributeElement(node.parent.parent)) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
verifyExpression(node.value, { disableFix: true });
|
|
49
|
+
},
|
|
50
|
+
SvelteSpreadAttribute(node) {
|
|
51
|
+
verifyExpression(node.argument);
|
|
52
|
+
},
|
|
53
|
+
SvelteDirective(node) {
|
|
54
|
+
if (node.kind === "Action" ||
|
|
55
|
+
node.kind === "Animation" ||
|
|
56
|
+
node.kind === "Transition") {
|
|
57
|
+
if (node.key.name.type !== "Identifier") {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
verifyExpression(node.key.name);
|
|
61
|
+
}
|
|
62
|
+
else if (node.kind === "Binding") {
|
|
63
|
+
if (node.key.name.name !== "this" &&
|
|
64
|
+
canAcceptStoreAttributeElement(node.parent.parent)) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
verifyExpression(node.expression, {
|
|
68
|
+
disableFix: node.shorthand,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
else if (node.kind === "Class") {
|
|
72
|
+
verifyExpression(node.expression, {
|
|
73
|
+
disableFix: node.shorthand,
|
|
74
|
+
consistent: true,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
else if (node.kind === "EventHandler") {
|
|
78
|
+
verifyExpression(node.expression);
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
SvelteStyleDirective(node) {
|
|
82
|
+
if (node.shorthand && node.key.name.type === "Identifier") {
|
|
83
|
+
verifyExpression(node.key.name, {
|
|
84
|
+
disableFix: true,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
SvelteSpecialDirective(node) {
|
|
89
|
+
if (node.kind === "this") {
|
|
90
|
+
verifyExpression(node.expression);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"SvelteIfBlock, SvelteAwaitBlock"(node) {
|
|
94
|
+
verifyExpression(node.expression, {
|
|
95
|
+
consistent: true,
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
SvelteEachBlock(node) {
|
|
99
|
+
verifyExpression(node.expression);
|
|
100
|
+
},
|
|
101
|
+
["IfStatement, WhileStatement, DoWhileStatement, " +
|
|
102
|
+
"ConditionalExpression, ForStatement"](node) {
|
|
103
|
+
verifyExpression(node.test, {
|
|
104
|
+
consistent: true,
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
"ForInStatement, ForOfStatement"(node) {
|
|
108
|
+
verifyExpression(node.right);
|
|
109
|
+
},
|
|
110
|
+
SwitchStatement(node) {
|
|
111
|
+
verifyExpression(node.discriminant);
|
|
112
|
+
},
|
|
113
|
+
"CallExpression, NewExpression"(node) {
|
|
114
|
+
if (node.callee.type === "Super") {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
verifyExpression(node.callee);
|
|
118
|
+
},
|
|
119
|
+
UnaryExpression(node) {
|
|
120
|
+
verifyExpression(node.argument, {
|
|
121
|
+
consistent: node.operator === "!" || node.operator === "typeof",
|
|
122
|
+
});
|
|
123
|
+
},
|
|
124
|
+
"UpdateExpression, SpreadElement"(node) {
|
|
125
|
+
verifyExpression(node.argument);
|
|
126
|
+
},
|
|
127
|
+
AssignmentExpression(node) {
|
|
128
|
+
if (node.operator !== "=") {
|
|
129
|
+
if (node.left.type !== "ObjectPattern" &&
|
|
130
|
+
node.left.type !== "ArrayPattern") {
|
|
131
|
+
verifyExpression(node.left);
|
|
132
|
+
}
|
|
133
|
+
verifyExpression(node.right);
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
BinaryExpression(node) {
|
|
137
|
+
if (node.left.type !== "PrivateIdentifier") {
|
|
138
|
+
verifyExpression(node.left, {
|
|
139
|
+
consistent: node.operator === "==" ||
|
|
140
|
+
node.operator === "!=" ||
|
|
141
|
+
node.operator === "===" ||
|
|
142
|
+
node.operator === "!==",
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
verifyExpression(node.right, {
|
|
146
|
+
consistent: node.operator === "==" ||
|
|
147
|
+
node.operator === "!=" ||
|
|
148
|
+
node.operator === "===" ||
|
|
149
|
+
node.operator === "!==",
|
|
150
|
+
});
|
|
151
|
+
},
|
|
152
|
+
LogicalExpression(node) {
|
|
153
|
+
verifyExpression(node.left, {
|
|
154
|
+
consistent: true,
|
|
155
|
+
});
|
|
156
|
+
},
|
|
157
|
+
TemplateLiteral(node) {
|
|
158
|
+
for (const expr of node.expressions) {
|
|
159
|
+
verifyExpression(expr);
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
TaggedTemplateExpression(node) {
|
|
163
|
+
verifyExpression(node.tag);
|
|
164
|
+
},
|
|
165
|
+
"Property, PropertyDefinition, MethodDefinition"(node) {
|
|
166
|
+
if (node.key.type === "PrivateIdentifier" || !node.computed) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
verifyExpression(node.key);
|
|
170
|
+
},
|
|
171
|
+
ImportExpression(node) {
|
|
172
|
+
verifyExpression(node.source);
|
|
173
|
+
},
|
|
174
|
+
AwaitExpression(node) {
|
|
175
|
+
verifyExpression(node.argument, {
|
|
176
|
+
consistent: true,
|
|
177
|
+
});
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
function canAcceptStoreMustache(node) {
|
|
181
|
+
if (node.parent.type !== "SvelteAttribute") {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
const attr = node.parent;
|
|
185
|
+
if (attr.value.length > 1) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
if (attr.key.name.startsWith("--")) {
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
const element = attr.parent.parent;
|
|
192
|
+
return canAcceptStoreAttributeElement(element);
|
|
193
|
+
}
|
|
194
|
+
function canAcceptStoreAttributeElement(node) {
|
|
195
|
+
if (node.type !== "SvelteElement") {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
if (node.kind === "html" ||
|
|
199
|
+
(node.kind === "special" && node.name.name === "svelte:element")) {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("../utils");
|
|
4
|
+
const svelte_kit_1 = require("../utils/svelte-kit");
|
|
5
|
+
const EXPECTED_PROP_NAMES = ["data", "errors"];
|
|
6
|
+
exports.default = (0, utils_1.createRule)("valid-prop-names-in-kit-pages", {
|
|
7
|
+
meta: {
|
|
8
|
+
docs: {
|
|
9
|
+
description: "disallow props other than data or errors in Svelte Kit page components.",
|
|
10
|
+
category: "Possible Errors",
|
|
11
|
+
recommended: false,
|
|
12
|
+
},
|
|
13
|
+
schema: [],
|
|
14
|
+
messages: {
|
|
15
|
+
unexpected: "disallow props other than data or errors in Svelte Kit page components.",
|
|
16
|
+
},
|
|
17
|
+
type: "problem",
|
|
18
|
+
},
|
|
19
|
+
create(context) {
|
|
20
|
+
if (!(0, svelte_kit_1.isKitPageComponent)(context))
|
|
21
|
+
return {};
|
|
22
|
+
let isScript = false;
|
|
23
|
+
return {
|
|
24
|
+
"Program > SvelteScriptElement > SvelteStartTag": (node) => {
|
|
25
|
+
isScript = !node.attributes.some((a) => a.type === "SvelteAttribute" &&
|
|
26
|
+
a.key.name === "context" &&
|
|
27
|
+
a.value.some((v) => v.type === "SvelteLiteral" && v.value === "module"));
|
|
28
|
+
},
|
|
29
|
+
"Program > SvelteScriptElement:exit": () => {
|
|
30
|
+
isScript = false;
|
|
31
|
+
},
|
|
32
|
+
"ExportNamedDeclaration > VariableDeclaration > VariableDeclarator": (node) => {
|
|
33
|
+
if (!isScript)
|
|
34
|
+
return;
|
|
35
|
+
if (node.id.type === "Identifier") {
|
|
36
|
+
if (!EXPECTED_PROP_NAMES.includes(node.id.name)) {
|
|
37
|
+
context.report({
|
|
38
|
+
node,
|
|
39
|
+
loc: node.loc,
|
|
40
|
+
messageId: "unexpected",
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (node.id.type !== "ObjectPattern")
|
|
46
|
+
return;
|
|
47
|
+
for (const p of node.id.properties) {
|
|
48
|
+
if (p.type === "Property" &&
|
|
49
|
+
p.value.type === "Identifier" &&
|
|
50
|
+
!EXPECTED_PROP_NAMES.includes(p.value.name)) {
|
|
51
|
+
context.report({
|
|
52
|
+
node: p.value,
|
|
53
|
+
loc: p.value.loc,
|
|
54
|
+
messageId: "unexpected",
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
});
|
package/lib/types-for-node.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { TSESTree, AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
2
2
|
import type { AST } from "svelte-eslint-parser";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type: ESTree.Node["type"];
|
|
3
|
+
export declare type ASTNode = AST.SvelteNode | Exclude<Omit<TSESTree.Node, "parent">, {
|
|
4
|
+
type: AST.SvelteNode["type"];
|
|
6
5
|
}>;
|
|
7
|
-
export declare type ASTNodeWithParent = (Exclude<ASTNode,
|
|
6
|
+
export declare type ASTNodeWithParent = (Exclude<ASTNode, AST.SvelteProgram> & {
|
|
8
7
|
parent: ASTNodeWithParent;
|
|
9
8
|
}) | AST.SvelteProgram;
|
|
10
9
|
export declare type ASTNodeListener = {
|
|
@@ -206,75 +205,75 @@ export declare type ASTNodeListener = {
|
|
|
206
205
|
SvelteReactiveStatement?: (node: AST.SvelteReactiveStatement & ASTNodeWithParent) => void;
|
|
207
206
|
};
|
|
208
207
|
export declare type ESNodeListener = {
|
|
209
|
-
ArrayExpression?: (node:
|
|
210
|
-
ArrayPattern?: (node:
|
|
211
|
-
ArrowFunctionExpression?: (node:
|
|
212
|
-
AssignmentExpression?: (node:
|
|
213
|
-
AssignmentPattern?: (node:
|
|
214
|
-
AwaitExpression?: (node:
|
|
215
|
-
BinaryExpression?: (node:
|
|
216
|
-
BlockStatement?: (node:
|
|
217
|
-
BreakStatement?: (node:
|
|
218
|
-
CallExpression?: (node:
|
|
219
|
-
CatchClause?: (node:
|
|
220
|
-
ChainExpression?: (node:
|
|
221
|
-
ClassBody?: (node:
|
|
222
|
-
ClassDeclaration?: (node:
|
|
223
|
-
ClassExpression?: (node:
|
|
224
|
-
ConditionalExpression?: (node:
|
|
225
|
-
ContinueStatement?: (node:
|
|
226
|
-
DebuggerStatement?: (node:
|
|
227
|
-
DoWhileStatement?: (node:
|
|
228
|
-
EmptyStatement?: (node:
|
|
229
|
-
ExportAllDeclaration?: (node:
|
|
230
|
-
ExportDefaultDeclaration?: (node:
|
|
231
|
-
ExportNamedDeclaration?: (node:
|
|
232
|
-
ExportSpecifier?: (node:
|
|
233
|
-
ExpressionStatement?: (node:
|
|
234
|
-
ForInStatement?: (node:
|
|
235
|
-
ForOfStatement?: (node:
|
|
236
|
-
ForStatement?: (node:
|
|
237
|
-
FunctionDeclaration?: (node:
|
|
238
|
-
FunctionExpression?: (node:
|
|
239
|
-
Identifier?: (node:
|
|
240
|
-
IfStatement?: (node:
|
|
241
|
-
ImportDeclaration?: (node:
|
|
242
|
-
ImportDefaultSpecifier?: (node:
|
|
243
|
-
ImportExpression?: (node:
|
|
244
|
-
ImportNamespaceSpecifier?: (node:
|
|
245
|
-
ImportSpecifier?: (node:
|
|
246
|
-
LabeledStatement?: (node:
|
|
247
|
-
Literal?: (node:
|
|
248
|
-
LogicalExpression?: (node:
|
|
249
|
-
MemberExpression?: (node:
|
|
250
|
-
MetaProperty?: (node:
|
|
251
|
-
MethodDefinition?: (node:
|
|
252
|
-
NewExpression?: (node:
|
|
253
|
-
ObjectExpression?: (node:
|
|
254
|
-
ObjectPattern?: (node:
|
|
255
|
-
PrivateIdentifier?: (node:
|
|
256
|
-
Property?: (node:
|
|
257
|
-
PropertyDefinition?: (node:
|
|
258
|
-
RestElement?: (node:
|
|
259
|
-
ReturnStatement?: (node:
|
|
260
|
-
SequenceExpression?: (node:
|
|
261
|
-
SpreadElement?: (node:
|
|
262
|
-
Super?: (node:
|
|
263
|
-
SwitchCase?: (node:
|
|
264
|
-
SwitchStatement?: (node:
|
|
265
|
-
TaggedTemplateExpression?: (node:
|
|
266
|
-
TemplateElement?: (node:
|
|
267
|
-
TemplateLiteral?: (node:
|
|
268
|
-
ThisExpression?: (node:
|
|
269
|
-
ThrowStatement?: (node:
|
|
270
|
-
TryStatement?: (node:
|
|
271
|
-
UnaryExpression?: (node:
|
|
272
|
-
UpdateExpression?: (node:
|
|
273
|
-
VariableDeclaration?: (node:
|
|
274
|
-
VariableDeclarator?: (node:
|
|
275
|
-
WhileStatement?: (node:
|
|
276
|
-
WithStatement?: (node:
|
|
277
|
-
YieldExpression?: (node:
|
|
208
|
+
ArrayExpression?: (node: TSESTree.ArrayExpression & ASTNodeWithParent) => void;
|
|
209
|
+
ArrayPattern?: (node: TSESTree.ArrayPattern & ASTNodeWithParent) => void;
|
|
210
|
+
ArrowFunctionExpression?: (node: TSESTree.ArrowFunctionExpression & ASTNodeWithParent) => void;
|
|
211
|
+
AssignmentExpression?: (node: TSESTree.AssignmentExpression & ASTNodeWithParent) => void;
|
|
212
|
+
AssignmentPattern?: (node: TSESTree.AssignmentPattern & ASTNodeWithParent) => void;
|
|
213
|
+
AwaitExpression?: (node: TSESTree.AwaitExpression & ASTNodeWithParent) => void;
|
|
214
|
+
BinaryExpression?: (node: TSESTree.BinaryExpression & ASTNodeWithParent) => void;
|
|
215
|
+
BlockStatement?: (node: TSESTree.BlockStatement & ASTNodeWithParent) => void;
|
|
216
|
+
BreakStatement?: (node: TSESTree.BreakStatement & ASTNodeWithParent) => void;
|
|
217
|
+
CallExpression?: (node: TSESTree.CallExpression & ASTNodeWithParent) => void;
|
|
218
|
+
CatchClause?: (node: TSESTree.CatchClause & ASTNodeWithParent) => void;
|
|
219
|
+
ChainExpression?: (node: TSESTree.ChainExpression & ASTNodeWithParent) => void;
|
|
220
|
+
ClassBody?: (node: TSESTree.ClassBody & ASTNodeWithParent) => void;
|
|
221
|
+
ClassDeclaration?: (node: TSESTree.ClassDeclaration & ASTNodeWithParent) => void;
|
|
222
|
+
ClassExpression?: (node: TSESTree.ClassExpression & ASTNodeWithParent) => void;
|
|
223
|
+
ConditionalExpression?: (node: TSESTree.ConditionalExpression & ASTNodeWithParent) => void;
|
|
224
|
+
ContinueStatement?: (node: TSESTree.ContinueStatement & ASTNodeWithParent) => void;
|
|
225
|
+
DebuggerStatement?: (node: TSESTree.DebuggerStatement & ASTNodeWithParent) => void;
|
|
226
|
+
DoWhileStatement?: (node: TSESTree.DoWhileStatement & ASTNodeWithParent) => void;
|
|
227
|
+
EmptyStatement?: (node: TSESTree.EmptyStatement & ASTNodeWithParent) => void;
|
|
228
|
+
ExportAllDeclaration?: (node: TSESTree.ExportAllDeclaration & ASTNodeWithParent) => void;
|
|
229
|
+
ExportDefaultDeclaration?: (node: TSESTree.ExportDefaultDeclaration & ASTNodeWithParent) => void;
|
|
230
|
+
ExportNamedDeclaration?: (node: TSESTree.ExportNamedDeclaration & ASTNodeWithParent) => void;
|
|
231
|
+
ExportSpecifier?: (node: TSESTree.ExportSpecifier & ASTNodeWithParent) => void;
|
|
232
|
+
ExpressionStatement?: (node: TSESTree.ExpressionStatement & ASTNodeWithParent) => void;
|
|
233
|
+
ForInStatement?: (node: TSESTree.ForInStatement & ASTNodeWithParent) => void;
|
|
234
|
+
ForOfStatement?: (node: TSESTree.ForOfStatement & ASTNodeWithParent) => void;
|
|
235
|
+
ForStatement?: (node: TSESTree.ForStatement & ASTNodeWithParent) => void;
|
|
236
|
+
FunctionDeclaration?: (node: TSESTree.FunctionDeclaration & ASTNodeWithParent) => void;
|
|
237
|
+
FunctionExpression?: (node: TSESTree.FunctionExpression & ASTNodeWithParent) => void;
|
|
238
|
+
Identifier?: (node: TSESTree.Identifier & ASTNodeWithParent) => void;
|
|
239
|
+
IfStatement?: (node: TSESTree.IfStatement & ASTNodeWithParent) => void;
|
|
240
|
+
ImportDeclaration?: (node: TSESTree.ImportDeclaration & ASTNodeWithParent) => void;
|
|
241
|
+
ImportDefaultSpecifier?: (node: TSESTree.ImportDefaultSpecifier & ASTNodeWithParent) => void;
|
|
242
|
+
ImportExpression?: (node: TSESTree.ImportExpression & ASTNodeWithParent) => void;
|
|
243
|
+
ImportNamespaceSpecifier?: (node: TSESTree.ImportNamespaceSpecifier & ASTNodeWithParent) => void;
|
|
244
|
+
ImportSpecifier?: (node: TSESTree.ImportSpecifier & ASTNodeWithParent) => void;
|
|
245
|
+
LabeledStatement?: (node: TSESTree.LabeledStatement & ASTNodeWithParent) => void;
|
|
246
|
+
Literal?: (node: TSESTree.Literal & ASTNodeWithParent) => void;
|
|
247
|
+
LogicalExpression?: (node: TSESTree.LogicalExpression & ASTNodeWithParent) => void;
|
|
248
|
+
MemberExpression?: (node: TSESTree.MemberExpression & ASTNodeWithParent) => void;
|
|
249
|
+
MetaProperty?: (node: TSESTree.MetaProperty & ASTNodeWithParent) => void;
|
|
250
|
+
MethodDefinition?: (node: TSESTree.MethodDefinition & ASTNodeWithParent) => void;
|
|
251
|
+
NewExpression?: (node: TSESTree.NewExpression & ASTNodeWithParent) => void;
|
|
252
|
+
ObjectExpression?: (node: TSESTree.ObjectExpression & ASTNodeWithParent) => void;
|
|
253
|
+
ObjectPattern?: (node: TSESTree.ObjectPattern & ASTNodeWithParent) => void;
|
|
254
|
+
PrivateIdentifier?: (node: TSESTree.PrivateIdentifier & ASTNodeWithParent) => void;
|
|
255
|
+
Property?: (node: TSESTree.Property & ASTNodeWithParent) => void;
|
|
256
|
+
PropertyDefinition?: (node: TSESTree.PropertyDefinition & ASTNodeWithParent) => void;
|
|
257
|
+
RestElement?: (node: TSESTree.RestElement & ASTNodeWithParent) => void;
|
|
258
|
+
ReturnStatement?: (node: TSESTree.ReturnStatement & ASTNodeWithParent) => void;
|
|
259
|
+
SequenceExpression?: (node: TSESTree.SequenceExpression & ASTNodeWithParent) => void;
|
|
260
|
+
SpreadElement?: (node: TSESTree.SpreadElement & ASTNodeWithParent) => void;
|
|
261
|
+
Super?: (node: TSESTree.Super & ASTNodeWithParent) => void;
|
|
262
|
+
SwitchCase?: (node: TSESTree.SwitchCase & ASTNodeWithParent) => void;
|
|
263
|
+
SwitchStatement?: (node: TSESTree.SwitchStatement & ASTNodeWithParent) => void;
|
|
264
|
+
TaggedTemplateExpression?: (node: TSESTree.TaggedTemplateExpression & ASTNodeWithParent) => void;
|
|
265
|
+
TemplateElement?: (node: TSESTree.TemplateElement & ASTNodeWithParent) => void;
|
|
266
|
+
TemplateLiteral?: (node: TSESTree.TemplateLiteral & ASTNodeWithParent) => void;
|
|
267
|
+
ThisExpression?: (node: TSESTree.ThisExpression & ASTNodeWithParent) => void;
|
|
268
|
+
ThrowStatement?: (node: TSESTree.ThrowStatement & ASTNodeWithParent) => void;
|
|
269
|
+
TryStatement?: (node: TSESTree.TryStatement & ASTNodeWithParent) => void;
|
|
270
|
+
UnaryExpression?: (node: TSESTree.UnaryExpression & ASTNodeWithParent) => void;
|
|
271
|
+
UpdateExpression?: (node: TSESTree.UpdateExpression & ASTNodeWithParent) => void;
|
|
272
|
+
VariableDeclaration?: (node: TSESTree.VariableDeclaration & ASTNodeWithParent) => void;
|
|
273
|
+
VariableDeclarator?: (node: TSESTree.VariableDeclarator & ASTNodeWithParent) => void;
|
|
274
|
+
WhileStatement?: (node: TSESTree.WhileStatement & ASTNodeWithParent) => void;
|
|
275
|
+
WithStatement?: (node: TSESTree.WithStatement & ASTNodeWithParent) => void;
|
|
276
|
+
YieldExpression?: (node: TSESTree.YieldExpression & ASTNodeWithParent) => void;
|
|
278
277
|
Program?: (node: AST.SvelteProgram & ASTNodeWithParent) => void;
|
|
279
278
|
SvelteReactiveStatement?: (node: AST.SvelteReactiveStatement & ASTNodeWithParent) => void;
|
|
280
279
|
};
|
package/lib/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { JSONSchema4 } from "json-schema";
|
|
2
2
|
import type { Linter, Rule, Scope, SourceCode as ESLintSourceCode } from "eslint";
|
|
3
3
|
import type { AST } from "svelte-eslint-parser";
|
|
4
|
-
import type
|
|
4
|
+
import type { TSESTree } from "@typescript-eslint/types";
|
|
5
5
|
import type { ASTNode, ASTNodeWithParent, ASTNodeListener } from "./types-for-node";
|
|
6
6
|
export type { ASTNode, ASTNodeWithParent, ASTNodeListener };
|
|
7
7
|
export interface RuleListener extends ASTNodeListener {
|
|
@@ -80,7 +80,7 @@ export declare type RuleContext = {
|
|
|
80
80
|
id: string;
|
|
81
81
|
options: any[];
|
|
82
82
|
settings?: {
|
|
83
|
-
|
|
83
|
+
svelte?: {
|
|
84
84
|
ignoreWarnings?: unknown;
|
|
85
85
|
compileOptions?: {
|
|
86
86
|
babel?: boolean;
|
|
@@ -88,13 +88,18 @@ export declare type RuleContext = {
|
|
|
88
88
|
configFilePath?: unknown;
|
|
89
89
|
};
|
|
90
90
|
};
|
|
91
|
+
kit?: {
|
|
92
|
+
files?: {
|
|
93
|
+
routes?: string;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
91
96
|
};
|
|
92
97
|
};
|
|
93
98
|
parserPath: string;
|
|
94
99
|
parserOptions: Linter.ParserOptions;
|
|
95
100
|
parserServices: ESLintSourceCode.ParserServices;
|
|
96
101
|
getAncestors(): ASTNode[];
|
|
97
|
-
getDeclaredVariables(node:
|
|
102
|
+
getDeclaredVariables(node: TSESTree.Node): Scope.Variable[];
|
|
98
103
|
getFilename(): string;
|
|
99
104
|
getScope(): Scope.Scope;
|
|
100
105
|
getSourceCode(): SourceCode;
|
package/lib/utils/ast-utils.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { ASTNode, RuleContext, SourceCode } from "../types";
|
|
2
|
-
import type * as ESTree from "estree";
|
|
3
2
|
import type { TSESTree } from "@typescript-eslint/types";
|
|
4
3
|
import type { AST as SvAST } from "svelte-eslint-parser";
|
|
5
4
|
import type { Scope } from "eslint";
|
|
6
5
|
export declare function equalTokens(left: ASTNode, right: ASTNode, sourceCode: SourceCode): boolean;
|
|
7
|
-
export declare function getStringIfConstant(node:
|
|
8
|
-
export declare function needParentheses(node:
|
|
6
|
+
export declare function getStringIfConstant(node: TSESTree.Expression | TSESTree.PrivateIdentifier): string | null;
|
|
7
|
+
export declare function needParentheses(node: TSESTree.Expression, kind: "not" | "logical"): boolean;
|
|
9
8
|
export declare function isHTMLElementLike(node: SvAST.SvelteElement | SvAST.SvelteScriptElement | SvAST.SvelteStyleElement): node is SvAST.SvelteHTMLElement | (SvAST.SvelteSpecialElement & {
|
|
10
9
|
name: SvAST.SvelteName & {
|
|
11
10
|
name: "svelte:element";
|
|
@@ -30,8 +29,9 @@ export declare function findBindDirective<N extends string>(node: SvAST.SvelteEl
|
|
|
30
29
|
}) | null;
|
|
31
30
|
export declare function getStaticAttributeValue(node: SvAST.SvelteAttribute): string | null;
|
|
32
31
|
export declare function getLangValue(node: SvAST.SvelteScriptElement | SvAST.SvelteStyleElement): string | null;
|
|
33
|
-
export declare function findVariable(context: RuleContext, node:
|
|
34
|
-
export declare function getScope(context: RuleContext, currentNode:
|
|
32
|
+
export declare function findVariable(context: RuleContext, node: TSESTree.Identifier): Scope.Variable | null;
|
|
33
|
+
export declare function getScope(context: RuleContext, currentNode: TSESTree.Node): Scope.Scope;
|
|
34
|
+
export declare function getParent(node: TSESTree.Node): TSESTree.Node | null;
|
|
35
35
|
export declare type QuoteAndRange = {
|
|
36
36
|
quote: "unquoted" | "double" | "single";
|
|
37
37
|
range: [number, number];
|
package/lib/utils/ast-utils.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.isExpressionIdentifier = exports.isVoidHtmlElement = exports.getNodeName = exports.getDirectiveName = exports.getAttributeKeyText = exports.getMustacheTokens = exports.getAttributeValueQuoteAndRange = exports.getScope = exports.findVariable = exports.getLangValue = exports.getStaticAttributeValue = exports.findBindDirective = exports.findShorthandAttribute = exports.findAttribute = exports.isHTMLElementLike = exports.needParentheses = exports.getStringIfConstant = exports.equalTokens = void 0;
|
|
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
30
|
const eslintUtils = __importStar(require("eslint-utils"));
|
|
31
31
|
const void_elements_1 = __importDefault(require("./void-elements"));
|
|
32
32
|
function equalTokens(left, right, sourceCode) {
|
|
@@ -194,6 +194,10 @@ function getScope(context, currentNode) {
|
|
|
194
194
|
return scopeManager.scopes[0];
|
|
195
195
|
}
|
|
196
196
|
exports.getScope = getScope;
|
|
197
|
+
function getParent(node) {
|
|
198
|
+
return node.parent || null;
|
|
199
|
+
}
|
|
200
|
+
exports.getParent = getParent;
|
|
197
201
|
function getAttributeValueQuoteAndRange(attr, sourceCode) {
|
|
198
202
|
const valueTokens = getAttributeValueRangeTokens(attr, sourceCode);
|
|
199
203
|
if (valueTokens == null) {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCache = void 0;
|
|
4
|
+
const SKIP_TIME = 5000;
|
|
5
|
+
function createCache() {
|
|
6
|
+
const map = new Map();
|
|
7
|
+
function get(key) {
|
|
8
|
+
const entry = map.get(key);
|
|
9
|
+
const now = Date.now();
|
|
10
|
+
if (entry) {
|
|
11
|
+
if (entry.expire > now) {
|
|
12
|
+
entry.expire = now + SKIP_TIME;
|
|
13
|
+
return entry.value;
|
|
14
|
+
}
|
|
15
|
+
map.delete(key);
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
function set(key, value) {
|
|
20
|
+
const entry = map.get(key);
|
|
21
|
+
const expire = Date.now() + SKIP_TIME;
|
|
22
|
+
if (entry) {
|
|
23
|
+
entry.value = value;
|
|
24
|
+
entry.expire = expire;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
map.set(key, { value, expire });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return { get, set };
|
|
31
|
+
}
|
|
32
|
+
exports.createCache = createCache;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { AST } from "svelte-eslint-parser";
|
|
2
2
|
import type { RuleContext } from "../../types";
|
|
3
|
-
import type
|
|
3
|
+
import type { TSESTree } from "@typescript-eslint/types";
|
|
4
4
|
export declare function parseStyleAttributeValue(node: AST.SvelteAttribute, context: RuleContext): SvelteStyleRoot<AST.SvelteMustacheTagText> | null;
|
|
5
|
-
export declare type SvelteStyleInterpolation = AST.SvelteMustacheTagText |
|
|
5
|
+
export declare type SvelteStyleInterpolation = AST.SvelteMustacheTagText | TSESTree.Expression;
|
|
6
6
|
export interface SvelteStyleNode<E extends SvelteStyleInterpolation> {
|
|
7
7
|
nodes?: SvelteStyleChildNode<E>[];
|
|
8
8
|
range: AST.Range;
|
|
@@ -15,8 +15,8 @@ export interface SvelteStyleRoot<E extends SvelteStyleInterpolation = SvelteStyl
|
|
|
15
15
|
export interface SvelteStyleInline<E extends SvelteStyleInterpolation = SvelteStyleInterpolation> extends SvelteStyleNode<E> {
|
|
16
16
|
type: "inline";
|
|
17
17
|
node: E;
|
|
18
|
-
getInlineStyle(node:
|
|
19
|
-
getAllInlineStyles(): Map<
|
|
18
|
+
getInlineStyle(node: TSESTree.Expression): SvelteStyleRoot<TSESTree.Expression> | null;
|
|
19
|
+
getAllInlineStyles(): Map<TSESTree.Expression, SvelteStyleRoot<TSESTree.Expression>>;
|
|
20
20
|
}
|
|
21
21
|
export interface SvelteStyleDeclaration<E extends SvelteStyleInterpolation = SvelteStyleInterpolation> extends SvelteStyleNode<E> {
|
|
22
22
|
type: "decl";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RuleListener, RuleContext, RuleModule } from "../types";
|
|
2
|
-
import type
|
|
2
|
+
import type { TSESTree } from "@typescript-eslint/types";
|
|
3
3
|
import type { AST as SvAST } from "svelte-eslint-parser";
|
|
4
4
|
export declare function defineWrapperListener(coreRule: RuleModule, context: RuleContext, proxyOptions: {
|
|
5
5
|
createListenerProxy?: (listener: RuleListener) => RuleListener;
|
|
@@ -7,7 +7,7 @@ export declare function defineWrapperListener(coreRule: RuleModule, context: Rul
|
|
|
7
7
|
export declare function getProxyNode(node: {
|
|
8
8
|
type: string;
|
|
9
9
|
}, properties: any): any;
|
|
10
|
-
export declare function buildProxyListener(base: RuleListener, convertNode: (node: SvAST.SvelteNode | (
|
|
11
|
-
parent: SvAST.SvelteNode |
|
|
10
|
+
export declare function buildProxyListener(base: RuleListener, convertNode: (node: SvAST.SvelteNode | (TSESTree.Node & {
|
|
11
|
+
parent: SvAST.SvelteNode | TSESTree.Node | null;
|
|
12
12
|
})) => any): RuleListener;
|
|
13
13
|
export declare function getCoreRule(ruleName: string): RuleModule;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getPackageJson = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const cache_1 = require("./cache");
|
|
10
|
+
const isRunOnBrowser = !fs_1.default.readFileSync;
|
|
11
|
+
const cache = (0, cache_1.createCache)();
|
|
12
|
+
function readPackageJson(dir) {
|
|
13
|
+
if (isRunOnBrowser)
|
|
14
|
+
return null;
|
|
15
|
+
const filePath = path_1.default.join(dir, "package.json");
|
|
16
|
+
try {
|
|
17
|
+
const text = fs_1.default.readFileSync(filePath, "utf8");
|
|
18
|
+
const data = JSON.parse(text);
|
|
19
|
+
if (typeof data === "object" && data !== null) {
|
|
20
|
+
data.filePath = filePath;
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
catch (_err) {
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
function getPackageJson(startPath = "a.js") {
|
|
29
|
+
if (isRunOnBrowser)
|
|
30
|
+
return null;
|
|
31
|
+
const startDir = path_1.default.dirname(path_1.default.resolve(startPath));
|
|
32
|
+
let dir = startDir;
|
|
33
|
+
let prevDir = "";
|
|
34
|
+
let data = null;
|
|
35
|
+
do {
|
|
36
|
+
data = cache.get(dir);
|
|
37
|
+
if (data) {
|
|
38
|
+
if (dir !== startDir) {
|
|
39
|
+
cache.set(startDir, data);
|
|
40
|
+
}
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
data = readPackageJson(dir);
|
|
44
|
+
if (data) {
|
|
45
|
+
cache.set(dir, data);
|
|
46
|
+
cache.set(startDir, data);
|
|
47
|
+
return data;
|
|
48
|
+
}
|
|
49
|
+
prevDir = dir;
|
|
50
|
+
dir = path_1.default.resolve(dir, "..");
|
|
51
|
+
} while (dir !== prevDir);
|
|
52
|
+
cache.set(startDir, null);
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
exports.getPackageJson = getPackageJson;
|
package/lib/utils/rules.js
CHANGED
|
@@ -20,6 +20,7 @@ const no_at_html_tags_1 = __importDefault(require("../rules/no-at-html-tags"));
|
|
|
20
20
|
const no_dupe_else_if_blocks_1 = __importDefault(require("../rules/no-dupe-else-if-blocks"));
|
|
21
21
|
const no_dupe_style_properties_1 = __importDefault(require("../rules/no-dupe-style-properties"));
|
|
22
22
|
const no_dynamic_slot_name_1 = __importDefault(require("../rules/no-dynamic-slot-name"));
|
|
23
|
+
const no_export_load_in_svelte_module_in_kit_pages_1 = __importDefault(require("../rules/no-export-load-in-svelte-module-in-kit-pages"));
|
|
23
24
|
const no_extra_reactive_curlies_1 = __importDefault(require("../rules/no-extra-reactive-curlies"));
|
|
24
25
|
const no_inner_declarations_1 = __importDefault(require("../rules/no-inner-declarations"));
|
|
25
26
|
const no_not_function_handler_1 = __importDefault(require("../rules/no-not-function-handler"));
|
|
@@ -38,6 +39,8 @@ const prefer_class_directive_1 = __importDefault(require("../rules/prefer-class-
|
|
|
38
39
|
const prefer_destructured_store_props_1 = __importDefault(require("../rules/prefer-destructured-store-props"));
|
|
39
40
|
const prefer_style_directive_1 = __importDefault(require("../rules/prefer-style-directive"));
|
|
40
41
|
const require_optimized_style_attribute_1 = __importDefault(require("../rules/require-optimized-style-attribute"));
|
|
42
|
+
const require_store_callbacks_use_set_param_1 = __importDefault(require("../rules/require-store-callbacks-use-set-param"));
|
|
43
|
+
const require_store_reactive_access_1 = __importDefault(require("../rules/require-store-reactive-access"));
|
|
41
44
|
const require_stores_init_1 = __importDefault(require("../rules/require-stores-init"));
|
|
42
45
|
const shorthand_attribute_1 = __importDefault(require("../rules/shorthand-attribute"));
|
|
43
46
|
const shorthand_directive_1 = __importDefault(require("../rules/shorthand-directive"));
|
|
@@ -45,6 +48,7 @@ const sort_attributes_1 = __importDefault(require("../rules/sort-attributes"));
|
|
|
45
48
|
const spaced_html_comment_1 = __importDefault(require("../rules/spaced-html-comment"));
|
|
46
49
|
const system_1 = __importDefault(require("../rules/system"));
|
|
47
50
|
const valid_compile_1 = __importDefault(require("../rules/valid-compile"));
|
|
51
|
+
const valid_prop_names_in_kit_pages_1 = __importDefault(require("../rules/valid-prop-names-in-kit-pages"));
|
|
48
52
|
exports.rules = [
|
|
49
53
|
no_unnecessary_condition_1.default,
|
|
50
54
|
button_has_type_1.default,
|
|
@@ -62,6 +66,7 @@ exports.rules = [
|
|
|
62
66
|
no_dupe_else_if_blocks_1.default,
|
|
63
67
|
no_dupe_style_properties_1.default,
|
|
64
68
|
no_dynamic_slot_name_1.default,
|
|
69
|
+
no_export_load_in_svelte_module_in_kit_pages_1.default,
|
|
65
70
|
no_extra_reactive_curlies_1.default,
|
|
66
71
|
no_inner_declarations_1.default,
|
|
67
72
|
no_not_function_handler_1.default,
|
|
@@ -80,6 +85,8 @@ exports.rules = [
|
|
|
80
85
|
prefer_destructured_store_props_1.default,
|
|
81
86
|
prefer_style_directive_1.default,
|
|
82
87
|
require_optimized_style_attribute_1.default,
|
|
88
|
+
require_store_callbacks_use_set_param_1.default,
|
|
89
|
+
require_store_reactive_access_1.default,
|
|
83
90
|
require_stores_init_1.default,
|
|
84
91
|
shorthand_attribute_1.default,
|
|
85
92
|
shorthand_directive_1.default,
|
|
@@ -87,4 +94,5 @@ exports.rules = [
|
|
|
87
94
|
spaced_html_comment_1.default,
|
|
88
95
|
system_1.default,
|
|
89
96
|
valid_compile_1.default,
|
|
97
|
+
valid_prop_names_in_kit_pages_1.default,
|
|
90
98
|
];
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isKitPageComponent = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const get_package_json_1 = require("./get-package-json");
|
|
10
|
+
const isRunOnBrowser = !fs_1.default.readFileSync;
|
|
11
|
+
function isKitPageComponent(context) {
|
|
12
|
+
if (isRunOnBrowser)
|
|
13
|
+
return true;
|
|
14
|
+
if (!hasSvelteKit(context.getFilename()))
|
|
15
|
+
return false;
|
|
16
|
+
const routes = context.settings?.svelte?.kit?.files?.routes?.replace(/^\//, "") ??
|
|
17
|
+
"src/routes";
|
|
18
|
+
const filePath = context.getFilename();
|
|
19
|
+
const projectRootDir = getProjectRootDir(context.getFilename()) ?? "";
|
|
20
|
+
const fileName = filePath.split("/").pop() || filePath;
|
|
21
|
+
return (filePath.startsWith(path_1.default.join(projectRootDir, routes)) &&
|
|
22
|
+
Boolean(/^\+.+\.svelte$/.test(fileName)));
|
|
23
|
+
}
|
|
24
|
+
exports.isKitPageComponent = isKitPageComponent;
|
|
25
|
+
function hasSvelteKit(filePath) {
|
|
26
|
+
if (isRunOnBrowser)
|
|
27
|
+
return true;
|
|
28
|
+
try {
|
|
29
|
+
const packageJson = (0, get_package_json_1.getPackageJson)(filePath);
|
|
30
|
+
if (!packageJson)
|
|
31
|
+
return false;
|
|
32
|
+
if (packageJson.name === "eslint-plugin-svelte")
|
|
33
|
+
return true;
|
|
34
|
+
return Boolean(packageJson.dependencies["@sveltejs/kit"] ??
|
|
35
|
+
packageJson.devDependencies["@sveltejs/kit"]);
|
|
36
|
+
}
|
|
37
|
+
catch (_e) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function getProjectRootDir(filePath) {
|
|
42
|
+
if (isRunOnBrowser)
|
|
43
|
+
return null;
|
|
44
|
+
const packageJsonFilePath = (0, get_package_json_1.getPackageJson)(filePath)?.filePath;
|
|
45
|
+
if (!packageJsonFilePath)
|
|
46
|
+
return null;
|
|
47
|
+
return path_1.default.dirname(path_1.default.resolve(packageJsonFilePath));
|
|
48
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-svelte",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.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",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"docs:build": "yarn svelte-kit build",
|
|
35
35
|
"docs:preview": "yarn svelte-kit preview",
|
|
36
36
|
"docs:watch": "yarn svelte-kit dev",
|
|
37
|
-
"format-for-gen-file": "eslint src/types-for-node.ts src/utils/rules.ts src/configs --fix",
|
|
37
|
+
"format-for-gen-file": "eslint src/types-for-node.ts src/utils/rules.ts src/configs typings/estree/index.d.ts --fix",
|
|
38
38
|
"install-with-ignore-engines": "yarn --ignore-engines",
|
|
39
39
|
"lint": "run-p lint:*",
|
|
40
40
|
"lint-fix": "yarn lint:es --fix && yarn lint:style --fix",
|
|
@@ -68,12 +68,12 @@
|
|
|
68
68
|
"debug": "^4.3.1",
|
|
69
69
|
"eslint-utils": "^3.0.0",
|
|
70
70
|
"esutils": "^2.0.3",
|
|
71
|
-
"known-css-properties": "^0.
|
|
71
|
+
"known-css-properties": "^0.26.0",
|
|
72
72
|
"postcss": "^8.4.5",
|
|
73
73
|
"postcss-load-config": "^3.1.4",
|
|
74
74
|
"postcss-safe-parser": "^6.0.0",
|
|
75
75
|
"sourcemap-codec": "^1.4.8",
|
|
76
|
-
"svelte-eslint-parser": "^0.
|
|
76
|
+
"svelte-eslint-parser": "^0.20.0"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@1stg/browserslist-config": "^1.2.3",
|
|
@@ -100,7 +100,6 @@
|
|
|
100
100
|
"@types/eslint-scope": "^3.7.0",
|
|
101
101
|
"@types/eslint-utils": "^3.0.1",
|
|
102
102
|
"@types/eslint-visitor-keys": "^1.0.0",
|
|
103
|
-
"@types/estree": "^1.0.0",
|
|
104
103
|
"@types/esutils": "^2.0.0",
|
|
105
104
|
"@types/less": "^3.0.3",
|
|
106
105
|
"@types/markdown-it": "^12.2.3",
|
|
@@ -131,10 +130,10 @@
|
|
|
131
130
|
"eslint-plugin-markdown": "^3.0.0",
|
|
132
131
|
"eslint-plugin-mdx": "^2.0.2",
|
|
133
132
|
"eslint-plugin-node": "^11.1.0",
|
|
134
|
-
"eslint-plugin-node-dependencies": "^0.
|
|
133
|
+
"eslint-plugin-node-dependencies": "^0.10.0",
|
|
135
134
|
"eslint-plugin-prettier": "^4.0.0",
|
|
136
135
|
"eslint-plugin-regexp": "^1.0.0",
|
|
137
|
-
"eslint-plugin-svelte": "^2.
|
|
136
|
+
"eslint-plugin-svelte": "^2.11.0",
|
|
138
137
|
"eslint-plugin-yml": "^1.0.0",
|
|
139
138
|
"eslint-scope": "^7.1.1",
|
|
140
139
|
"estree-walker": "^3.0.0",
|
|
@@ -163,6 +162,7 @@
|
|
|
163
162
|
"stylus": "^0.59.0",
|
|
164
163
|
"svelte": "^3.46.1",
|
|
165
164
|
"svelte-adapter-ghpages": "0.0.2",
|
|
165
|
+
"svelte-i18n": "^3.4.0",
|
|
166
166
|
"type-coverage": "^2.22.0",
|
|
167
167
|
"typescript": "^4.5.2",
|
|
168
168
|
"vite": "^3.1.0-0",
|
|
@@ -174,7 +174,7 @@
|
|
|
174
174
|
"access": "public"
|
|
175
175
|
},
|
|
176
176
|
"typeCoverage": {
|
|
177
|
-
"atLeast": 98.
|
|
177
|
+
"atLeast": 98.72,
|
|
178
178
|
"cache": true,
|
|
179
179
|
"detail": true,
|
|
180
180
|
"ignoreAsAssertion": true,
|