eslint-plugin-svelte 3.9.2 → 3.9.3
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/main.d.ts +1 -1
- package/lib/meta.d.ts +1 -1
- package/lib/meta.js +1 -1
- package/lib/rules/no-top-level-browser-globals.js +17 -0
- package/package.json +3 -3
package/lib/main.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare const configs: {
|
|
|
14
14
|
export declare const rules: Record<string, Rule.RuleModule>;
|
|
15
15
|
export declare const meta: {
|
|
16
16
|
name: "eslint-plugin-svelte";
|
|
17
|
-
version: "3.9.
|
|
17
|
+
version: "3.9.3";
|
|
18
18
|
};
|
|
19
19
|
export declare const processors: {
|
|
20
20
|
'.svelte': typeof processor;
|
package/lib/meta.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name: "eslint-plugin-svelte";
|
|
2
|
-
export declare const version: "3.9.
|
|
2
|
+
export declare const version: "3.9.3";
|
package/lib/meta.js
CHANGED
|
@@ -104,6 +104,7 @@ export default createRule('no-top-level-browser-globals', {
|
|
|
104
104
|
}
|
|
105
105
|
return {
|
|
106
106
|
':function': enterFunction,
|
|
107
|
+
SvelteSnippetBlock: enterFunction,
|
|
107
108
|
'*.typeAnnotation': enterTypeAnnotation,
|
|
108
109
|
MetaProperty: enterMetaProperty,
|
|
109
110
|
'Program:exit': verifyGlobalReferences
|
|
@@ -294,6 +295,22 @@ export default createRule('no-top-level-browser-globals', {
|
|
|
294
295
|
if (parent.type === 'UnaryExpression' && parent.operator === '!') {
|
|
295
296
|
return getGuardChecker({ not: !guardInfo.not, node: parent });
|
|
296
297
|
}
|
|
298
|
+
if (parent.type === 'SvelteIfBlock' && parent.expression === guardInfo.node) {
|
|
299
|
+
if (!guardInfo.not) {
|
|
300
|
+
if (parent.children.length === 0) {
|
|
301
|
+
return null; // No block to check
|
|
302
|
+
}
|
|
303
|
+
const first = parent.children[0];
|
|
304
|
+
const last = parent.children.at(-1);
|
|
305
|
+
return (n) => first.range[0] <= n.range[0] && n.range[1] <= last.range[1];
|
|
306
|
+
}
|
|
307
|
+
// not
|
|
308
|
+
if (parent.else) {
|
|
309
|
+
const block = parent.else;
|
|
310
|
+
return (n) => block.range[0] <= n.range[0] && n.range[1] <= block.range[1];
|
|
311
|
+
}
|
|
312
|
+
return null;
|
|
313
|
+
}
|
|
297
314
|
if (parent.type === 'IfStatement' && parent.test === guardInfo.node) {
|
|
298
315
|
if (!guardInfo.not) {
|
|
299
316
|
const block = parent.consequent;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-svelte",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.3",
|
|
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",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@jridgewell/sourcemap-codec": "^1.5.0",
|
|
37
37
|
"esutils": "^2.0.3",
|
|
38
38
|
"globals": "^16.0.0",
|
|
39
|
-
"known-css-properties": "^0.
|
|
39
|
+
"known-css-properties": "^0.37.0",
|
|
40
40
|
"postcss": "^8.4.49",
|
|
41
41
|
"postcss-load-config": "^3.1.4",
|
|
42
42
|
"postcss-safe-parser": "^7.0.0",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"eslint-visitor-keys": "^4.2.0",
|
|
67
67
|
"espree": "^10.3.0",
|
|
68
68
|
"less": "^4.2.1",
|
|
69
|
-
"mocha": "
|
|
69
|
+
"mocha": "~11.6.0",
|
|
70
70
|
"postcss-nested": "^7.0.2",
|
|
71
71
|
"postcss-selector-parser": "^7.0.0",
|
|
72
72
|
"sass": "^1.81.0",
|