Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Use eslint types for exported configs #789

Merged
merged 3 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/long-dingos-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'eslint-plugin-svelte': patch
---

chore: Use eslint types for exported configs
6 changes: 4 additions & 2 deletions packages/eslint-plugin-svelte/src/configs/all.ts
Original file line number Diff line number Diff line change
@@ -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(
KuSh marked this conversation as resolved.
Show resolved Hide resolved
rules
Expand All @@ -16,3 +17,4 @@ export = {
)
)
};
export = config;
4 changes: 3 additions & 1 deletion packages/eslint-plugin-svelte/src/configs/base.ts
Original file line number Diff line number Diff line change
@@ -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: [
{
Expand All @@ -21,3 +22,4 @@ export = {
}
]
};
export = config;
4 changes: 3 additions & 1 deletion packages/eslint-plugin-svelte/src/configs/flat/all.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -16,3 +17,4 @@ export default [
)
}
];
export default config;
5 changes: 3 additions & 2 deletions packages/eslint-plugin-svelte/src/configs/flat/base.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -31,3 +31,4 @@ export default [
processor: 'svelte/svelte'
}
];
export default config;
4 changes: 3 additions & 1 deletion packages/eslint-plugin-svelte/src/configs/flat/prettier.ts
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -21,3 +22,4 @@ export default [
}
}
];
export default config;
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -24,3 +25,4 @@ export default [
}
}
];
export default config;
6 changes: 4 additions & 2 deletions packages/eslint-plugin-svelte/src/configs/prettier.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -21,3 +22,4 @@ export = {
'svelte/shorthand-directive': 'off'
}
};
export = config;
6 changes: 4 additions & 2 deletions packages/eslint-plugin-svelte/src/configs/recommended.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -24,3 +25,4 @@ export = {
'svelte/valid-compile': 'error'
}
};
export = config;
29 changes: 20 additions & 9 deletions packages/eslint-plugin-svelte/tools/update-rulesets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand All @@ -36,6 +37,7 @@ export = {
},
],
}
export = config
`;

const legacyBaseFilePath = path.resolve(__dirname, '../src/configs/base.ts');
Expand All @@ -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
Expand All @@ -65,6 +68,7 @@ export = {
.join(',\n ')},
},
}
export = config
`;

const legacyRecommendedFilePath = path.resolve(__dirname, '../src/configs/recommended.ts');
Expand All @@ -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
Expand All @@ -91,6 +96,7 @@ export = {
.join(',\n ')},
},
}
export = config
`;

const legacyPrettierFilePath = path.resolve(__dirname, '../src/configs/prettier.ts');
Expand All @@ -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 {
Expand Down Expand Up @@ -142,6 +148,7 @@ export default [
processor: 'svelte/svelte'
},
]
export default config
`;

const baseFilePath = path.resolve(__dirname, '../src/configs/flat/base.ts');
Expand All @@ -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: {
Expand All @@ -170,6 +178,7 @@ export default [
},
}
]
export default config
`;

const recommendedFilePath = path.resolve(__dirname, '../src/configs/flat/recommended.ts');
Expand All @@ -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: {
Expand All @@ -195,6 +205,7 @@ export default [
},
}
]
export default config
`;

const prettierFilePath = path.resolve(__dirname, '../src/configs/flat/prettier.ts');
Expand Down
Loading