From d792c0188186118a4b3fb4648cc09d9903cef05c Mon Sep 17 00:00:00 2001 From: Nicolas Le Cam Date: Sat, 15 Jun 2024 23:37:39 +0200 Subject: [PATCH 1/3] chore: Use const in rules configs This allows svelte configs to pass typescript-eslint type checking --- .../eslint-plugin-svelte/src/configs/all.ts | 2 +- .../eslint-plugin-svelte/src/configs/base.ts | 10 +++---- .../src/configs/flat/all.ts | 2 +- .../src/configs/flat/base.ts | 10 +++---- .../src/configs/flat/prettier.ts | 22 +++++++-------- .../src/configs/flat/recommended.ts | 28 +++++++++---------- .../src/configs/prettier.ts | 22 +++++++-------- .../src/configs/recommended.ts | 28 +++++++++---------- 8 files changed, 62 insertions(+), 62 deletions(-) diff --git a/packages/eslint-plugin-svelte/src/configs/all.ts b/packages/eslint-plugin-svelte/src/configs/all.ts index 602a61c7f..f56ece9c6 100644 --- a/packages/eslint-plugin-svelte/src/configs/all.ts +++ b/packages/eslint-plugin-svelte/src/configs/all.ts @@ -6,7 +6,7 @@ export = { extends: [baseExtend], rules: Object.fromEntries( rules - .map((rule) => [`svelte/${rule.meta.docs.ruleName}`, 'error']) + .map((rule) => [`svelte/${rule.meta.docs.ruleName}`, 'error' as const]) .filter( ([ruleName]) => ![ diff --git a/packages/eslint-plugin-svelte/src/configs/base.ts b/packages/eslint-plugin-svelte/src/configs/base.ts index d9ebce6c1..60b04ab09 100644 --- a/packages/eslint-plugin-svelte/src/configs/base.ts +++ b/packages/eslint-plugin-svelte/src/configs/base.ts @@ -9,14 +9,14 @@ export = { parser: require.resolve('svelte-eslint-parser'), rules: { // ESLint core rules known to cause problems with `.svelte`. - '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`. - // "no-irregular-whitespace": "off", + '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`. + // "no-irregular-whitespace": "off" as const, // Self assign is one of way to update reactive value in Svelte. - 'no-self-assign': 'off', + 'no-self-assign': 'off' as const, // eslint-plugin-svelte rules - 'svelte/comment-directive': 'error', - 'svelte/system': 'error' + 'svelte/comment-directive': 'error' as const, + 'svelte/system': 'error' as const } } ] diff --git a/packages/eslint-plugin-svelte/src/configs/flat/all.ts b/packages/eslint-plugin-svelte/src/configs/flat/all.ts index c2dfe9771..6b98e51ee 100644 --- a/packages/eslint-plugin-svelte/src/configs/flat/all.ts +++ b/packages/eslint-plugin-svelte/src/configs/flat/all.ts @@ -5,7 +5,7 @@ export default [ { rules: Object.fromEntries( rules - .map((rule) => [`svelte/${rule.meta.docs.ruleName}`, 'error']) + .map((rule) => [`svelte/${rule.meta.docs.ruleName}`, 'error' as const]) .filter( ([ruleName]) => ![ diff --git a/packages/eslint-plugin-svelte/src/configs/flat/base.ts b/packages/eslint-plugin-svelte/src/configs/flat/base.ts index 755a52831..bd22dd956 100644 --- a/packages/eslint-plugin-svelte/src/configs/flat/base.ts +++ b/packages/eslint-plugin-svelte/src/configs/flat/base.ts @@ -19,14 +19,14 @@ export default [ }, rules: { // ESLint core rules known to cause problems with `.svelte`. - '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`. - // "no-irregular-whitespace": "off", + '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`. + // "no-irregular-whitespace": "off" as const, // Self assign is one of way to update reactive value in Svelte. - 'no-self-assign': 'off', + 'no-self-assign': 'off' as const, // eslint-plugin-svelte rules - 'svelte/comment-directive': 'error', - 'svelte/system': 'error' + 'svelte/comment-directive': 'error' as const, + 'svelte/system': 'error' as const }, processor: 'svelte/svelte' } diff --git a/packages/eslint-plugin-svelte/src/configs/flat/prettier.ts b/packages/eslint-plugin-svelte/src/configs/flat/prettier.ts index 5b2b1543b..dfbff02b4 100644 --- a/packages/eslint-plugin-svelte/src/configs/flat/prettier.ts +++ b/packages/eslint-plugin-svelte/src/configs/flat/prettier.ts @@ -7,17 +7,17 @@ export default [ { rules: { // eslint-plugin-svelte rules - 'svelte/first-attribute-linebreak': 'off', - 'svelte/html-closing-bracket-spacing': 'off', - 'svelte/html-quotes': 'off', - 'svelte/html-self-closing': 'off', - 'svelte/indent': 'off', - 'svelte/max-attributes-per-line': 'off', - 'svelte/mustache-spacing': 'off', - 'svelte/no-spaces-around-equal-signs-in-attribute': 'off', - 'svelte/no-trailing-spaces': 'off', - 'svelte/shorthand-attribute': 'off', - 'svelte/shorthand-directive': 'off' + 'svelte/first-attribute-linebreak': 'off' as const, + 'svelte/html-closing-bracket-spacing': 'off' as const, + 'svelte/html-quotes': 'off' as const, + 'svelte/html-self-closing': 'off' as const, + 'svelte/indent': 'off' as const, + 'svelte/max-attributes-per-line': 'off' as const, + 'svelte/mustache-spacing': 'off' as const, + 'svelte/no-spaces-around-equal-signs-in-attribute': 'off' as const, + 'svelte/no-trailing-spaces': 'off' as const, + 'svelte/shorthand-attribute': 'off' as const, + 'svelte/shorthand-directive': 'off' as const } } ]; diff --git a/packages/eslint-plugin-svelte/src/configs/flat/recommended.ts b/packages/eslint-plugin-svelte/src/configs/flat/recommended.ts index 7e2c4a80d..307af67e3 100644 --- a/packages/eslint-plugin-svelte/src/configs/flat/recommended.ts +++ b/packages/eslint-plugin-svelte/src/configs/flat/recommended.ts @@ -7,20 +7,20 @@ export default [ { rules: { // eslint-plugin-svelte rules - 'svelte/comment-directive': 'error', - 'svelte/no-at-debug-tags': 'warn', - 'svelte/no-at-html-tags': 'error', - 'svelte/no-dupe-else-if-blocks': 'error', - 'svelte/no-dupe-style-properties': 'error', - 'svelte/no-dynamic-slot-name': 'error', - 'svelte/no-inner-declarations': 'error', - 'svelte/no-not-function-handler': 'error', - 'svelte/no-object-in-text-mustaches': 'error', - 'svelte/no-shorthand-style-property-overrides': 'error', - 'svelte/no-unknown-style-directive-property': 'error', - 'svelte/no-unused-svelte-ignore': 'error', - 'svelte/system': 'error', - 'svelte/valid-compile': 'error' + 'svelte/comment-directive': 'error' as const, + 'svelte/no-at-debug-tags': 'warn' as const, + 'svelte/no-at-html-tags': 'error' as const, + 'svelte/no-dupe-else-if-blocks': 'error' as const, + 'svelte/no-dupe-style-properties': 'error' as const, + 'svelte/no-dynamic-slot-name': 'error' as const, + 'svelte/no-inner-declarations': 'error' as const, + 'svelte/no-not-function-handler': 'error' as const, + 'svelte/no-object-in-text-mustaches': 'error' as const, + 'svelte/no-shorthand-style-property-overrides': 'error' as const, + 'svelte/no-unknown-style-directive-property': 'error' as const, + 'svelte/no-unused-svelte-ignore': 'error' as const, + 'svelte/system': 'error' as const, + 'svelte/valid-compile': 'error' as const } } ]; diff --git a/packages/eslint-plugin-svelte/src/configs/prettier.ts b/packages/eslint-plugin-svelte/src/configs/prettier.ts index b1bf978b8..9a524e002 100644 --- a/packages/eslint-plugin-svelte/src/configs/prettier.ts +++ b/packages/eslint-plugin-svelte/src/configs/prettier.ts @@ -8,16 +8,16 @@ export = { extends: [baseExtend], rules: { // eslint-plugin-svelte rules - 'svelte/first-attribute-linebreak': 'off', - 'svelte/html-closing-bracket-spacing': 'off', - 'svelte/html-quotes': 'off', - 'svelte/html-self-closing': 'off', - 'svelte/indent': 'off', - 'svelte/max-attributes-per-line': 'off', - 'svelte/mustache-spacing': 'off', - 'svelte/no-spaces-around-equal-signs-in-attribute': 'off', - 'svelte/no-trailing-spaces': 'off', - 'svelte/shorthand-attribute': 'off', - 'svelte/shorthand-directive': 'off' + 'svelte/first-attribute-linebreak': 'off' as const, + 'svelte/html-closing-bracket-spacing': 'off' as const, + 'svelte/html-quotes': 'off' as const, + 'svelte/html-self-closing': 'off' as const, + 'svelte/indent': 'off' as const, + 'svelte/max-attributes-per-line': 'off' as const, + 'svelte/mustache-spacing': 'off' as const, + 'svelte/no-spaces-around-equal-signs-in-attribute': 'off' as const, + 'svelte/no-trailing-spaces': 'off' as const, + 'svelte/shorthand-attribute': 'off' as const, + 'svelte/shorthand-directive': 'off' as const } }; diff --git a/packages/eslint-plugin-svelte/src/configs/recommended.ts b/packages/eslint-plugin-svelte/src/configs/recommended.ts index b865b64e2..53195e72f 100644 --- a/packages/eslint-plugin-svelte/src/configs/recommended.ts +++ b/packages/eslint-plugin-svelte/src/configs/recommended.ts @@ -8,19 +8,19 @@ export = { extends: [baseExtend], rules: { // eslint-plugin-svelte rules - 'svelte/comment-directive': 'error', - 'svelte/no-at-debug-tags': 'warn', - 'svelte/no-at-html-tags': 'error', - 'svelte/no-dupe-else-if-blocks': 'error', - 'svelte/no-dupe-style-properties': 'error', - 'svelte/no-dynamic-slot-name': 'error', - 'svelte/no-inner-declarations': 'error', - 'svelte/no-not-function-handler': 'error', - 'svelte/no-object-in-text-mustaches': 'error', - 'svelte/no-shorthand-style-property-overrides': 'error', - 'svelte/no-unknown-style-directive-property': 'error', - 'svelte/no-unused-svelte-ignore': 'error', - 'svelte/system': 'error', - 'svelte/valid-compile': 'error' + 'svelte/comment-directive': 'error' as const, + 'svelte/no-at-debug-tags': 'warn' as const, + 'svelte/no-at-html-tags': 'error' as const, + 'svelte/no-dupe-else-if-blocks': 'error' as const, + 'svelte/no-dupe-style-properties': 'error' as const, + 'svelte/no-dynamic-slot-name': 'error' as const, + 'svelte/no-inner-declarations': 'error' as const, + 'svelte/no-not-function-handler': 'error' as const, + 'svelte/no-object-in-text-mustaches': 'error' as const, + 'svelte/no-shorthand-style-property-overrides': 'error' as const, + 'svelte/no-unknown-style-directive-property': 'error' as const, + 'svelte/no-unused-svelte-ignore': 'error' as const, + 'svelte/system': 'error' as const, + 'svelte/valid-compile': 'error' as const } }; From 66ef0d9eee3750590031c974c6f33b871acaa3c1 Mon Sep 17 00:00:00 2001 From: Nicolas Le Cam Date: Tue, 18 Jun 2024 13:41:18 +0200 Subject: [PATCH 2/3] chore: Use eslint types for configs --- .../eslint-plugin-svelte/src/configs/all.ts | 8 +++-- .../eslint-plugin-svelte/src/configs/base.ts | 14 ++++---- .../src/configs/flat/all.ts | 6 ++-- .../src/configs/flat/base.ts | 15 ++++---- .../src/configs/flat/prettier.ts | 26 +++++++------- .../src/configs/flat/recommended.ts | 32 +++++++++-------- .../src/configs/prettier.ts | 28 ++++++++------- .../src/configs/recommended.ts | 34 ++++++++++--------- .../tools/update-rulesets.ts | 29 +++++++++++----- 9 files changed, 109 insertions(+), 83 deletions(-) diff --git a/packages/eslint-plugin-svelte/src/configs/all.ts b/packages/eslint-plugin-svelte/src/configs/all.ts index f56ece9c6..41a45fa39 100644 --- a/packages/eslint-plugin-svelte/src/configs/all.ts +++ b/packages/eslint-plugin-svelte/src/configs/all.ts @@ -1,12 +1,13 @@ -import path from 'path'; +import type { Linter } from 'eslint'; +import path from 'node:path'; import { rules } from '../utils/rules'; const base = require.resolve('./base'); const baseExtend = path.extname(`${base}`) === '.ts' ? 'plugin:svelte/base' : base; -export = { +const config: Linter.Config = { extends: [baseExtend], rules: Object.fromEntries( rules - .map((rule) => [`svelte/${rule.meta.docs.ruleName}`, 'error' as const]) + .map((rule) => [`svelte/${rule.meta.docs.ruleName}`, 'error']) .filter( ([ruleName]) => ![ @@ -16,3 +17,4 @@ export = { ) ) }; +export = config; diff --git a/packages/eslint-plugin-svelte/src/configs/base.ts b/packages/eslint-plugin-svelte/src/configs/base.ts index 60b04ab09..fe0e3a94d 100644 --- a/packages/eslint-plugin-svelte/src/configs/base.ts +++ b/packages/eslint-plugin-svelte/src/configs/base.ts @@ -1,7 +1,8 @@ // IMPORTANT! // This file has been automatically generated, // in order to update its content execute "pnpm run update" -export = { +import type { Linter } from 'eslint'; +const config: Linter.Config = { plugins: ['svelte'], overrides: [ { @@ -9,15 +10,16 @@ export = { parser: require.resolve('svelte-eslint-parser'), rules: { // ESLint core rules known to cause problems with `.svelte`. - '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`. - // "no-irregular-whitespace": "off" as const, + '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`. + // "no-irregular-whitespace": "off", // Self assign is one of way to update reactive value in Svelte. - 'no-self-assign': 'off' as const, + 'no-self-assign': 'off', // eslint-plugin-svelte rules - 'svelte/comment-directive': 'error' as const, - 'svelte/system': 'error' as const + 'svelte/comment-directive': 'error', + 'svelte/system': 'error' } } ] }; +export = config; diff --git a/packages/eslint-plugin-svelte/src/configs/flat/all.ts b/packages/eslint-plugin-svelte/src/configs/flat/all.ts index 6b98e51ee..fed3af8b7 100644 --- a/packages/eslint-plugin-svelte/src/configs/flat/all.ts +++ b/packages/eslint-plugin-svelte/src/configs/flat/all.ts @@ -1,11 +1,12 @@ +import type { Linter } from 'eslint'; import { rules } from '../../utils/rules'; import base from './base'; -export default [ +const config: Linter.FlatConfig[] = [ ...base, { rules: Object.fromEntries( rules - .map((rule) => [`svelte/${rule.meta.docs.ruleName}`, 'error' as const]) + .map((rule) => [`svelte/${rule.meta.docs.ruleName}`, 'error']) .filter( ([ruleName]) => ![ @@ -16,3 +17,4 @@ export default [ ) } ]; +export default config; diff --git a/packages/eslint-plugin-svelte/src/configs/flat/base.ts b/packages/eslint-plugin-svelte/src/configs/flat/base.ts index bd22dd956..94dc151e1 100644 --- a/packages/eslint-plugin-svelte/src/configs/flat/base.ts +++ b/packages/eslint-plugin-svelte/src/configs/flat/base.ts @@ -1,8 +1,8 @@ // IMPORTANT! // This file has been automatically generated, // in order to update its content execute "pnpm run update" -import type { ESLint } from 'eslint'; -export default [ +import type { ESLint, Linter } from 'eslint'; +const config: Linter.FlatConfig[] = [ { plugins: { get svelte(): ESLint.Plugin { @@ -19,15 +19,16 @@ export default [ }, rules: { // ESLint core rules known to cause problems with `.svelte`. - '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`. - // "no-irregular-whitespace": "off" as const, + '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`. + // "no-irregular-whitespace": "off", // Self assign is one of way to update reactive value in Svelte. - 'no-self-assign': 'off' as const, + 'no-self-assign': 'off', // eslint-plugin-svelte rules - 'svelte/comment-directive': 'error' as const, - 'svelte/system': 'error' as const + 'svelte/comment-directive': 'error', + 'svelte/system': 'error' }, processor: 'svelte/svelte' } ]; +export default config; diff --git a/packages/eslint-plugin-svelte/src/configs/flat/prettier.ts b/packages/eslint-plugin-svelte/src/configs/flat/prettier.ts index dfbff02b4..4c149e8e5 100644 --- a/packages/eslint-plugin-svelte/src/configs/flat/prettier.ts +++ b/packages/eslint-plugin-svelte/src/configs/flat/prettier.ts @@ -1,23 +1,25 @@ // IMPORTANT! // This file has been automatically generated, // in order to update its content execute "pnpm run update" +import type { Linter } from 'eslint'; import base from './base'; -export default [ +const config: Linter.FlatConfig[] = [ ...base, { rules: { // eslint-plugin-svelte rules - 'svelte/first-attribute-linebreak': 'off' as const, - 'svelte/html-closing-bracket-spacing': 'off' as const, - 'svelte/html-quotes': 'off' as const, - 'svelte/html-self-closing': 'off' as const, - 'svelte/indent': 'off' as const, - 'svelte/max-attributes-per-line': 'off' as const, - 'svelte/mustache-spacing': 'off' as const, - 'svelte/no-spaces-around-equal-signs-in-attribute': 'off' as const, - 'svelte/no-trailing-spaces': 'off' as const, - 'svelte/shorthand-attribute': 'off' as const, - 'svelte/shorthand-directive': 'off' as const + 'svelte/first-attribute-linebreak': 'off', + 'svelte/html-closing-bracket-spacing': 'off', + 'svelte/html-quotes': 'off', + 'svelte/html-self-closing': 'off', + 'svelte/indent': 'off', + 'svelte/max-attributes-per-line': 'off', + 'svelte/mustache-spacing': 'off', + 'svelte/no-spaces-around-equal-signs-in-attribute': 'off', + 'svelte/no-trailing-spaces': 'off', + 'svelte/shorthand-attribute': 'off', + 'svelte/shorthand-directive': 'off' } } ]; +export default config; diff --git a/packages/eslint-plugin-svelte/src/configs/flat/recommended.ts b/packages/eslint-plugin-svelte/src/configs/flat/recommended.ts index 307af67e3..432017b3d 100644 --- a/packages/eslint-plugin-svelte/src/configs/flat/recommended.ts +++ b/packages/eslint-plugin-svelte/src/configs/flat/recommended.ts @@ -1,26 +1,28 @@ // IMPORTANT! // This file has been automatically generated, // in order to update its content execute "pnpm run update" +import type { Linter } from 'eslint'; import base from './base'; -export default [ +const config: Linter.FlatConfig[] = [ ...base, { rules: { // eslint-plugin-svelte rules - 'svelte/comment-directive': 'error' as const, - 'svelte/no-at-debug-tags': 'warn' as const, - 'svelte/no-at-html-tags': 'error' as const, - 'svelte/no-dupe-else-if-blocks': 'error' as const, - 'svelte/no-dupe-style-properties': 'error' as const, - 'svelte/no-dynamic-slot-name': 'error' as const, - 'svelte/no-inner-declarations': 'error' as const, - 'svelte/no-not-function-handler': 'error' as const, - 'svelte/no-object-in-text-mustaches': 'error' as const, - 'svelte/no-shorthand-style-property-overrides': 'error' as const, - 'svelte/no-unknown-style-directive-property': 'error' as const, - 'svelte/no-unused-svelte-ignore': 'error' as const, - 'svelte/system': 'error' as const, - 'svelte/valid-compile': 'error' as const + 'svelte/comment-directive': 'error', + 'svelte/no-at-debug-tags': 'warn', + 'svelte/no-at-html-tags': 'error', + 'svelte/no-dupe-else-if-blocks': 'error', + 'svelte/no-dupe-style-properties': 'error', + 'svelte/no-dynamic-slot-name': 'error', + 'svelte/no-inner-declarations': 'error', + 'svelte/no-not-function-handler': 'error', + 'svelte/no-object-in-text-mustaches': 'error', + 'svelte/no-shorthand-style-property-overrides': 'error', + 'svelte/no-unknown-style-directive-property': 'error', + 'svelte/no-unused-svelte-ignore': 'error', + 'svelte/system': 'error', + 'svelte/valid-compile': 'error' } } ]; +export default config; diff --git a/packages/eslint-plugin-svelte/src/configs/prettier.ts b/packages/eslint-plugin-svelte/src/configs/prettier.ts index 9a524e002..42054233b 100644 --- a/packages/eslint-plugin-svelte/src/configs/prettier.ts +++ b/packages/eslint-plugin-svelte/src/configs/prettier.ts @@ -1,23 +1,25 @@ // IMPORTANT! // This file has been automatically generated, // in order to update its content execute "pnpm run update" -import path from 'path'; +import type { Linter } from 'eslint'; +import path from 'node:path'; const base = require.resolve('./base'); const baseExtend = path.extname(`${base}`) === '.ts' ? 'plugin:svelte/base' : base; -export = { +const config: Linter.Config = { extends: [baseExtend], rules: { // eslint-plugin-svelte rules - 'svelte/first-attribute-linebreak': 'off' as const, - 'svelte/html-closing-bracket-spacing': 'off' as const, - 'svelte/html-quotes': 'off' as const, - 'svelte/html-self-closing': 'off' as const, - 'svelte/indent': 'off' as const, - 'svelte/max-attributes-per-line': 'off' as const, - 'svelte/mustache-spacing': 'off' as const, - 'svelte/no-spaces-around-equal-signs-in-attribute': 'off' as const, - 'svelte/no-trailing-spaces': 'off' as const, - 'svelte/shorthand-attribute': 'off' as const, - 'svelte/shorthand-directive': 'off' as const + 'svelte/first-attribute-linebreak': 'off', + 'svelte/html-closing-bracket-spacing': 'off', + 'svelte/html-quotes': 'off', + 'svelte/html-self-closing': 'off', + 'svelte/indent': 'off', + 'svelte/max-attributes-per-line': 'off', + 'svelte/mustache-spacing': 'off', + 'svelte/no-spaces-around-equal-signs-in-attribute': 'off', + 'svelte/no-trailing-spaces': 'off', + 'svelte/shorthand-attribute': 'off', + 'svelte/shorthand-directive': 'off' } }; +export = config; diff --git a/packages/eslint-plugin-svelte/src/configs/recommended.ts b/packages/eslint-plugin-svelte/src/configs/recommended.ts index 53195e72f..5e53547be 100644 --- a/packages/eslint-plugin-svelte/src/configs/recommended.ts +++ b/packages/eslint-plugin-svelte/src/configs/recommended.ts @@ -1,26 +1,28 @@ // IMPORTANT! // This file has been automatically generated, // in order to update its content execute "pnpm run update" -import path from 'path'; +import type { Linter } from 'eslint'; +import path from 'node:path'; const base = require.resolve('./base'); const baseExtend = path.extname(`${base}`) === '.ts' ? 'plugin:svelte/base' : base; -export = { +const config: Linter.Config = { extends: [baseExtend], rules: { // eslint-plugin-svelte rules - 'svelte/comment-directive': 'error' as const, - 'svelte/no-at-debug-tags': 'warn' as const, - 'svelte/no-at-html-tags': 'error' as const, - 'svelte/no-dupe-else-if-blocks': 'error' as const, - 'svelte/no-dupe-style-properties': 'error' as const, - 'svelte/no-dynamic-slot-name': 'error' as const, - 'svelte/no-inner-declarations': 'error' as const, - 'svelte/no-not-function-handler': 'error' as const, - 'svelte/no-object-in-text-mustaches': 'error' as const, - 'svelte/no-shorthand-style-property-overrides': 'error' as const, - 'svelte/no-unknown-style-directive-property': 'error' as const, - 'svelte/no-unused-svelte-ignore': 'error' as const, - 'svelte/system': 'error' as const, - 'svelte/valid-compile': 'error' as const + 'svelte/comment-directive': 'error', + 'svelte/no-at-debug-tags': 'warn', + 'svelte/no-at-html-tags': 'error', + 'svelte/no-dupe-else-if-blocks': 'error', + 'svelte/no-dupe-style-properties': 'error', + 'svelte/no-dynamic-slot-name': 'error', + 'svelte/no-inner-declarations': 'error', + 'svelte/no-not-function-handler': 'error', + 'svelte/no-object-in-text-mustaches': 'error', + 'svelte/no-shorthand-style-property-overrides': 'error', + 'svelte/no-unknown-style-directive-property': 'error', + 'svelte/no-unused-svelte-ignore': 'error', + 'svelte/system': 'error', + 'svelte/valid-compile': 'error' } }; +export = config; diff --git a/packages/eslint-plugin-svelte/tools/update-rulesets.ts b/packages/eslint-plugin-svelte/tools/update-rulesets.ts index 90e8b0139..1b9db19c5 100644 --- a/packages/eslint-plugin-svelte/tools/update-rulesets.ts +++ b/packages/eslint-plugin-svelte/tools/update-rulesets.ts @@ -11,7 +11,8 @@ const legacyBaseContent = `/* * This file has been automatically generated, * in order to update its content execute "pnpm run update" */ -export = { +import type { Linter } from 'eslint' +const config: Linter.Config = { plugins: ["svelte"], overrides: [ { @@ -36,6 +37,7 @@ export = { }, ], } +export = config `; const legacyBaseFilePath = path.resolve(__dirname, '../src/configs/base.ts'); @@ -48,11 +50,12 @@ const legacyRecommendedContent = `/* * This file has been automatically generated, * in order to update its content execute "pnpm run update" */ -import path from "path" +import type { Linter } from 'eslint' +import path from "node:path" const base = require.resolve("./base") const baseExtend = path.extname(\`\${base}\`) === ".ts" ? "plugin:svelte/base" : base -export = { +const config: Linter.Config = { extends: [baseExtend], rules: { // eslint-plugin-svelte rules @@ -65,6 +68,7 @@ export = { .join(',\n ')}, }, } +export = config `; const legacyRecommendedFilePath = path.resolve(__dirname, '../src/configs/recommended.ts'); @@ -77,11 +81,12 @@ const legacyPrettierContent = `/* * This file has been automatically generated, * in order to update its content execute "pnpm run update" */ -import path from "path" +import type { Linter } from 'eslint' +import path from "node:path" const base = require.resolve("./base") const baseExtend = path.extname(\`\${base}\`) === ".ts" ? "plugin:svelte/base" : base -export = { +const config: Linter.Config = { extends: [baseExtend], rules: { // eslint-plugin-svelte rules @@ -91,6 +96,7 @@ export = { .join(',\n ')}, }, } +export = config `; const legacyPrettierFilePath = path.resolve(__dirname, '../src/configs/prettier.ts'); @@ -107,8 +113,8 @@ const baseContent = `/* * This file has been automatically generated, * in order to update its content execute "pnpm run update" */ -import type { ESLint } from 'eslint'; -export default [ +import type { ESLint, Linter } from 'eslint'; +const config: Linter.FlatConfig[] = [ { plugins: { get svelte(): ESLint.Plugin { @@ -142,6 +148,7 @@ export default [ processor: 'svelte/svelte' }, ] +export default config `; const baseFilePath = path.resolve(__dirname, '../src/configs/flat/base.ts'); @@ -154,8 +161,9 @@ const recommendedContent = `/* * This file has been automatically generated, * in order to update its content execute "pnpm run update" */ +import type { Linter } from 'eslint'; import base from "./base" -export default [ +const config: Linter.FlatConfig[] = [ ...base, { rules: { @@ -170,6 +178,7 @@ export default [ }, } ] +export default config `; const recommendedFilePath = path.resolve(__dirname, '../src/configs/flat/recommended.ts'); @@ -182,8 +191,9 @@ const prettierContent = `/* * This file has been automatically generated, * in order to update its content execute "pnpm run update" */ +import type { Linter } from 'eslint'; import base from "./base" -export default [ +const config: Linter.FlatConfig[] = [ ...base, { rules: { @@ -195,6 +205,7 @@ export default [ }, } ] +export default config `; const prettierFilePath = path.resolve(__dirname, '../src/configs/flat/prettier.ts'); From 09efac121f9dfa87b297230e96d5b10f3856c34c Mon Sep 17 00:00:00 2001 From: Nicolas Le Cam Date: Tue, 18 Jun 2024 21:53:17 +0200 Subject: [PATCH 3/3] add changeset --- .changeset/long-dingos-fold.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/long-dingos-fold.md diff --git a/.changeset/long-dingos-fold.md b/.changeset/long-dingos-fold.md new file mode 100644 index 000000000..b8c2737fe --- /dev/null +++ b/.changeset/long-dingos-fold.md @@ -0,0 +1,5 @@ +--- +'eslint-plugin-svelte': patch +--- + +chore: Use eslint types for exported configs