|
| 1 | +import markdown from 'eslint-plugin-markdown'; |
| 2 | +import globals from 'globals'; |
| 3 | +import n from 'eslint-plugin-n'; |
| 4 | +import svelteOrgEslintConfig from '@sveltejs/eslint-config'; |
| 5 | +import svelteParser from 'svelte-eslint-parser'; |
| 6 | +export default [ |
| 7 | + { |
| 8 | + name: 'local/ignores', |
| 9 | + ignores: [ |
| 10 | + '**/temp/**', |
| 11 | + '**/dist/**', |
| 12 | + '**/build/**', |
| 13 | + '**/.svelte-kit/**', |
| 14 | + '**/.svelte/**', |
| 15 | + 'packages/playground/big/src/pages/**', // lots of generated files |
| 16 | + 'packages/*/types/index.d.ts', |
| 17 | + 'packages/*/types/index.d.ts.map', |
| 18 | + 'packages/*/CHANGELOG.md' |
| 19 | + ] |
| 20 | + }, |
| 21 | + ...svelteOrgEslintConfig, // contains setup for svelte, typescript and unicorn |
| 22 | + n.configs['flat/recommended-module'], |
| 23 | + ...markdown.configs.recommended, |
| 24 | + { |
| 25 | + name: 'local/language-options', |
| 26 | + languageOptions: { |
| 27 | + ecmaVersion: 2022, |
| 28 | + sourceType: 'module' |
| 29 | + } |
| 30 | + }, |
| 31 | + { |
| 32 | + name: 'local/generic-rules', |
| 33 | + rules: { |
| 34 | + 'n/no-unsupported-features/es-builtins': 'error', |
| 35 | + 'n/no-unsupported-features/es-syntax': 'error', |
| 36 | + 'no-console': 'off', |
| 37 | + 'no-debugger': 'error', |
| 38 | + |
| 39 | + 'n/no-extraneous-import': [ |
| 40 | + 'error', |
| 41 | + { |
| 42 | + allowModules: ['vite', 'vitest'] |
| 43 | + } |
| 44 | + ], |
| 45 | + |
| 46 | + 'no-restricted-properties': [ |
| 47 | + 'error', |
| 48 | + { |
| 49 | + property: 'substr', |
| 50 | + message: 'Use .slice instead of .substr.' |
| 51 | + } |
| 52 | + ], |
| 53 | + |
| 54 | + 'n/no-unpublished-import': 'off', |
| 55 | + 'n/no-unpublished-require': 'off', |
| 56 | + 'no-process-exit': 'off', |
| 57 | + |
| 58 | + 'prefer-const': [ |
| 59 | + 'error', |
| 60 | + { |
| 61 | + destructuring: 'all' |
| 62 | + } |
| 63 | + ], |
| 64 | + |
| 65 | + quotes: [ |
| 66 | + 'error', |
| 67 | + 'single', |
| 68 | + { |
| 69 | + avoidEscape: true |
| 70 | + } |
| 71 | + ], |
| 72 | + |
| 73 | + 'unicorn/prefer-node-protocol': 'error' |
| 74 | + } |
| 75 | + }, |
| 76 | + { |
| 77 | + name: 'local/packages-src', |
| 78 | + files: ['packages/*/src/**'], |
| 79 | + rules: { |
| 80 | + 'no-console': 'error' |
| 81 | + } |
| 82 | + }, |
| 83 | + { |
| 84 | + name: 'local/inspector-extras', |
| 85 | + files: [ |
| 86 | + 'packages/vite-plugin-svelte-inspector/src/runtime/load-inspector.js', |
| 87 | + 'packages/vite-plugin-svelte-inspector/src/runtime/Inspector.svelte' |
| 88 | + ], |
| 89 | + |
| 90 | + languageOptions: { |
| 91 | + globals: { |
| 92 | + ...globals.browser |
| 93 | + } |
| 94 | + }, |
| 95 | + rules: { |
| 96 | + 'n/no-unsupported-features/node-builtins': 'off' |
| 97 | + } |
| 98 | + }, |
| 99 | + { |
| 100 | + name: 'local/tests-and-playground-rules', |
| 101 | + files: ['packages/e2e-tests/**', 'packages/playground/**'], |
| 102 | + |
| 103 | + rules: { |
| 104 | + 'n/no-extraneous-import': 'off' |
| 105 | + } |
| 106 | + }, |
| 107 | + { |
| 108 | + name: 'local/svelte-files', |
| 109 | + files: ['**/*.svelte'], |
| 110 | + |
| 111 | + languageOptions: { |
| 112 | + globals: { |
| 113 | + ...globals.browser |
| 114 | + }, |
| 115 | + parserOptions: { |
| 116 | + parser: '@typescript-eslint/parser' |
| 117 | + } |
| 118 | + }, |
| 119 | + |
| 120 | + rules: { |
| 121 | + 'n/no-missing-import': 'off' // n doesn't know some vite specifics or monorepo imports. |
| 122 | + } |
| 123 | + }, |
| 124 | + { |
| 125 | + name: 'local/svelte-runes-globals', |
| 126 | + files: ['**/*.svelte.js', '**/*.svelte.ts', '**/*.svelte.*.js', '**/*.svelte.*.ts'], |
| 127 | + languageOptions: { |
| 128 | + parser: svelteParser |
| 129 | + } |
| 130 | + }, |
| 131 | + { |
| 132 | + name: 'local/markdown-codefences', |
| 133 | + files: ['**/*.md/*.js', '**/*.md/*.ts', '**/*.md/*.svelte'], |
| 134 | + rules: { |
| 135 | + 'n/no-missing-import': 'off', |
| 136 | + '@typescript-eslint/no-unused-vars': 'off' |
| 137 | + } |
| 138 | + }, |
| 139 | + { |
| 140 | + name: 'local/spec-files', |
| 141 | + files: ['**/__tests__/**/*.spec.ts'], |
| 142 | + |
| 143 | + languageOptions: { |
| 144 | + globals: { |
| 145 | + ...globals.jest, |
| 146 | + ...globals.node, |
| 147 | + ...globals.browser |
| 148 | + } |
| 149 | + }, |
| 150 | + rules: { |
| 151 | + 'n/no-missing-import': 'off' |
| 152 | + } |
| 153 | + }, |
| 154 | + { |
| 155 | + name: 'local/allow-unused-vars', |
| 156 | + files: ['**/vite.config.*', 'packages/e2e-tests/**', '**/*.d.ts'], |
| 157 | + rules: { |
| 158 | + 'no-unused-vars': 'off', |
| 159 | + '@typescript-eslint/no-unused-vars': 'off' |
| 160 | + } |
| 161 | + } |
| 162 | +]; |
0 commit comments