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 diff --git a/packages/eslint-plugin-svelte/src/configs/all.ts b/packages/eslint-plugin-svelte/src/configs/all.ts index 602a61c7f..41a45fa39 100644 --- a/packages/eslint-plugin-svelte/src/configs/all.ts +++ b/packages/eslint-plugin-svelte/src/configs/all.ts @@ -1,8 +1,9 @@ -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 @@ -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 d9ebce6c1..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: [ { @@ -21,3 +22,4 @@ export = { } ] }; +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 c2dfe9771..fed3af8b7 100644 --- a/packages/eslint-plugin-svelte/src/configs/flat/all.ts +++ b/packages/eslint-plugin-svelte/src/configs/flat/all.ts @@ -1,6 +1,7 @@ +import type { Linter } from 'eslint'; import { rules } from '../../utils/rules'; import base from './base'; -export default [ +const config: Linter.FlatConfig[] = [ ...base, { rules: Object.fromEntries( @@ -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 755a52831..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 { @@ -31,3 +31,4 @@ export default [ 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 5b2b1543b..4c149e8e5 100644 --- a/packages/eslint-plugin-svelte/src/configs/flat/prettier.ts +++ b/packages/eslint-plugin-svelte/src/configs/flat/prettier.ts @@ -1,8 +1,9 @@ // 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: { @@ -21,3 +22,4 @@ export default [ } } ]; +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 7e2c4a80d..432017b3d 100644 --- a/packages/eslint-plugin-svelte/src/configs/flat/recommended.ts +++ b/packages/eslint-plugin-svelte/src/configs/flat/recommended.ts @@ -1,8 +1,9 @@ // 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: { @@ -24,3 +25,4 @@ export default [ } } ]; +export default config; diff --git a/packages/eslint-plugin-svelte/src/configs/prettier.ts b/packages/eslint-plugin-svelte/src/configs/prettier.ts index b1bf978b8..42054233b 100644 --- a/packages/eslint-plugin-svelte/src/configs/prettier.ts +++ b/packages/eslint-plugin-svelte/src/configs/prettier.ts @@ -1,10 +1,11 @@ // 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 @@ -21,3 +22,4 @@ export = { '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 b865b64e2..5e53547be 100644 --- a/packages/eslint-plugin-svelte/src/configs/recommended.ts +++ b/packages/eslint-plugin-svelte/src/configs/recommended.ts @@ -1,10 +1,11 @@ // 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 @@ -24,3 +25,4 @@ export = { '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');