-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.mjs
74 lines (71 loc) · 2.17 KB
/
eslint.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import eslint from "@eslint/js";
import tsParser from "@typescript-eslint/parser";
import eslintPluginSvelte from "eslint-plugin-svelte";
import globals from "globals";
import svelteParser from "svelte-eslint-parser";
import tseslint from "typescript-eslint";
/**
* Workaround for https://github.com/sveltejs/eslint-plugin-svelte/pull/789#issuecomment-2309033145
*
* @type {{
* [K in keyof typeof eslintPluginSvelte["configs"]]:
* typeof eslintPluginSvelte["configs"][K] extends unknown[]
* ? import("eslint").Linter.Config[]
* : import("eslint").Linter.Config
* }} */
const eslintPluginSvelteConfigs = eslintPluginSvelte.configs;
/**
* Note: must be consistent per tsconfig project: https://github.com/typescript-eslint/typescript-eslint/issues/6778#issuecomment-1484725834
* @type {import("@typescript-eslint/parser").ParserOptions}
*/
const parserOptions = {
projectService: {
allowDefaultProject: ["*.js", "*.mjs"],
defaultProject: "tsconfig.default.json",
},
tsconfigRootDir: import.meta.dirname,
extraFileExtensions: [".svelte"],
};
export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.strictTypeChecked,
...eslintPluginSvelteConfigs["flat/recommended"],
...eslintPluginSvelteConfigs["flat/prettier"],
{
languageOptions: {
parser: tsParser,
parserOptions,
},
rules: {
curly: ["error"],
"object-shorthand": ["error", "always"],
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unnecessary-condition": [
"error",
{ allowConstantLoopConditions: true },
],
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
},
],
"@typescript-eslint/restrict-template-expressions": ["error", { allowNumber: true }],
"@typescript-eslint/switch-exhaustiveness-check": "error",
},
},
{
files: ["**/*.svelte", "*.svelte"],
languageOptions: {
parser: svelteParser,
parserOptions: {
parser: tsParser,
...parserOptions,
},
globals: {
...globals.browser,
},
},
},
);