-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.mjs
106 lines (103 loc) · 3.05 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
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
/** @license AGPL-3.0-or-later
*
* Copyright(C) 2025 Hong Xu <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import eslint from "@eslint/js";
import globals from "globals";
import tseslint from "typescript-eslint";
const tsFiles = ["**/*.ts", "**/*.mts"];
export default [
eslint.configs.recommended,
{
ignores: ["dist/*", "docs/*"],
},
{
files: [...tsFiles, "**/*.js", "**/*.mjs"],
rules: {
"no-constant-binary-expression": ["error"],
"no-constructor-return": ["error"],
"no-duplicate-imports": ["error"],
"no-new-native-nonconstructor": ["error"],
"no-self-compare": ["error"],
"no-template-curly-in-string": ["error"],
"no-unneeded-ternary": ["error"],
"no-unreachable-loop": ["error"],
"no-unused-private-class-members": ["error"],
"sort-imports": ["error"],
"unicode-bom": ["error", "never"],
},
},
// Apply ts rules only to ts files
...[
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
].map((elem) => ({
...elem,
files: tsFiles,
})),
{
files: tsFiles,
languageOptions: {
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
project: ["tsconfig.json"],
tsconfigRootDir: import.meta.dirname,
},
globals: {
...globals.node,
},
},
rules: {
"@typescript-eslint/consistent-type-assertions": [
"error",
{
assertionStyle: "never",
},
],
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/no-misused-promises": [
"error",
{
checksVoidReturn: false,
},
],
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
"@typescript-eslint/no-unnecessary-type-assertion": [
"error",
{ typesToIgnore: ["const"] },
],
"@typescript-eslint/restrict-template-expressions": [
"error",
{
allowNumber: true,
},
],
// This must be off otherwise "@typescript-eslint/no-unused-expressions"
// may not work properly. See the doc of
// @typescript-eslint/no-unused-expressions.
"no-unused-expressions": "off",
"@typescript-eslint/no-unused-expressions": "error",
},
},
];