-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.ts
141 lines (134 loc) · 4.54 KB
/
eslint.config.ts
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import { includeIgnoreFile } from "@eslint/compat";
import js from "@eslint/js";
import prettier from "eslint-config-prettier";
import svelte from "eslint-plugin-svelte";
import unicorn from "eslint-plugin-unicorn";
import globals from "globals";
import { fileURLToPath } from "node:url";
import ts from "typescript-eslint";
const gitignorePath = fileURLToPath(new URL("./.gitignore", import.meta.url));
const error = "error";
const warn = "warn";
const off = "off";
export default ts.config(
includeIgnoreFile(gitignorePath),
{ linterOptions: { reportUnusedDisableDirectives: warn } },
js.configs.recommended,
...ts.configs.strictTypeChecked,
...ts.configs.stylisticTypeChecked,
unicorn.configs["flat/recommended"],
...svelte.configs["flat/recommended"],
prettier,
...svelte.configs["flat/prettier"],
{
languageOptions: {
globals: globals.browser,
parserOptions: {
extraFileExtensions: [".svelte"],
projectService: {
allowDefaultProject: [".prettierrc.js"],
},
tsconfigRootDir: import.meta.dirname,
parser: ts.parser,
},
},
},
{
files: ["**/*.{js,ts,svelte}"],
rules: {
"arrow-body-style": warn,
"func-style": [error, "declaration", { allowArrowFunctions: true }],
"no-await-in-loop": warn,
"no-console": warn,
"no-negated-condition": off,
"no-nested-ternary": off,
"no-plusplus": [error, { allowForLoopAfterthoughts: true }],
"no-undef": off,
"no-void": [error, { allowAsStatement: true }],
"operator-assignment": [warn, "always"],
"prefer-destructuring": off,
"prefer-template": warn,
curly: [error, "multi-line"],
eqeqeq: [error],
"@typescript-eslint/ban-ts-comment": [
error,
{
"ts-check": false,
"ts-expect-error": { descriptionFormat: String.raw`^\(TS\d+\): .+$` },
},
],
"@typescript-eslint/explicit-function-return-type": [
warn,
{ allowExpressions: true },
],
"@typescript-eslint/explicit-module-boundary-types": "error",
"@typescript-eslint/naming-convention": off,
"@typescript-eslint/no-confusing-void-expression": warn,
"@typescript-eslint/no-non-null-assertion": off,
"@typescript-eslint/no-unused-vars": [
"error",
{
args: "all",
argsIgnorePattern: "^_",
caughtErrors: "all",
caughtErrorsIgnorePattern: "^_",
destructuredArrayIgnorePattern: "^_",
varsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
"@typescript-eslint/prefer-destructuring": warn,
"@typescript-eslint/prefer-function-type": warn,
"@typescript-eslint/promise-function-async": warn,
"@typescript-eslint/restrict-template-expressions": [
error,
{ allowNumber: true },
],
"@typescript-eslint/return-await": [error, "always"],
"@typescript-eslint/strict-boolean-expressions": warn,
"@typescript-eslint/switch-exhaustiveness-check": error,
"unicorn/relative-url-style": [warn, "always"],
"unicorn/prevent-abbreviations": [
error,
{ allowList: { Props: true, props: true, env: true } },
],
},
},
{
files: ["*.js"],
rules: {
"@typescript-eslint/explicit-function-return-type": off,
"@typescript-eslint/explicit-module-boundary-types": off,
"@typescript-eslint/no-unsafe-assignment": off,
"@typescript-eslint/parameter-properties": off,
"@typescript-eslint/typedef": off,
},
},
{
files: ["**/*.svelte"],
rules: {
// Rules that don't work well with Svelte.
"@typescript-eslint/no-confusing-void-expression": off,
"@typescript-eslint/no-unsafe-argument": off,
"@typescript-eslint/no-unsafe-assignment": off,
"@typescript-eslint/no-unsafe-call": off,
"unicorn/filename-case": off,
// Best Practices
"prefer-const": off,
"svelte/block-lang": [warn, { script: "ts" }],
"svelte/button-has-type": warn,
"svelte/no-inline-styles": warn,
"svelte/prefer-const": warn,
"svelte/require-optimized-style-attribute": warn,
// Stylistic Issues
"svelte/consistent-selector-style": [warn, { style: ["class"] }],
"svelte/html-self-closing": warn,
"svelte/prefer-class-directive": warn,
"svelte/prefer-style-directive": warn,
"svelte/shorthand-attribute": warn,
"svelte/shorthand-directive": warn,
"svelte/sort-attributes": warn,
"svelte/spaced-html-comment": warn,
},
},
);