-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Expand file tree
/
Copy patheslint.config.js
More file actions
186 lines (176 loc) · 4.92 KB
/
Copy patheslint.config.js
File metadata and controls
186 lines (176 loc) · 4.92 KB
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import tsPlugin from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
import importPlugin from "eslint-plugin-import";
import unusedImports from "eslint-plugin-unused-imports";
export default [
{
files: ["**/*.ts", "**/*.tsx"],
plugins: {
"@typescript-eslint": tsPlugin,
import: importPlugin,
"unused-imports": unusedImports,
},
languageOptions: {
parser: tsParser,
parserOptions: {
project: "./tsconfig.json",
ecmaVersion: "latest",
sourceType: "module",
},
},
rules: {
// Core rules - all as errors
"max-classes-per-file": ["error", 1],
"prefer-const": "error",
// "class-methods-use-this": [
// "error",
// {
// exceptMethods: [
// "render",
// "shouldComponentUpdate",
// "componentDidMount",
// "componentDidUpdate",
// "componentWillUnmount",
// ],
// },
// ],
"no-negated-condition": "error",
"max-lines": [
"error",
{ max: 500, skipBlankLines: true, skipComments: true },
],
complexity: ["error", { max: 30 }],
// "max-lines-per-function": [
// "error",
// { max: 150, skipBlankLines: true, skipComments: true },
// ],
"max-statements": ["error", { max: 50 }],
"max-depth": ["error", { max: 4 }],
"max-nested-callbacks": ["error", { max: 3 }],
"max-params": ["error", { max: 5 }],
eqeqeq: "error",
// TypeScript specific rules
// "@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-explicit-any": "error",
// "@typescript-eslint/member-ordering": [
// "error",
// {
// default: [
// // Static fields
// "public-static-field",
// "protected-static-field",
// "private-static-field",
// // Instance fields
// "public-instance-field",
// "protected-instance-field",
// "private-instance-field",
// // Constructors
// "constructor",
// // Static methods
// "public-static-method",
// "protected-static-method",
// "private-static-method",
// // Instance methods
// "public-instance-method",
// "protected-instance-method",
// "private-instance-method",
// ],
// },
// ],
// Import rules
"import/order": [
"error",
{
groups: [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index",
],
"newlines-between": "always",
alphabetize: {
order: "asc",
caseInsensitive: true,
},
},
],
"import/no-default-export": "error",
// Unused code detection
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "off",
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"error",
{
vars: "all",
varsIgnorePattern: "^_",
args: "after-used",
argsIgnorePattern: "^_",
},
],
// Turn off rules that might be too strict for CLI
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-non-null-assertion": "off",
// Allow console for CLI tool
"no-console": "off",
},
settings: {
"import/resolver": {
typescript: {
project: "./tsconfig.json",
},
node: true,
},
},
},
{
// Allow default exports in specific files
files: ["src/index.ts", "*.config.js", "*.config.ts"],
rules: {
"import/no-default-export": "off",
},
},
{
// Test files can have different rules
files: [
"**/*.test.ts",
"**/*.test.tsx",
"**/*.spec.ts",
"**/*.spec.tsx",
"**/test-helpers/**/*.ts",
"**/test-helpers/**/*.tsx",
"**/__tests__/**/*.ts",
"**/__tests__/**/*.tsx",
"**/__mocks__/**/*.ts",
"**/__mocks__/**/*.tsx",
],
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-floating-promises": "off",
"unused-imports/no-unused-vars": "off",
"max-classes-per-file": "off",
"max-lines": "off",
"max-lines-per-function": "off",
"max-statements": "off",
complexity: "off",
"class-methods-use-this": "off",
"max-nested-callbacks": "off",
},
},
{
ignores: [
"dist/**",
"node_modules/**",
"coverage/**",
"*.d.ts",
"src/__mocks__/**",
"vitest.config.ts",
"*.config.js",
"*.config.ts",
],
},
];