eslint-plugin-svelte 3.13.0 → 3.13.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/lib/main.d.ts +1 -1
- package/lib/meta.d.ts +1 -1
- package/lib/meta.js +1 -1
- package/lib/rules/indent-helpers/ts.js +15 -5
- package/lib/rules/prefer-destructured-store-props.js +6 -0
- package/lib/shared/runes.d.ts +1 -0
- package/lib/shared/runes.js +9 -0
- package/lib/shared/svelte-compile-warns/index.js +11 -0
- package/package.json +7 -7
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.13.
|
|
17
|
+
version: "3.13.1";
|
|
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.13.
|
|
2
|
+
export declare const version: "3.13.1";
|
package/lib/meta.js
CHANGED
|
@@ -542,14 +542,24 @@ export function defineVisitor(context) {
|
|
|
542
542
|
includeComments: false
|
|
543
543
|
});
|
|
544
544
|
offsets.setOffsetToken(leftParenToken, 1, firstToken);
|
|
545
|
-
const
|
|
546
|
-
|
|
547
|
-
node.
|
|
548
|
-
|
|
545
|
+
const args = [];
|
|
546
|
+
if (node.source) {
|
|
547
|
+
args.push(node.source);
|
|
548
|
+
if (node.options) {
|
|
549
|
+
args.push(node.options);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
else {
|
|
553
|
+
// typescript-eslint<v8.48 node
|
|
554
|
+
args.push(node.argument ||
|
|
555
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- typescript-eslint<v6 node
|
|
556
|
+
node.parameter);
|
|
557
|
+
}
|
|
558
|
+
const rightParenToken = sourceCode.getTokenAfter(args[args.length - 1], {
|
|
549
559
|
filter: isClosingParenToken,
|
|
550
560
|
includeComments: false
|
|
551
561
|
});
|
|
552
|
-
offsets.setOffsetElementList(
|
|
562
|
+
offsets.setOffsetElementList(args, leftParenToken, rightParenToken, 1);
|
|
553
563
|
if (node.qualifier) {
|
|
554
564
|
const dotToken = sourceCode.getTokenBefore(node.qualifier);
|
|
555
565
|
const propertyToken = sourceCode.getTokenAfter(dotToken);
|
|
@@ -2,6 +2,8 @@ import { getPropertyName } from '@eslint-community/eslint-utils';
|
|
|
2
2
|
import { keyword } from 'esutils';
|
|
3
3
|
import { createRule } from '../utils/index.js';
|
|
4
4
|
import { findAttribute, isExpressionIdentifier, findVariable } from '../utils/ast-utils.js';
|
|
5
|
+
import { getSvelteContext } from '../utils/svelte-context.js';
|
|
6
|
+
import { SVELTE_RUNES } from '../shared/runes.js';
|
|
5
7
|
export default createRule('prefer-destructured-store-props', {
|
|
6
8
|
meta: {
|
|
7
9
|
docs: {
|
|
@@ -20,6 +22,7 @@ export default createRule('prefer-destructured-store-props', {
|
|
|
20
22
|
},
|
|
21
23
|
create(context) {
|
|
22
24
|
let mainScript = null;
|
|
25
|
+
const svelteContext = getSvelteContext(context);
|
|
23
26
|
// Store off instances of probably-destructurable statements
|
|
24
27
|
const reports = [];
|
|
25
28
|
let inScriptElement = false;
|
|
@@ -105,6 +108,9 @@ export default createRule('prefer-destructured-store-props', {
|
|
|
105
108
|
"MemberExpression[object.type='Identifier'][object.name=/^\\$[^\\$]/]"(node) {
|
|
106
109
|
if (inScriptElement)
|
|
107
110
|
return; // Within a script tag
|
|
111
|
+
// Skip Svelte 5 runes (e.g., $derived.by, $state.raw, $effect.pre)
|
|
112
|
+
if (svelteContext?.runes === true && SVELTE_RUNES.has(node.object.name))
|
|
113
|
+
return;
|
|
108
114
|
storeMemberAccessStack.unshift({ node, identifiers: [] });
|
|
109
115
|
},
|
|
110
116
|
Identifier(node) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SVELTE_RUNES: Set<string>;
|
|
@@ -10,6 +10,7 @@ import { transform as transformWithStylus } from './transform/stylus.js';
|
|
|
10
10
|
import { getSvelteIgnoreItems } from './ignore-comment.js';
|
|
11
11
|
import { extractLeadingComments } from './extract-leading-comments.js';
|
|
12
12
|
import { findAttribute, getLangValue } from '../../utils/ast-utils.js';
|
|
13
|
+
import { getSvelteVersion } from '../../utils/svelte-context.js';
|
|
13
14
|
import path from 'path';
|
|
14
15
|
import fs from 'fs';
|
|
15
16
|
const STYLE_TRANSFORMS = {
|
|
@@ -287,12 +288,22 @@ function isCustomElement(program) {
|
|
|
287
288
|
return Boolean(findAttribute(body, 'tag')) || Boolean(findAttribute(body, 'customElement'));
|
|
288
289
|
});
|
|
289
290
|
}
|
|
291
|
+
const svelteVersion = getSvelteVersion();
|
|
290
292
|
/**
|
|
291
293
|
* Get compile warnings
|
|
292
294
|
*/
|
|
293
295
|
function getWarningsFromCode(code, context) {
|
|
294
296
|
try {
|
|
297
|
+
const svelteConfig = context.sourceCode.parserServices.svelteParseContext?.svelteConfig;
|
|
298
|
+
const compilerOptions = svelteConfig?.compilerOptions ?? {};
|
|
295
299
|
const result = compiler.compile(code, {
|
|
300
|
+
...(svelteVersion === '5'
|
|
301
|
+
? {
|
|
302
|
+
experimental: {
|
|
303
|
+
async: compilerOptions.experimental?.async
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
: {}),
|
|
296
307
|
generate: false,
|
|
297
308
|
...(isCustomElement(context.sourceCode.ast) ? { customElement: true } : {})
|
|
298
309
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-svelte",
|
|
3
|
-
"version": "3.13.
|
|
3
|
+
"version": "3.13.1",
|
|
4
4
|
"description": "ESLint plugin for Svelte using AST",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -62,15 +62,15 @@
|
|
|
62
62
|
"@types/postcss-safe-parser": "^5.0.4",
|
|
63
63
|
"@types/semver": "^7.7.0",
|
|
64
64
|
"@types/stylus": "^0.48.43",
|
|
65
|
-
"@typescript-eslint/scope-manager": "^8.
|
|
66
|
-
"@typescript-eslint/types": "^8.
|
|
65
|
+
"@typescript-eslint/scope-manager": "^8.48.1",
|
|
66
|
+
"@typescript-eslint/types": "^8.48.1",
|
|
67
67
|
"acorn": "^8.15.0",
|
|
68
68
|
"assert": "^2.1.0",
|
|
69
|
-
"esbuild": "^0.
|
|
70
|
-
"eslint-scope": "^
|
|
69
|
+
"esbuild": "^0.27.0",
|
|
70
|
+
"eslint-scope": "^9.0.0",
|
|
71
71
|
"eslint-typegen": "^2.3.0",
|
|
72
|
-
"eslint-visitor-keys": "^
|
|
73
|
-
"espree": "^
|
|
72
|
+
"eslint-visitor-keys": "^5.0.0",
|
|
73
|
+
"espree": "^11.0.0",
|
|
74
74
|
"jiti": "^2.5.1",
|
|
75
75
|
"less": "^4.4.1",
|
|
76
76
|
"mocha": "~11.7.2",
|