eslint-plugin-svelte 2.33.2 → 2.34.1
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
CHANGED
|
@@ -340,6 +340,7 @@ These rules relate to better ways of doing things to help you avoid problems:
|
|
|
340
340
|
| [svelte/block-lang](https://sveltejs.github.io/eslint-plugin-svelte/rules/block-lang/) | disallows the use of languages other than those specified in the configuration for the lang attribute of `<script>` and `<style>` blocks. | |
|
|
341
341
|
| [svelte/button-has-type](https://sveltejs.github.io/eslint-plugin-svelte/rules/button-has-type/) | disallow usage of button without an explicit type attribute | |
|
|
342
342
|
| [svelte/no-at-debug-tags](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-at-debug-tags/) | disallow the use of `{@debug}` | :star: |
|
|
343
|
+
| [svelte/no-ignored-unsubscribe](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-ignored-unsubscribe/) | disallow ignoring the unsubscribe method returned by the `subscribe()` on Svelte stores. | |
|
|
343
344
|
| [svelte/no-immutable-reactive-statements](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-immutable-reactive-statements/) | disallow reactive statements that don't reference reactive values. | |
|
|
344
345
|
| [svelte/no-reactive-functions](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-reactive-functions/) | it's not necessary to define functions in reactive statements | :bulb: |
|
|
345
346
|
| [svelte/no-reactive-literals](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-reactive-literals/) | don't assign literal values in reactive statements | :bulb: |
|
package/lib/meta.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name: "eslint-plugin-svelte";
|
|
2
|
-
export declare const version: "2.
|
|
2
|
+
export declare const version: "2.34.1";
|
package/lib/meta.js
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("../utils");
|
|
4
|
+
exports.default = (0, utils_1.createRule)('no-ignored-unsubscribe', {
|
|
5
|
+
meta: {
|
|
6
|
+
docs: {
|
|
7
|
+
description: 'disallow ignoring the unsubscribe method returned by the `subscribe()` on Svelte stores.',
|
|
8
|
+
category: 'Best Practices',
|
|
9
|
+
recommended: false
|
|
10
|
+
},
|
|
11
|
+
fixable: undefined,
|
|
12
|
+
hasSuggestions: false,
|
|
13
|
+
messages: {
|
|
14
|
+
forbidden: 'Ignoring returned value of the subscribe method is forbidden.'
|
|
15
|
+
},
|
|
16
|
+
schema: [],
|
|
17
|
+
type: 'problem'
|
|
18
|
+
},
|
|
19
|
+
create: (context) => {
|
|
20
|
+
return {
|
|
21
|
+
"ExpressionStatement > CallExpression > MemberExpression.callee[property.name='subscribe']": (node) => {
|
|
22
|
+
context.report({
|
|
23
|
+
messageId: 'forbidden',
|
|
24
|
+
node: node.property
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
});
|
|
@@ -89,7 +89,7 @@ function getSvelteCompileWarningsWithoutCache(context) {
|
|
|
89
89
|
const text = buildStrippedText(context, ignoreComments, stripStyleTokens);
|
|
90
90
|
transformResults.push(...transformScripts(context, text));
|
|
91
91
|
if (!transformResults.length) {
|
|
92
|
-
const warnings = getWarningsFromCode(text);
|
|
92
|
+
const warnings = getWarningsFromCode(text, context);
|
|
93
93
|
return {
|
|
94
94
|
...processIgnore(warnings.warnings, warnings.kind, stripStyleElements, ignoreComments, context),
|
|
95
95
|
kind: warnings.kind,
|
|
@@ -209,7 +209,7 @@ function getSvelteCompileWarningsWithoutCache(context) {
|
|
|
209
209
|
remapContext.appendTranspile(result);
|
|
210
210
|
}
|
|
211
211
|
const code = remapContext.postprocess();
|
|
212
|
-
const baseWarnings = getWarningsFromCode(code);
|
|
212
|
+
const baseWarnings = getWarningsFromCode(code, context);
|
|
213
213
|
const warnings = [];
|
|
214
214
|
for (const warn of baseWarnings.warnings) {
|
|
215
215
|
let loc = null;
|
|
@@ -287,11 +287,26 @@ function* transformScripts(context, text) {
|
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
|
-
function
|
|
290
|
+
function hasTagOption(program) {
|
|
291
|
+
return program.body.some((body) => {
|
|
292
|
+
if (body.type !== 'SvelteElement' || body.kind !== 'special') {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
if (body.name.name !== 'svelte:options') {
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
return Boolean((0, ast_utils_1.findAttribute)(body, 'tag'));
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
function getWarningsFromCode(code, context) {
|
|
291
302
|
try {
|
|
292
303
|
const result = compiler.compile(code, {
|
|
293
304
|
generate: false,
|
|
294
|
-
...(semver_1.default.satisfies(compiler.VERSION, '>=4.0.0-0')
|
|
305
|
+
...(semver_1.default.satisfies(compiler.VERSION, '>=4.0.0-0')
|
|
306
|
+
? { customElement: true }
|
|
307
|
+
: hasTagOption(context.getSourceCode().ast)
|
|
308
|
+
? { customElement: true }
|
|
309
|
+
: {})
|
|
295
310
|
});
|
|
296
311
|
return { warnings: result.warnings, kind: 'warn' };
|
|
297
312
|
}
|
package/lib/utils/rules.js
CHANGED
|
@@ -29,6 +29,7 @@ const no_dupe_use_directives_1 = __importDefault(require("../rules/no-dupe-use-d
|
|
|
29
29
|
const no_dynamic_slot_name_1 = __importDefault(require("../rules/no-dynamic-slot-name"));
|
|
30
30
|
const no_export_load_in_svelte_module_in_kit_pages_1 = __importDefault(require("../rules/no-export-load-in-svelte-module-in-kit-pages"));
|
|
31
31
|
const no_extra_reactive_curlies_1 = __importDefault(require("../rules/no-extra-reactive-curlies"));
|
|
32
|
+
const no_ignored_unsubscribe_1 = __importDefault(require("../rules/no-ignored-unsubscribe"));
|
|
32
33
|
const no_immutable_reactive_statements_1 = __importDefault(require("../rules/no-immutable-reactive-statements"));
|
|
33
34
|
const no_inner_declarations_1 = __importDefault(require("../rules/no-inner-declarations"));
|
|
34
35
|
const no_not_function_handler_1 = __importDefault(require("../rules/no-not-function-handler"));
|
|
@@ -89,6 +90,7 @@ exports.rules = [
|
|
|
89
90
|
no_dynamic_slot_name_1.default,
|
|
90
91
|
no_export_load_in_svelte_module_in_kit_pages_1.default,
|
|
91
92
|
no_extra_reactive_curlies_1.default,
|
|
93
|
+
no_ignored_unsubscribe_1.default,
|
|
92
94
|
no_immutable_reactive_statements_1.default,
|
|
93
95
|
no_inner_declarations_1.default,
|
|
94
96
|
no_not_function_handler_1.default,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-svelte",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.34.1",
|
|
4
4
|
"description": "ESLint plugin for Svelte using AST",
|
|
5
5
|
"repository": "git+https://github.com/sveltejs/eslint-plugin-svelte.git",
|
|
6
6
|
"homepage": "https://sveltejs.github.io/eslint-plugin-svelte",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@jridgewell/sourcemap-codec": "^1.4.14",
|
|
40
40
|
"debug": "^4.3.1",
|
|
41
41
|
"esutils": "^2.0.3",
|
|
42
|
-
"known-css-properties": "^0.
|
|
42
|
+
"known-css-properties": "^0.29.0",
|
|
43
43
|
"postcss": "^8.4.5",
|
|
44
44
|
"postcss-load-config": "^3.1.4",
|
|
45
45
|
"postcss-safe-parser": "^6.0.0",
|
|
@@ -76,13 +76,13 @@
|
|
|
76
76
|
"@types/markdown-it-container": "^2.0.5",
|
|
77
77
|
"@types/markdown-it-emoji": "^2.0.2",
|
|
78
78
|
"@types/mocha": "^10.0.0",
|
|
79
|
-
"@types/node": "^
|
|
79
|
+
"@types/node": "^20.0.0",
|
|
80
80
|
"@types/postcss-safe-parser": "^5.0.1",
|
|
81
81
|
"@types/prismjs": "^1.26.0",
|
|
82
82
|
"@types/semver": "^7.5.0",
|
|
83
83
|
"@types/stylus": "^0.48.38",
|
|
84
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
85
|
-
"@typescript-eslint/parser": "^6.
|
|
84
|
+
"@typescript-eslint/eslint-plugin": "^6.9.0",
|
|
85
|
+
"@typescript-eslint/parser": "^6.9.0",
|
|
86
86
|
"@typescript/vfs": "^1.4.0",
|
|
87
87
|
"acorn": "^8.8.2",
|
|
88
88
|
"assert": "^2.0.0",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"eslint-plugin-n": "^16.0.0",
|
|
104
104
|
"eslint-plugin-node-dependencies": "^0.11.0",
|
|
105
105
|
"eslint-plugin-prettier": "^5.0.0",
|
|
106
|
-
"eslint-plugin-regexp": "^
|
|
106
|
+
"eslint-plugin-regexp": "^2.0.0",
|
|
107
107
|
"eslint-plugin-svelte": "^2.28.0",
|
|
108
108
|
"eslint-plugin-yml": "^1.0.0",
|
|
109
109
|
"eslint-scope": "^7.1.1",
|
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
"stylus": "^0.60.0",
|
|
135
135
|
"svelte": "^4.0.0",
|
|
136
136
|
"svelte-adapter-ghpages": "0.1.0",
|
|
137
|
-
"svelte-i18n": "^
|
|
137
|
+
"svelte-i18n": "^4.0.0",
|
|
138
138
|
"tslib": "^2.5.0",
|
|
139
139
|
"type-coverage": "^2.22.0",
|
|
140
140
|
"typescript": "~5.1.0",
|