Skip to content

Commit d792c01

Browse files
committed
chore: Use const in rules configs
This allows svelte configs to pass typescript-eslint type checking
1 parent 23f7bf2 commit d792c01

File tree

8 files changed

+62
-62
lines changed

8 files changed

+62
-62
lines changed

packages/eslint-plugin-svelte/src/configs/all.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export = {
66
extends: [baseExtend],
77
rules: Object.fromEntries(
88
rules
9-
.map((rule) => [`svelte/${rule.meta.docs.ruleName}`, 'error'])
9+
.map((rule) => [`svelte/${rule.meta.docs.ruleName}`, 'error' as const])
1010
.filter(
1111
([ruleName]) =>
1212
![

packages/eslint-plugin-svelte/src/configs/base.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ export = {
99
parser: require.resolve('svelte-eslint-parser'),
1010
rules: {
1111
// ESLint core rules known to cause problems with `.svelte`.
12-
'no-inner-declarations': 'off', // The AST generated by svelte-eslint-parser will false positives in it rule because the root node of the script is not the `Program`.
13-
// "no-irregular-whitespace": "off",
12+
'no-inner-declarations': 'off' as const, // The AST generated by svelte-eslint-parser will false positives in it rule because the root node of the script is not the `Program`.
13+
// "no-irregular-whitespace": "off" as const,
1414
// Self assign is one of way to update reactive value in Svelte.
15-
'no-self-assign': 'off',
15+
'no-self-assign': 'off' as const,
1616

1717
// eslint-plugin-svelte rules
18-
'svelte/comment-directive': 'error',
19-
'svelte/system': 'error'
18+
'svelte/comment-directive': 'error' as const,
19+
'svelte/system': 'error' as const
2020
}
2121
}
2222
]

packages/eslint-plugin-svelte/src/configs/flat/all.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default [
55
{
66
rules: Object.fromEntries(
77
rules
8-
.map((rule) => [`svelte/${rule.meta.docs.ruleName}`, 'error'])
8+
.map((rule) => [`svelte/${rule.meta.docs.ruleName}`, 'error' as const])
99
.filter(
1010
([ruleName]) =>
1111
![

packages/eslint-plugin-svelte/src/configs/flat/base.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ export default [
1919
},
2020
rules: {
2121
// ESLint core rules known to cause problems with `.svelte`.
22-
'no-inner-declarations': 'off', // The AST generated by svelte-eslint-parser will false positives in it rule because the root node of the script is not the `Program`.
23-
// "no-irregular-whitespace": "off",
22+
'no-inner-declarations': 'off' as const, // The AST generated by svelte-eslint-parser will false positives in it rule because the root node of the script is not the `Program`.
23+
// "no-irregular-whitespace": "off" as const,
2424
// Self assign is one of way to update reactive value in Svelte.
25-
'no-self-assign': 'off',
25+
'no-self-assign': 'off' as const,
2626

2727
// eslint-plugin-svelte rules
28-
'svelte/comment-directive': 'error',
29-
'svelte/system': 'error'
28+
'svelte/comment-directive': 'error' as const,
29+
'svelte/system': 'error' as const
3030
},
3131
processor: 'svelte/svelte'
3232
}

packages/eslint-plugin-svelte/src/configs/flat/prettier.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ export default [
77
{
88
rules: {
99
// eslint-plugin-svelte rules
10-
'svelte/first-attribute-linebreak': 'off',
11-
'svelte/html-closing-bracket-spacing': 'off',
12-
'svelte/html-quotes': 'off',
13-
'svelte/html-self-closing': 'off',
14-
'svelte/indent': 'off',
15-
'svelte/max-attributes-per-line': 'off',
16-
'svelte/mustache-spacing': 'off',
17-
'svelte/no-spaces-around-equal-signs-in-attribute': 'off',
18-
'svelte/no-trailing-spaces': 'off',
19-
'svelte/shorthand-attribute': 'off',
20-
'svelte/shorthand-directive': 'off'
10+
'svelte/first-attribute-linebreak': 'off' as const,
11+
'svelte/html-closing-bracket-spacing': 'off' as const,
12+
'svelte/html-quotes': 'off' as const,
13+
'svelte/html-self-closing': 'off' as const,
14+
'svelte/indent': 'off' as const,
15+
'svelte/max-attributes-per-line': 'off' as const,
16+
'svelte/mustache-spacing': 'off' as const,
17+
'svelte/no-spaces-around-equal-signs-in-attribute': 'off' as const,
18+
'svelte/no-trailing-spaces': 'off' as const,
19+
'svelte/shorthand-attribute': 'off' as const,
20+
'svelte/shorthand-directive': 'off' as const
2121
}
2222
}
2323
];

packages/eslint-plugin-svelte/src/configs/flat/recommended.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ export default [
77
{
88
rules: {
99
// eslint-plugin-svelte rules
10-
'svelte/comment-directive': 'error',
11-
'svelte/no-at-debug-tags': 'warn',
12-
'svelte/no-at-html-tags': 'error',
13-
'svelte/no-dupe-else-if-blocks': 'error',
14-
'svelte/no-dupe-style-properties': 'error',
15-
'svelte/no-dynamic-slot-name': 'error',
16-
'svelte/no-inner-declarations': 'error',
17-
'svelte/no-not-function-handler': 'error',
18-
'svelte/no-object-in-text-mustaches': 'error',
19-
'svelte/no-shorthand-style-property-overrides': 'error',
20-
'svelte/no-unknown-style-directive-property': 'error',
21-
'svelte/no-unused-svelte-ignore': 'error',
22-
'svelte/system': 'error',
23-
'svelte/valid-compile': 'error'
10+
'svelte/comment-directive': 'error' as const,
11+
'svelte/no-at-debug-tags': 'warn' as const,
12+
'svelte/no-at-html-tags': 'error' as const,
13+
'svelte/no-dupe-else-if-blocks': 'error' as const,
14+
'svelte/no-dupe-style-properties': 'error' as const,
15+
'svelte/no-dynamic-slot-name': 'error' as const,
16+
'svelte/no-inner-declarations': 'error' as const,
17+
'svelte/no-not-function-handler': 'error' as const,
18+
'svelte/no-object-in-text-mustaches': 'error' as const,
19+
'svelte/no-shorthand-style-property-overrides': 'error' as const,
20+
'svelte/no-unknown-style-directive-property': 'error' as const,
21+
'svelte/no-unused-svelte-ignore': 'error' as const,
22+
'svelte/system': 'error' as const,
23+
'svelte/valid-compile': 'error' as const
2424
}
2525
}
2626
];

packages/eslint-plugin-svelte/src/configs/prettier.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ export = {
88
extends: [baseExtend],
99
rules: {
1010
// eslint-plugin-svelte rules
11-
'svelte/first-attribute-linebreak': 'off',
12-
'svelte/html-closing-bracket-spacing': 'off',
13-
'svelte/html-quotes': 'off',
14-
'svelte/html-self-closing': 'off',
15-
'svelte/indent': 'off',
16-
'svelte/max-attributes-per-line': 'off',
17-
'svelte/mustache-spacing': 'off',
18-
'svelte/no-spaces-around-equal-signs-in-attribute': 'off',
19-
'svelte/no-trailing-spaces': 'off',
20-
'svelte/shorthand-attribute': 'off',
21-
'svelte/shorthand-directive': 'off'
11+
'svelte/first-attribute-linebreak': 'off' as const,
12+
'svelte/html-closing-bracket-spacing': 'off' as const,
13+
'svelte/html-quotes': 'off' as const,
14+
'svelte/html-self-closing': 'off' as const,
15+
'svelte/indent': 'off' as const,
16+
'svelte/max-attributes-per-line': 'off' as const,
17+
'svelte/mustache-spacing': 'off' as const,
18+
'svelte/no-spaces-around-equal-signs-in-attribute': 'off' as const,
19+
'svelte/no-trailing-spaces': 'off' as const,
20+
'svelte/shorthand-attribute': 'off' as const,
21+
'svelte/shorthand-directive': 'off' as const
2222
}
2323
};

packages/eslint-plugin-svelte/src/configs/recommended.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ export = {
88
extends: [baseExtend],
99
rules: {
1010
// eslint-plugin-svelte rules
11-
'svelte/comment-directive': 'error',
12-
'svelte/no-at-debug-tags': 'warn',
13-
'svelte/no-at-html-tags': 'error',
14-
'svelte/no-dupe-else-if-blocks': 'error',
15-
'svelte/no-dupe-style-properties': 'error',
16-
'svelte/no-dynamic-slot-name': 'error',
17-
'svelte/no-inner-declarations': 'error',
18-
'svelte/no-not-function-handler': 'error',
19-
'svelte/no-object-in-text-mustaches': 'error',
20-
'svelte/no-shorthand-style-property-overrides': 'error',
21-
'svelte/no-unknown-style-directive-property': 'error',
22-
'svelte/no-unused-svelte-ignore': 'error',
23-
'svelte/system': 'error',
24-
'svelte/valid-compile': 'error'
11+
'svelte/comment-directive': 'error' as const,
12+
'svelte/no-at-debug-tags': 'warn' as const,
13+
'svelte/no-at-html-tags': 'error' as const,
14+
'svelte/no-dupe-else-if-blocks': 'error' as const,
15+
'svelte/no-dupe-style-properties': 'error' as const,
16+
'svelte/no-dynamic-slot-name': 'error' as const,
17+
'svelte/no-inner-declarations': 'error' as const,
18+
'svelte/no-not-function-handler': 'error' as const,
19+
'svelte/no-object-in-text-mustaches': 'error' as const,
20+
'svelte/no-shorthand-style-property-overrides': 'error' as const,
21+
'svelte/no-unknown-style-directive-property': 'error' as const,
22+
'svelte/no-unused-svelte-ignore': 'error' as const,
23+
'svelte/system': 'error' as const,
24+
'svelte/valid-compile': 'error' as const
2525
}
2626
};

0 commit comments

Comments
 (0)