-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.js
146 lines (145 loc) · 4.42 KB
/
eslint.config.js
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
142
143
144
145
146
import globals from "globals";
import js from "@eslint/js";
import prettier from "eslint-config-prettier";
import svelte from "eslint-plugin-svelte";
import svelteParser from "svelte-eslint-parser";
import ts from "typescript-eslint";
export default [
...[
js.configs.recommended,
...ts.configs.recommended,
prettier,
{
languageOptions: {
parser: ts.parser,
parserOptions: {
project: "./tsconfig.json",
tsconfigRootDir: import.meta.dirname,
extraFileExtensions: [".svelte"],
},
globals: { ...globals.browser, ...globals.node },
},
rules: {
"no-implicit-globals": "error",
"no-restricted-globals": [
"error",
"name",
"event",
"frames",
"history",
"length",
"content",
"origin",
"status",
],
// Require using arrow functions as callbacks.
// https://eslint.org/docs/rules/prefer-arrow-callback
"prefer-arrow-callback": "warn",
// Require using const for variables that are never modified after declared.
// https://eslint.org/docs/rules/prefer-const
"prefer-const": "warn",
// Disallow modifying variables that are declared using const.
// https://eslint.org/docs/rules/no-const-assign
"no-const-assign": "error",
// Require let or const instead of var.
// https://eslint.org/docs/rules/no-var
"no-var": "warn",
// Require `===` and `!==` comparisons.
eqeqeq: "warn",
"@typescript-eslint/no-floating-promises": "warn",
"@typescript-eslint/no-empty-function": "warn",
"@typescript-eslint/naming-convention": [
"warn",
{
selector: "enumMember",
format: ["PascalCase"],
},
{
selector: "objectLiteralProperty",
format: ["PascalCase", "camelCase"],
},
{
selector: "default",
format: ["camelCase"],
leadingUnderscore: "allow",
trailingUnderscore: "allow",
},
{
selector: "variable",
modifiers: ["const"],
format: ["camelCase", "PascalCase", "UPPER_CASE"],
leadingUnderscore: "allow",
trailingUnderscore: "allow",
},
{
selector: "typeLike",
format: ["PascalCase"],
},
// Disable @typescript-eslint/naming-convention format for imports
// https://github.com/typescript-eslint/typescript-eslint/pull/7269#issuecomment-1777628591
// https://github.com/typescript-eslint/typescript-eslint/issues/7892
{ selector: "import", format: null },
{
selector: ["objectLiteralProperty"],
modifiers: ["requiresQuotes"],
format: null,
},
],
"@typescript-eslint/no-namespace": [
"error",
{ allowDeclarations: true },
],
"@typescript-eslint/member-ordering": [
"warn",
{ default: ["field", "signature", "constructor", "method"] },
],
// Allow explict type annotations for additional clarity.
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-invalid-void-type": ["warn"],
// Disallow Unused Variables.
// https://eslint.org/docs/rules/no-unused-vars
"@typescript-eslint/no-unused-vars": [
"warn",
{ argsIgnorePattern: "^_" },
],
},
},
].map(conf => ({
...conf,
linterOptions: {
reportUnusedDisableDirectives: "error",
},
files: ["**/*.js", "**/*.ts", "**/*.svelte"],
})),
...svelte.configs["flat/recommended"],
...svelte.configs["flat/prettier"],
{
files: ["*.svelte", "**/*.svelte"],
languageOptions: {
parser: svelteParser,
parserOptions: {
parser: ts.parser,
project: "./tsconfig.json",
tsconfigRootDir: import.meta.dirname,
svelteFeatures: {
experimentalGenerics: true,
},
},
},
rules: {
"svelte/no-at-html-tags": "off",
"@typescript-eslint/no-explicit-any": "error",
},
},
{
ignores: [
"build/*",
"isolation/*",
"node_modules/**/*",
"target/*",
"crates/radicle-tauri/**/*",
"crates/radicle-types/**/*",
"eslint.config.js",
],
},
];