| 1 |
// @ts-check |
| 2 |
|
| 3 |
import eslint from "@eslint/js"; |
| 4 |
import simpleImportSort from "eslint-plugin-simple-import-sort"; |
| 5 |
import eslintPluginSvelte from "eslint-plugin-svelte"; |
| 6 |
import svelteParser from "svelte-eslint-parser"; |
| 7 |
import tseslint from "typescript-eslint"; |
| 8 |
|
| 9 |
const OFF = "off"; |
| 10 |
const ON = "error"; |
| 11 |
|
| 12 |
const tsParserOptions = { |
| 13 |
projectService: true, |
| 14 |
tsconfigRootDir: import.meta.dirname, |
| 15 |
extraFileExtensions: [".svelte"], |
| 16 |
}; |
| 17 |
|
| 18 |
export default tseslint.config( |
| 19 |
eslint.configs.recommended, |
| 20 |
...tseslint.configs.strictTypeChecked, |
| 21 |
...tseslint.configs.stylisticTypeChecked, |
| 22 |
...eslintPluginSvelte.configs["flat/recommended"], |
| 23 |
{ |
| 24 |
languageOptions: { |
| 25 |
parserOptions: tsParserOptions, |
| 26 |
}, |
| 27 |
plugins: { |
| 28 |
"simple-import-sort": simpleImportSort, |
| 29 |
}, |
| 30 |
rules: { |
| 31 |
"no-undef": OFF, // better handled by Typescript |
| 32 |
"no-param-reassign": ON, |
| 33 |
"no-restricted-syntax": [ |
| 34 |
ON, |
| 35 |
"ForInStatement", |
| 36 |
"LabelStatement", |
| 37 |
"WithStatement", |
| 38 |
], |
| 39 |
"@typescript-eslint/consistent-type-imports": ON, |
| 40 |
"@typescript-eslint/explicit-module-boundary-types": ON, |
| 41 |
"@typescript-eslint/promise-function-async": ON, |
| 42 |
"@typescript-eslint/strict-boolean-expressions": ON, |
| 43 |
curly: [ON, "all"], |
| 44 |
eqeqeq: [ON, "smart"], |
| 45 |
"@typescript-eslint/naming-convention": [ |
| 46 |
ON, |
| 47 |
{ |
| 48 |
selector: "variable", |
| 49 |
format: ["camelCase", "PascalCase", "snake_case", "UPPER_CASE"], |
| 50 |
}, |
| 51 |
{ |
| 52 |
selector: "function", |
| 53 |
format: ["camelCase", "PascalCase", "snake_case"], |
| 54 |
}, |
| 55 |
{ |
| 56 |
selector: "typeLike", |
| 57 |
format: ["PascalCase"], |
| 58 |
}, |
| 59 |
], |
| 60 |
// Sort import statements and members alphabetically. |
| 61 |
"simple-import-sort/imports": ON, |
| 62 |
"simple-import-sort/exports": ON, |
| 63 |
}, |
| 64 |
}, |
| 65 |
{ |
| 66 |
files: ["**/*.svelte", "**/*.svelte.ts"], |
| 67 |
languageOptions: { |
| 68 |
parser: svelteParser, |
| 69 |
parserOptions: { |
| 70 |
...tsParserOptions, |
| 71 |
parser: tseslint.parser, |
| 72 |
}, |
| 73 |
}, |
| 74 |
rules: { |
| 75 |
"svelte/button-has-type": ON, |
| 76 |
"svelte/require-each-key": OFF, |
| 77 |
}, |
| 78 |
}, |
| 79 |
); |