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 tsParser from '@typescript-eslint/parser';
import eslintConfigPrettier from 'eslint-config-prettier';
import eslintPluginSvelte from 'eslint-plugin-svelte';
import svelte from 'eslint-plugin-svelte';
import globals from 'globals';
import tsEslint from 'typescript-eslint';
import pluginImportX from 'eslint-plugin-import-x';
// Flat config support: https://github.com/storybookjs/eslint-plugin-storybook/pull/156
import storybook from 'eslint-plugin-storybook';
import svelteParser from 'svelte-eslint-parser';
import ts from 'typescript-eslint';
export default tsEslint.config(
export default ts.config(
js.configs.recommended,
...storybook.configs['flat/recommended'],
...tsEslint.configs.recommended,
...eslintPluginSvelte.configs['flat/recommended'],
eslintConfigPrettier,
...eslintPluginSvelte.configs['flat/prettier'],
...ts.configs.recommended,
...svelte.configs['flat/recommended'],
prettier,
...svelte.configs['flat/prettier'],
{
files: ['apps/desktop/e2e/**'],
languageOptions: {
ecmaVersion: 2021,
sourceType: 'module',
globals: {
...globals.node,
...globals.browser,
...globals.mocha,
...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'
...globals.node
},
parser: svelteParser,
parserOptions: {
parser: tsParser,
extraFileExtensions: ['.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'],
projectService: true,
allowDefaultProject: ['*.svelte'],
extraFileExtensions: ['.svelte']
}
},
rules: {
eqeqeq: ['error', 'always'],
'import-x/no-cycle': 'error',
'import-x/order': [
'error',
{
@ -165,7 +91,8 @@ export default tsEslint.config(
'./apps/web/tsconfig.json',
'./apps/web/.svelte-kit/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: {
'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'
]
}
);