-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.mjs
162 lines (156 loc) · 4.72 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
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import tsParser from "@typescript-eslint/parser";
import tsPlugin from "@typescript-eslint/eslint-plugin";
import prettierPlugin from "eslint-plugin-prettier";
import importPlugin from "eslint-plugin-import";
import jestPlugin from "eslint-plugin-jest";
import unusedImportsPlugin from "eslint-plugin-unused-imports";
import reactPlugin from "eslint-plugin-react";
export default {
languageOptions: {
globals: {
NodeJS: true,
jest: true,
global: true,
fetch: true,
},
parser: tsParser,
parserOptions: {
projectService: true,
ecmaVersion: 2020,
sourceType: "module",
},
},
files: ["**/*.ts"],
rules: {
// TypeScript rules
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-function": [
"warn",
{ allow: ["arrowFunctions"] },
],
"@typescript-eslint/switch-exhaustiveness-check": "warn",
"@typescript-eslint/await-thenable": "warn",
"@typescript-eslint/no-unnecessary-condition": "warn",
"@typescript-eslint/ban-ts-comment": [
"warn",
{ "ts-ignore": "allow-with-description" },
],
"@typescript-eslint/no-unused-vars": [
"warn",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
"@typescript-eslint/triple-slash-reference": "off",
"@typescript-eslint/require-await": "warn",
"@typescript-eslint/no-floating-promises": "warn",
"@typescript-eslint/no-misused-promises": [
"warn",
{ checksVoidReturn: { attributes: false } },
],
"@typescript-eslint/no-unused-expressions": [
"warn",
{ allowShortCircuit: true, allowTernary: true, enforceForJSX: true },
],
"@typescript-eslint/consistent-type-imports": [
"error",
{ fixStyle: "inline-type-imports" },
],
// Jest rules
"jest/no-focused-tests": "warn",
"jest/no-identical-title": "warn",
"jest/valid-expect": "warn",
"jest/prefer-to-have-length": "warn",
// Unused imports rule
"unused-imports/no-unused-imports": "warn",
// General rules
"arrow-body-style": ["warn", "as-needed"],
curly: ["warn", "all"],
eqeqeq: ["warn", "always"],
"comma-dangle": ["error", "only-multiline"],
"require-await": "error",
"no-undef": ["error"],
"no-var": ["error"],
"object-curly-spacing": ["error", "always"],
quotes: ["error", "double", { allowTemplateLiterals: true }],
semi: ["error", "always"],
"no-console": ["error", { allow: ["warn"] }],
"no-duplicate-imports": "warn",
"no-restricted-imports": [
"warn",
{
paths: [
{
name: "react",
importNames: ["default"],
message: "use `import { <...> } from 'react'` instead",
},
],
},
],
// Import rules
"import/no-extraneous-dependencies": ["error"],
"import/no-cycle": "warn",
"import/no-self-import": "warn",
"import/no-duplicates": ["warn", { "prefer-inline": true }],
"import/order": [
"warn",
{
groups: [
"builtin", // Built-in imports (come from NodeJS native) go first
"external", // <- External imports
"internal", // <- Absolute imports
["sibling", "parent"], // <- Relative imports, the sibling and parent types they can be mingled together
"index", // <- index imports
"unknown", // <- unknown
],
"newlines-between": "always",
alphabetize: {
order: "asc",
caseInsensitive: true,
},
},
],
"sort-imports": [
"warn",
{
ignoreCase: false,
ignoreDeclarationSort: true, // Don't sort import lines, use eslint-plugin-import instead
ignoreMemberSort: false,
memberSyntaxSortOrder: ["none", "all", "multiple", "single"],
allowSeparatedGroups: true,
},
],
"sort-keys": [
"warn", // or "error"
"asc", // "asc" for ascending, "desc" for descending
{
caseSensitive: false,
natural: true, // Whether to use natural ordering for numbers (e.g., "a", "10", "2", "b")
minKeys: 2, // Minimum number of keys required in an object for sorting
},
],
// React-specific rules
"react/jsx-curly-brace-presence": ["warn", "never"],
"react/jsx-key": [
"warn",
{
checkFragmentShorthand: true,
checkKeyMustBeforeSpread: true,
warnOnDuplicates: true,
},
],
},
ignores: ["dist", "node_modules/*"],
plugins: {
"@typescript-eslint": tsPlugin,
prettier: prettierPlugin,
import: importPlugin,
jest: jestPlugin,
"unused-imports": unusedImportsPlugin,
react: reactPlugin,
// "sort-keys": sortKeysPlugin,
},
};