fix: update eslint.config based on svelte5 example

This commit is contained in:
ndom91 2024-10-21 11:50:10 +02:00 committed by Nico Domino
parent 785a04dbe5
commit 3a233b64e3

View File

@ -1,105 +1,31 @@
import prettier from 'eslint-config-prettier';
import js from '@eslint/js'; import js from '@eslint/js';
import tsParser from '@typescript-eslint/parser'; import svelte from 'eslint-plugin-svelte';
import eslintConfigPrettier from 'eslint-config-prettier';
import eslintPluginSvelte from 'eslint-plugin-svelte';
import globals from 'globals'; import globals from 'globals';
import tsEslint from 'typescript-eslint';
import pluginImportX from 'eslint-plugin-import-x'; import pluginImportX from 'eslint-plugin-import-x';
// Flat config support: https://github.com/storybookjs/eslint-plugin-storybook/pull/156 import ts from 'typescript-eslint';
import storybook from 'eslint-plugin-storybook';
import svelteParser from 'svelte-eslint-parser';
export default tsEslint.config( export default ts.config(
js.configs.recommended, js.configs.recommended,
...storybook.configs['flat/recommended'], ...ts.configs.recommended,
...tsEslint.configs.recommended, ...svelte.configs['flat/recommended'],
...eslintPluginSvelte.configs['flat/recommended'], prettier,
eslintConfigPrettier, ...svelte.configs['flat/prettier'],
...eslintPluginSvelte.configs['flat/prettier'],
{ {
files: ['apps/desktop/e2e/**'],
languageOptions: { languageOptions: {
ecmaVersion: 2021,
sourceType: 'module',
globals: { globals: {
...globals.node,
...globals.browser, ...globals.browser,
...globals.mocha, ...globals.node
...globals.chai,
$: false
}
}
},
{
files: ['**/*.svelte'],
languageOptions: {
ecmaVersion: 2021,
sourceType: 'module',
globals: {
...globals.node,
...globals.browser,
$state: 'readonly',
$derived: 'readonly',
$props: 'readonly',
$bindable: 'readonly',
$inspect: 'readonly',
$host: 'readonly',
$effect: 'readonly'
}, },
parser: svelteParser,
parserOptions: { parserOptions: {
parser: tsParser, projectService: true,
extraFileExtensions: ['.svelte'], allowDefaultProject: ['*.svelte'],
svelteFeatures: {
experimentalGenerics: true
}
}
}
},
{
ignores: [
'**/.*', // dotfiles aren't ignored by default in FlatConfig
'.*', // dotfiles aren't ignored by default in FlatConfig
'**/.DS_Store',
'**/node_modules',
'**/butler/target',
'**/build',
'**/dist',
'.svelte-kit',
'**/package',
'**/.env',
'**/.env.*',
'!**/.env.example',
'**/pnpm-lock.yaml',
'**/package-lock.json',
'**/yarn.lock',
'.github',
'.vscode',
'src-tauri',
'**/eslint.config.js',
'**/svelte.config.js',
'**/.pnpm-store',
'**/vite.config.ts.timestamp-*',
'!.storybook',
'target/',
'crates/',
'packages/ui/storybook-static',
// We're having issues parsing splat syntax in svelte components
'packages/ui/src/stories/**/*.svelte'
]
},
{
languageOptions: {
parserOptions: {
parser: tsEslint.parser,
project: ['./packages/**/tsconfig.json', './apps/**/tsconfig.json'],
extraFileExtensions: ['.svelte'] extraFileExtensions: ['.svelte']
} }
}, },
rules: { rules: {
eqeqeq: ['error', 'always'], eqeqeq: ['error', 'always'],
'import-x/no-cycle': 'error', 'import-x/no-cycle': 'error',
'import-x/order': [ 'import-x/order': [
'error', 'error',
{ {
@ -165,7 +91,8 @@ export default tsEslint.config(
'./apps/web/tsconfig.json', './apps/web/tsconfig.json',
'./apps/web/.svelte-kit/tsconfig.json', './apps/web/.svelte-kit/tsconfig.json',
'./packages/**/tsconfig.json', './packages/**/tsconfig.json',
'./packages/ui/.svelte-kit/tsconfig.json' './packages/ui/.svelte-kit/tsconfig.json',
'./packages/shared/.svelte-kit/tsconfig.json'
] ]
} }
} }
@ -173,5 +100,42 @@ export default tsEslint.config(
plugins: { plugins: {
'import-x': pluginImportX 'import-x': pluginImportX
} }
},
{
files: ['**/*.svelte'],
languageOptions: {
parserOptions: {
parser: ts.parser
}
}
},
{
ignores: [
'**/.*', // dotfiles aren't ignored by default in FlatConfig
'.*', // dotfiles aren't ignored by default in FlatConfig
'**/.DS_Store',
'**/node_modules',
'**/butler/target',
'**/build',
'**/dist',
'.svelte-kit',
'**/package',
'**/.env',
'**/.env.*',
'!**/.env.example',
'**/pnpm-lock.yaml',
'**/package-lock.json',
'**/yarn.lock',
'.github',
'.vscode',
'**/eslint.config.js',
'**/svelte.config.js',
'**/.pnpm-store',
'**/vite.config.ts.timestamp-*',
'!.storybook',
'target/',
'crates/',
'packages/ui/storybook-static'
]
} }
); );