|
| 1 | +import { includeIgnoreFile } from '@eslint/compat' |
| 2 | +import js from '@eslint/js' |
| 3 | +import prettier from 'eslint-config-prettier' |
| 4 | +import svelte from 'eslint-plugin-svelte' |
| 5 | +import globals from 'globals' |
| 6 | +import { fileURLToPath } from 'node:url' |
| 7 | +import ts from 'typescript-eslint' |
| 8 | +const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url)) |
| 9 | + |
| 10 | +export default [ |
| 11 | + includeIgnoreFile(gitignorePath), |
| 12 | + { |
| 13 | + ignores: [ |
| 14 | + '**/.DS_Store', |
| 15 | + '**/node_modules', |
| 16 | + 'postcss.config.cjs', |
| 17 | + '**/build', |
| 18 | + '.svelte-kit', |
| 19 | + 'package', |
| 20 | + '**/.env', |
| 21 | + '**/.env.*', |
| 22 | + '!**/.env.example', |
| 23 | + '**/pnpm-lock.yaml', |
| 24 | + '**/package-lock.json', |
| 25 | + '**/yarn.lock', |
| 26 | + 'src/routes/poc', |
| 27 | + '**/dist', |
| 28 | + 'vite.config.ts.*' |
| 29 | + ] |
| 30 | + }, |
| 31 | + js.configs.recommended, |
| 32 | + ...ts.configs.recommended, |
| 33 | + ...svelte.configs['flat/recommended'], |
| 34 | + prettier, |
| 35 | + ...svelte.configs['flat/prettier'], |
| 36 | + { |
| 37 | + languageOptions: { |
| 38 | + globals: { |
| 39 | + ...globals.browser, |
| 40 | + ...globals.node |
| 41 | + } |
| 42 | + }, |
| 43 | + |
| 44 | + rules: { |
| 45 | + semi: ['warn', 'never'], |
| 46 | + quotes: ['error', 'single'], |
| 47 | + 'dot-location': ['warn', 'property'], |
| 48 | + 'guard-for-in': ['warn'], |
| 49 | + 'no-multi-spaces': ['warn'], |
| 50 | + yoda: ['warn', 'never'], |
| 51 | + camelcase: ['error'], |
| 52 | + 'comma-style': ['warn'], |
| 53 | + 'comma-dangle': ['off', 'always-multiline'], |
| 54 | + 'block-spacing': ['warn'], |
| 55 | + 'keyword-spacing': ['warn'], |
| 56 | + 'no-trailing-spaces': ['warn'], |
| 57 | + 'no-unneeded-ternary': ['warn'], |
| 58 | + 'no-whitespace-before-property': ['warn'], |
| 59 | + 'object-curly-spacing': ['warn', 'always'], |
| 60 | + 'space-before-blocks': ['warn'], |
| 61 | + 'space-in-parens': ['warn'], |
| 62 | + 'arrow-spacing': ['warn'], |
| 63 | + 'no-duplicate-imports': ['error'], |
| 64 | + 'no-var': ['error'], |
| 65 | + 'prefer-const': ['error'], |
| 66 | + |
| 67 | + 'no-unused-vars': [ |
| 68 | + 'warn', |
| 69 | + { |
| 70 | + argsIgnorePattern: '^_', |
| 71 | + ignoreRestSiblings: true |
| 72 | + } |
| 73 | + ], |
| 74 | + '@typescript-eslint/no-unused-expressions': [ |
| 75 | + 'error', |
| 76 | + { |
| 77 | + allowShortCircuit: true, |
| 78 | + allowTernary: true, |
| 79 | + allowTaggedTemplates: true |
| 80 | + } |
| 81 | + ] |
| 82 | + } |
| 83 | + }, |
| 84 | + { |
| 85 | + files: ['**/*.svelte'], |
| 86 | + languageOptions: { |
| 87 | + parserOptions: { |
| 88 | + parser: ts.parser |
| 89 | + } |
| 90 | + } |
| 91 | + }, |
| 92 | + { |
| 93 | + /* location of your components where you would like to apply these rules */ |
| 94 | + files: ['**/shadcn/components/ui/**/*.svelte', '**/shadcn/components/ui/**/*.ts'], |
| 95 | + languageOptions: { |
| 96 | + parserOptions: { |
| 97 | + parser: ts.parser |
| 98 | + } |
| 99 | + }, |
| 100 | + rules: { |
| 101 | + '@typescript-eslint/no-unused-vars': [ |
| 102 | + 'warn', |
| 103 | + { |
| 104 | + argsIgnorePattern: '^_', |
| 105 | + varsIgnorePattern: '^\\$\\$(Props|Events|Slots|Generic)$' |
| 106 | + } |
| 107 | + ], |
| 108 | + 'prefer-const': ['off'], |
| 109 | + 'no-unused-vars': ['off'] |
| 110 | + } |
| 111 | + } |
| 112 | +] |
0 commit comments