From 3a233b64e39599cf926d00b4b1633292b52ff9e2 Mon Sep 17 00:00:00 2001 From: ndom91 Date: Mon, 21 Oct 2024 11:50:10 +0200 Subject: [PATCH] fix: update eslint.config based on svelte5 example --- eslint.config.js | 136 +++++++++++++++++------------------------------ 1 file changed, 50 insertions(+), 86 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 06ed49d53..4202cf23b 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -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' + ] } );