@nihalgonsalves/esconfig 0.9.22 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -20
- package/eslint.config.react-shared.js +400 -0
- package/eslint.config.shared.js +203 -0
- package/package.json +16 -16
- package/.eslintrc.js +0 -19
- package/.eslintrc.react.js +0 -42
- package/.prettierrc.js +0 -4
- package/eslint-rules-base.js +0 -71
- /package/{tsconfig.json → tsconfig.shared.json} +0 -0
package/README.md
CHANGED
|
@@ -7,14 +7,14 @@ Shared ECMAScript Config (TS, Lint, Prettier)
|
|
|
7
7
|
1. Install
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
|
-
yarn add -D @nihalgonsalves/esconfig typescript eslint prettier
|
|
10
|
+
yarn add -D @nihalgonsalves/esconfig typescript typescript-eslint eslint prettier
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
2. `tsconfig.json`
|
|
14
14
|
|
|
15
15
|
```json
|
|
16
16
|
{
|
|
17
|
-
"extends": "@nihalgonsalves/esconfig",
|
|
17
|
+
"extends": "@nihalgonsalves/esconfig/tsconfig.shared.json",
|
|
18
18
|
"compilerOptions": {
|
|
19
19
|
"outDir": "./build",
|
|
20
20
|
"rootDir": "./src"
|
|
@@ -23,32 +23,35 @@ Shared ECMAScript Config (TS, Lint, Prettier)
|
|
|
23
23
|
}
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
3.
|
|
26
|
+
3. `eslint.config.mjs`
|
|
27
27
|
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
```js
|
|
29
|
+
import tseslint from "typescript-eslint";
|
|
30
|
+
|
|
31
|
+
import sharedConfig from "@nihalgonsalves/esconfig/eslint.config.shared";
|
|
32
|
+
|
|
33
|
+
export default tseslint.config([
|
|
34
|
+
{ ignores: [] },
|
|
35
|
+
...sharedConfig,
|
|
36
|
+
// ... others
|
|
37
|
+
]);
|
|
32
38
|
```
|
|
33
39
|
|
|
34
40
|
If you're using React:
|
|
35
41
|
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
"extends": [
|
|
39
|
-
"./node_modules/@nihalgonsalves/esconfig/.eslintrc",
|
|
40
|
-
"./node_modules/@nihalgonsalves/esconfig/.eslintrc.react"
|
|
41
|
-
]
|
|
42
|
-
}
|
|
43
|
-
```
|
|
42
|
+
```js
|
|
43
|
+
import tseslint from "typescript-eslint";
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
import sharedConfig from "@nihalgonsalves/esconfig/eslint.config.react-shared";
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
export default tseslint.config([
|
|
48
|
+
{ ignores: [] },
|
|
49
|
+
...sharedConfig,
|
|
50
|
+
// ... others
|
|
51
|
+
]);
|
|
49
52
|
```
|
|
50
53
|
|
|
51
|
-
|
|
54
|
+
4. `package.json`
|
|
52
55
|
|
|
53
56
|
```json
|
|
54
57
|
{
|
|
@@ -61,4 +64,4 @@ Shared ECMAScript Config (TS, Lint, Prettier)
|
|
|
61
64
|
}
|
|
62
65
|
```
|
|
63
66
|
|
|
64
|
-
|
|
67
|
+
5. Done! Don't forget to run `build`, `lint` and `format:check` in your CI workflow.
|
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
// @ts-expect-error no types
|
|
2
|
+
import prettierConfig from "eslint-config-prettier";
|
|
3
|
+
// @ts-expect-error no types
|
|
4
|
+
import jsxA11y from "eslint-plugin-jsx-a11y";
|
|
5
|
+
// @ts-expect-error no types
|
|
6
|
+
import react from "eslint-plugin-react";
|
|
7
|
+
// @ts-expect-error no types
|
|
8
|
+
import reactHooks from "eslint-plugin-react-hooks";
|
|
9
|
+
import tseslint from "typescript-eslint";
|
|
10
|
+
|
|
11
|
+
import sharedConfig from "./eslint.config.shared.js";
|
|
12
|
+
/** @type {Record<string, any>} */
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
14
|
+
const reactRules = react.config.recommended.rules;
|
|
15
|
+
export default tseslint.config(
|
|
16
|
+
...sharedConfig,
|
|
17
|
+
{
|
|
18
|
+
plugins: {
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
20
|
+
react,
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
22
|
+
"react-hooks": reactHooks,
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
24
|
+
"jsx-a11y": jsxA11y,
|
|
25
|
+
},
|
|
26
|
+
settings: {
|
|
27
|
+
react: { version: "detect" },
|
|
28
|
+
},
|
|
29
|
+
rules: {
|
|
30
|
+
...reactRules,
|
|
31
|
+
"react/react-in-jsx-scope": "off",
|
|
32
|
+
"react/checked-requires-onchange-or-readonly": [
|
|
33
|
+
"off",
|
|
34
|
+
{
|
|
35
|
+
ignoreMissingProperties: false,
|
|
36
|
+
ignoreExclusiveCheckedAttribute: false,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
"react/forbid-prop-types": [
|
|
40
|
+
"error",
|
|
41
|
+
{
|
|
42
|
+
forbid: ["any", "array", "object"],
|
|
43
|
+
checkContextTypes: true,
|
|
44
|
+
checkChildContextTypes: true,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
"react/jsx-boolean-value": ["error", "never", { always: [] }],
|
|
48
|
+
"react/jsx-handler-names": [
|
|
49
|
+
"off",
|
|
50
|
+
{
|
|
51
|
+
eventHandlerPrefix: "handle",
|
|
52
|
+
eventHandlerPropPrefix: "on",
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
"react/jsx-no-bind": [
|
|
56
|
+
"error",
|
|
57
|
+
{
|
|
58
|
+
ignoreRefs: true,
|
|
59
|
+
allowArrowFunctions: true,
|
|
60
|
+
allowFunctions: false,
|
|
61
|
+
allowBind: false,
|
|
62
|
+
ignoreDOMComponents: true,
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
"react/jsx-no-literals": ["off", { noStrings: true }],
|
|
66
|
+
"react/jsx-pascal-case": [
|
|
67
|
+
"error",
|
|
68
|
+
{
|
|
69
|
+
allowAllCaps: true,
|
|
70
|
+
ignore: [],
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
"react/sort-prop-types": [
|
|
74
|
+
"off",
|
|
75
|
+
{
|
|
76
|
+
ignoreCase: true,
|
|
77
|
+
callbacksLast: false,
|
|
78
|
+
requiredFirst: false,
|
|
79
|
+
sortShapeProp: true,
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
"react/no-danger": "warn",
|
|
83
|
+
"react/no-did-mount-set-state": "off",
|
|
84
|
+
"react/no-did-update-set-state": "error",
|
|
85
|
+
"react/no-will-update-set-state": "error",
|
|
86
|
+
"react/no-multi-comp": "off",
|
|
87
|
+
"react/no-set-state": "off",
|
|
88
|
+
"react/prefer-es6-class": ["error", "always"],
|
|
89
|
+
"react/prefer-stateless-function": [
|
|
90
|
+
"error",
|
|
91
|
+
{ ignorePureComponents: true },
|
|
92
|
+
],
|
|
93
|
+
"react/prop-types": [
|
|
94
|
+
"error",
|
|
95
|
+
{
|
|
96
|
+
ignore: [],
|
|
97
|
+
customValidators: [],
|
|
98
|
+
skipUndeclared: false,
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
"react/require-render-return": "error",
|
|
102
|
+
"react/self-closing-comp": "error",
|
|
103
|
+
"react/sort-comp": [
|
|
104
|
+
"error",
|
|
105
|
+
{
|
|
106
|
+
order: [
|
|
107
|
+
"static-variables",
|
|
108
|
+
"static-methods",
|
|
109
|
+
"instance-variables",
|
|
110
|
+
"lifecycle",
|
|
111
|
+
"/^handle.+$/",
|
|
112
|
+
"/^on.+$/",
|
|
113
|
+
"getters",
|
|
114
|
+
"setters",
|
|
115
|
+
"/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/",
|
|
116
|
+
"instance-methods",
|
|
117
|
+
"everything-else",
|
|
118
|
+
"rendering",
|
|
119
|
+
],
|
|
120
|
+
groups: {
|
|
121
|
+
lifecycle: [
|
|
122
|
+
"displayName",
|
|
123
|
+
"propTypes",
|
|
124
|
+
"contextTypes",
|
|
125
|
+
"childContextTypes",
|
|
126
|
+
"mixins",
|
|
127
|
+
"statics",
|
|
128
|
+
"defaultProps",
|
|
129
|
+
"constructor",
|
|
130
|
+
"getDefaultProps",
|
|
131
|
+
"getInitialState",
|
|
132
|
+
"state",
|
|
133
|
+
"getChildContext",
|
|
134
|
+
"getDerivedStateFromProps",
|
|
135
|
+
"componentWillMount",
|
|
136
|
+
"UNSAFE_componentWillMount",
|
|
137
|
+
"componentDidMount",
|
|
138
|
+
"componentWillReceiveProps",
|
|
139
|
+
"UNSAFE_componentWillReceiveProps",
|
|
140
|
+
"shouldComponentUpdate",
|
|
141
|
+
"componentWillUpdate",
|
|
142
|
+
"UNSAFE_componentWillUpdate",
|
|
143
|
+
"getSnapshotBeforeUpdate",
|
|
144
|
+
"componentDidUpdate",
|
|
145
|
+
"componentDidCatch",
|
|
146
|
+
"componentWillUnmount",
|
|
147
|
+
],
|
|
148
|
+
rendering: ["/^render.+$/", "render"],
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
"react/jsx-first-prop-new-line": ["error", "multiline-multiprop"],
|
|
153
|
+
"react/jsx-equals-spacing": ["error", "never"],
|
|
154
|
+
"react/jsx-indent": ["error", 2],
|
|
155
|
+
"react/jsx-filename-extension": [
|
|
156
|
+
"error",
|
|
157
|
+
{ extensions: [".jsx", ".tsx"] },
|
|
158
|
+
],
|
|
159
|
+
"react/require-optimization": ["off", { allowDecorators: [] }],
|
|
160
|
+
"react/forbid-component-props": ["off", { forbid: [] }],
|
|
161
|
+
"react/forbid-elements": ["off", { forbid: [] }],
|
|
162
|
+
"react/no-unused-prop-types": [
|
|
163
|
+
"error",
|
|
164
|
+
{
|
|
165
|
+
customValidators: [],
|
|
166
|
+
skipShapeProps: true,
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
"react/style-prop-object": "error",
|
|
170
|
+
"react/no-array-index-key": "error",
|
|
171
|
+
"react/void-dom-elements-no-children": "error",
|
|
172
|
+
"react/default-props-match-prop-types": [
|
|
173
|
+
"error",
|
|
174
|
+
{ allowRequiredDefaults: false },
|
|
175
|
+
],
|
|
176
|
+
"react/no-redundant-should-component-update": "error",
|
|
177
|
+
"react/no-unused-state": "error",
|
|
178
|
+
"react/jsx-curly-brace-presence": [
|
|
179
|
+
"error",
|
|
180
|
+
{ props: "never", children: "never" },
|
|
181
|
+
],
|
|
182
|
+
"react/destructuring-assignment": ["error", "always"],
|
|
183
|
+
"react/no-access-state-in-setstate": "error",
|
|
184
|
+
"react/button-has-type": [
|
|
185
|
+
"error",
|
|
186
|
+
{
|
|
187
|
+
button: true,
|
|
188
|
+
submit: true,
|
|
189
|
+
reset: false,
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
"react/no-this-in-sfc": "error",
|
|
193
|
+
"react/jsx-fragments": ["error", "syntax"],
|
|
194
|
+
"react/state-in-constructor": ["error", "never"],
|
|
195
|
+
"react/static-property-placement": ["error", "static public field"],
|
|
196
|
+
"react/jsx-no-script-url": [
|
|
197
|
+
"error",
|
|
198
|
+
[
|
|
199
|
+
{
|
|
200
|
+
name: "Link",
|
|
201
|
+
props: ["to"],
|
|
202
|
+
},
|
|
203
|
+
],
|
|
204
|
+
],
|
|
205
|
+
"react/jsx-no-useless-fragment": ["error", { allowExpressions: true }],
|
|
206
|
+
"react/jsx-no-constructed-context-values": "error",
|
|
207
|
+
"react/no-unstable-nested-components": ["error", { allowAsProps: true }],
|
|
208
|
+
"react/no-namespace": "error",
|
|
209
|
+
"react/prefer-exact-props": "error",
|
|
210
|
+
"react/no-arrow-function-lifecycle": "error",
|
|
211
|
+
"react/no-invalid-html-attribute": "error",
|
|
212
|
+
"react/no-unused-class-component-methods": "error",
|
|
213
|
+
"react/hook-use-state": "error",
|
|
214
|
+
"react/iframe-missing-sandbox": "error",
|
|
215
|
+
"react/jsx-no-leaked-render": "error",
|
|
216
|
+
"react-hooks/rules-of-hooks": "error",
|
|
217
|
+
"react-hooks/exhaustive-deps": "error",
|
|
218
|
+
"react/require-default-props": "off",
|
|
219
|
+
"react/jsx-key": [
|
|
220
|
+
"error",
|
|
221
|
+
{
|
|
222
|
+
checkFragmentShorthand: true,
|
|
223
|
+
checkKeyMustBeforeSpread: true,
|
|
224
|
+
warnOnDuplicates: true,
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
"jsx-a11y/alt-text": [
|
|
228
|
+
"error",
|
|
229
|
+
{
|
|
230
|
+
elements: ["img", "object", "area", 'input[type="image"]'],
|
|
231
|
+
img: [],
|
|
232
|
+
object: [],
|
|
233
|
+
area: [],
|
|
234
|
+
'input[type="image"]': [],
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
"jsx-a11y/anchor-has-content": ["error", { components: [] }],
|
|
238
|
+
"jsx-a11y/anchor-is-valid": [
|
|
239
|
+
"error",
|
|
240
|
+
{
|
|
241
|
+
components: ["Link"],
|
|
242
|
+
specialLink: ["to"],
|
|
243
|
+
aspects: ["noHref", "invalidHref", "preferButton"],
|
|
244
|
+
},
|
|
245
|
+
],
|
|
246
|
+
"jsx-a11y/aria-activedescendant-has-tabindex": "error",
|
|
247
|
+
"jsx-a11y/aria-props": "error",
|
|
248
|
+
"jsx-a11y/aria-proptypes": "error",
|
|
249
|
+
"jsx-a11y/aria-role": ["error", { ignoreNonDOM: false }],
|
|
250
|
+
"jsx-a11y/aria-unsupported-elements": "error",
|
|
251
|
+
"jsx-a11y/autocomplete-valid": [
|
|
252
|
+
"error",
|
|
253
|
+
{
|
|
254
|
+
inputComponents: [],
|
|
255
|
+
},
|
|
256
|
+
],
|
|
257
|
+
"jsx-a11y/click-events-have-key-events": "error",
|
|
258
|
+
"jsx-a11y/control-has-associated-label": [
|
|
259
|
+
"error",
|
|
260
|
+
{
|
|
261
|
+
labelAttributes: ["label"],
|
|
262
|
+
controlComponents: [],
|
|
263
|
+
ignoreElements: [
|
|
264
|
+
"audio",
|
|
265
|
+
"canvas",
|
|
266
|
+
"embed",
|
|
267
|
+
"input",
|
|
268
|
+
"textarea",
|
|
269
|
+
"tr",
|
|
270
|
+
"video",
|
|
271
|
+
],
|
|
272
|
+
ignoreRoles: [
|
|
273
|
+
"grid",
|
|
274
|
+
"listbox",
|
|
275
|
+
"menu",
|
|
276
|
+
"menubar",
|
|
277
|
+
"radiogroup",
|
|
278
|
+
"row",
|
|
279
|
+
"tablist",
|
|
280
|
+
"toolbar",
|
|
281
|
+
"tree",
|
|
282
|
+
"treegrid",
|
|
283
|
+
],
|
|
284
|
+
depth: 5,
|
|
285
|
+
},
|
|
286
|
+
],
|
|
287
|
+
"jsx-a11y/heading-has-content": ["error", { components: [""] }],
|
|
288
|
+
"jsx-a11y/html-has-lang": "error",
|
|
289
|
+
"jsx-a11y/iframe-has-title": "error",
|
|
290
|
+
"jsx-a11y/img-redundant-alt": "error",
|
|
291
|
+
"jsx-a11y/interactive-supports-focus": "error",
|
|
292
|
+
"jsx-a11y/label-has-associated-control": [
|
|
293
|
+
"error",
|
|
294
|
+
{
|
|
295
|
+
labelComponents: [],
|
|
296
|
+
labelAttributes: [],
|
|
297
|
+
controlComponents: [],
|
|
298
|
+
assert: "both",
|
|
299
|
+
depth: 25,
|
|
300
|
+
},
|
|
301
|
+
],
|
|
302
|
+
"jsx-a11y/lang": "error",
|
|
303
|
+
"jsx-a11y/media-has-caption": [
|
|
304
|
+
"error",
|
|
305
|
+
{
|
|
306
|
+
audio: [],
|
|
307
|
+
video: [],
|
|
308
|
+
track: [],
|
|
309
|
+
},
|
|
310
|
+
],
|
|
311
|
+
"jsx-a11y/mouse-events-have-key-events": "error",
|
|
312
|
+
"jsx-a11y/no-access-key": "error",
|
|
313
|
+
"jsx-a11y/no-autofocus": ["error", { ignoreNonDOM: true }],
|
|
314
|
+
"jsx-a11y/no-distracting-elements": [
|
|
315
|
+
"error",
|
|
316
|
+
{
|
|
317
|
+
elements: ["marquee", "blink"],
|
|
318
|
+
},
|
|
319
|
+
],
|
|
320
|
+
"jsx-a11y/no-interactive-element-to-noninteractive-role": [
|
|
321
|
+
"error",
|
|
322
|
+
{
|
|
323
|
+
tr: ["none", "presentation"],
|
|
324
|
+
},
|
|
325
|
+
],
|
|
326
|
+
"jsx-a11y/no-noninteractive-element-interactions": [
|
|
327
|
+
"error",
|
|
328
|
+
{
|
|
329
|
+
handlers: [
|
|
330
|
+
"onClick",
|
|
331
|
+
"onMouseDown",
|
|
332
|
+
"onMouseUp",
|
|
333
|
+
"onKeyPress",
|
|
334
|
+
"onKeyDown",
|
|
335
|
+
"onKeyUp",
|
|
336
|
+
],
|
|
337
|
+
},
|
|
338
|
+
],
|
|
339
|
+
"jsx-a11y/no-noninteractive-element-to-interactive-role": [
|
|
340
|
+
"error",
|
|
341
|
+
{
|
|
342
|
+
ul: [
|
|
343
|
+
"listbox",
|
|
344
|
+
"menu",
|
|
345
|
+
"menubar",
|
|
346
|
+
"radiogroup",
|
|
347
|
+
"tablist",
|
|
348
|
+
"tree",
|
|
349
|
+
"treegrid",
|
|
350
|
+
],
|
|
351
|
+
ol: [
|
|
352
|
+
"listbox",
|
|
353
|
+
"menu",
|
|
354
|
+
"menubar",
|
|
355
|
+
"radiogroup",
|
|
356
|
+
"tablist",
|
|
357
|
+
"tree",
|
|
358
|
+
"treegrid",
|
|
359
|
+
],
|
|
360
|
+
li: ["menuitem", "option", "row", "tab", "treeitem"],
|
|
361
|
+
table: ["grid"],
|
|
362
|
+
td: ["gridcell"],
|
|
363
|
+
},
|
|
364
|
+
],
|
|
365
|
+
"jsx-a11y/no-noninteractive-tabindex": [
|
|
366
|
+
"error",
|
|
367
|
+
{
|
|
368
|
+
tags: [],
|
|
369
|
+
roles: ["tabpanel"],
|
|
370
|
+
allowExpressionValues: true,
|
|
371
|
+
},
|
|
372
|
+
],
|
|
373
|
+
"jsx-a11y/no-redundant-roles": [
|
|
374
|
+
"error",
|
|
375
|
+
{
|
|
376
|
+
nav: ["navigation"],
|
|
377
|
+
},
|
|
378
|
+
],
|
|
379
|
+
"jsx-a11y/no-static-element-interactions": [
|
|
380
|
+
"error",
|
|
381
|
+
{
|
|
382
|
+
handlers: [
|
|
383
|
+
"onClick",
|
|
384
|
+
"onMouseDown",
|
|
385
|
+
"onMouseUp",
|
|
386
|
+
"onKeyPress",
|
|
387
|
+
"onKeyDown",
|
|
388
|
+
"onKeyUp",
|
|
389
|
+
],
|
|
390
|
+
},
|
|
391
|
+
],
|
|
392
|
+
"jsx-a11y/role-has-required-aria-props": "error",
|
|
393
|
+
"jsx-a11y/role-supports-aria-props": "error",
|
|
394
|
+
"jsx-a11y/scope": "error",
|
|
395
|
+
"jsx-a11y/tabindex-no-positive": "error",
|
|
396
|
+
},
|
|
397
|
+
},
|
|
398
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
399
|
+
prettierConfig,
|
|
400
|
+
);
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import js from "@eslint/js";
|
|
2
|
+
// @ts-expect-error no types
|
|
3
|
+
import prettierConfig from "eslint-config-prettier";
|
|
4
|
+
// @ts-expect-error no types
|
|
5
|
+
import importPlugin from "eslint-plugin-import";
|
|
6
|
+
import tseslint from "typescript-eslint";
|
|
7
|
+
|
|
8
|
+
export default tseslint.config(
|
|
9
|
+
js.configs.recommended,
|
|
10
|
+
// @ts-expect-error nullability
|
|
11
|
+
{
|
|
12
|
+
// extract only the rules, because this config otherwise applies only to
|
|
13
|
+
// TypeScript extensions, which causes problems with checkJs
|
|
14
|
+
rules: tseslint.configs.eslintRecommended.rules,
|
|
15
|
+
},
|
|
16
|
+
...tseslint.configs.strictTypeChecked,
|
|
17
|
+
...tseslint.configs.stylisticTypeChecked,
|
|
18
|
+
{
|
|
19
|
+
languageOptions: {
|
|
20
|
+
parserOptions: {
|
|
21
|
+
projectService: true,
|
|
22
|
+
warnOnUnsupportedTypeScriptVersion: false,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
plugins: {
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
27
|
+
import: importPlugin,
|
|
28
|
+
},
|
|
29
|
+
rules: {
|
|
30
|
+
"@typescript-eslint/naming-convention": [
|
|
31
|
+
"error",
|
|
32
|
+
{
|
|
33
|
+
selector: "variable",
|
|
34
|
+
format: ["camelCase", "PascalCase", "UPPER_CASE"],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
selector: "function",
|
|
38
|
+
format: ["camelCase", "PascalCase"],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
selector: "typeLike",
|
|
42
|
+
format: ["PascalCase"],
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
"@typescript-eslint/class-methods-use-this": "error",
|
|
46
|
+
"@typescript-eslint/default-param-last": ["error"],
|
|
47
|
+
"@typescript-eslint/no-dupe-class-members": ["error"],
|
|
48
|
+
"@typescript-eslint/no-loss-of-precision": ["error"],
|
|
49
|
+
"@typescript-eslint/no-loop-func": ["error"],
|
|
50
|
+
"@typescript-eslint/no-redeclare": ["error"],
|
|
51
|
+
"@typescript-eslint/no-shadow": ["error"],
|
|
52
|
+
"@typescript-eslint/only-throw-error": ["error"],
|
|
53
|
+
"@typescript-eslint/no-unused-expressions": [
|
|
54
|
+
"error",
|
|
55
|
+
{
|
|
56
|
+
allowShortCircuit: false,
|
|
57
|
+
allowTernary: false,
|
|
58
|
+
allowTaggedTemplates: false,
|
|
59
|
+
enforceForJSX: false,
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
"@typescript-eslint/no-unused-vars": [
|
|
63
|
+
"error",
|
|
64
|
+
{
|
|
65
|
+
vars: "all",
|
|
66
|
+
args: "after-used",
|
|
67
|
+
ignoreRestSiblings: true,
|
|
68
|
+
argsIgnorePattern: "^_",
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
"@typescript-eslint/no-use-before-define": [
|
|
72
|
+
"error",
|
|
73
|
+
{
|
|
74
|
+
functions: true,
|
|
75
|
+
classes: true,
|
|
76
|
+
variables: true,
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
"@typescript-eslint/return-await": ["error", "in-try-catch"],
|
|
80
|
+
"import/extensions": [
|
|
81
|
+
"error",
|
|
82
|
+
"ignorePackages",
|
|
83
|
+
{
|
|
84
|
+
js: "never",
|
|
85
|
+
mjs: "never",
|
|
86
|
+
jsx: "never",
|
|
87
|
+
ts: "never",
|
|
88
|
+
tsx: "never",
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
"import/no-extraneous-dependencies": [
|
|
92
|
+
"error",
|
|
93
|
+
{
|
|
94
|
+
devDependencies: [
|
|
95
|
+
"test/**",
|
|
96
|
+
"tests/**",
|
|
97
|
+
"spec/**",
|
|
98
|
+
"**/__tests__/**",
|
|
99
|
+
"**/__mocks__/**",
|
|
100
|
+
"test.{js,jsx}",
|
|
101
|
+
"test.{ts,tsx}",
|
|
102
|
+
"test-*.{js,jsx}",
|
|
103
|
+
"test-*.{ts,tsx}",
|
|
104
|
+
"**/*{.,_}{test,spec}.{js,jsx}",
|
|
105
|
+
"**/*{.,_}{test,spec}.{ts,tsx}",
|
|
106
|
+
"**/*.config.{js,ts,cjs,mjs,cts,mts}",
|
|
107
|
+
],
|
|
108
|
+
optionalDependencies: false,
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
"import/no-default-export": "error",
|
|
112
|
+
"import/order": [
|
|
113
|
+
"error",
|
|
114
|
+
{
|
|
115
|
+
pathGroups: [
|
|
116
|
+
{
|
|
117
|
+
pattern: "@nihalgonsalves/**",
|
|
118
|
+
group: "internal",
|
|
119
|
+
position: "after",
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
pathGroupsExcludedImportTypes: ["builtin"],
|
|
123
|
+
groups: [
|
|
124
|
+
"builtin",
|
|
125
|
+
"external",
|
|
126
|
+
"internal",
|
|
127
|
+
"unknown",
|
|
128
|
+
"parent",
|
|
129
|
+
"sibling",
|
|
130
|
+
"index",
|
|
131
|
+
],
|
|
132
|
+
"newlines-between": "always",
|
|
133
|
+
alphabetize: { order: "asc" },
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
"func-style": ["error", "expression"],
|
|
137
|
+
"arrow-body-style": "error",
|
|
138
|
+
"object-shorthand": "error",
|
|
139
|
+
"no-useless-rename": "error",
|
|
140
|
+
"@typescript-eslint/consistent-type-imports": [
|
|
141
|
+
"error",
|
|
142
|
+
{ fixStyle: "inline-type-imports" },
|
|
143
|
+
],
|
|
144
|
+
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
|
|
145
|
+
"@typescript-eslint/ban-ts-comment": [
|
|
146
|
+
"error",
|
|
147
|
+
{
|
|
148
|
+
"ts-expect-error": "allow-with-description",
|
|
149
|
+
"ts-ignore": true,
|
|
150
|
+
"ts-nocheck": true,
|
|
151
|
+
"ts-check": false,
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
"@typescript-eslint/consistent-type-assertions": [
|
|
155
|
+
"error",
|
|
156
|
+
{
|
|
157
|
+
assertionStyle: "never",
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
"@typescript-eslint/strict-boolean-expressions": [
|
|
161
|
+
"error",
|
|
162
|
+
{ allowNullableBoolean: true, allowNullableString: true },
|
|
163
|
+
],
|
|
164
|
+
"@typescript-eslint/promise-function-async": "error",
|
|
165
|
+
"@typescript-eslint/method-signature-style": "error",
|
|
166
|
+
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
167
|
+
"@typescript-eslint/require-array-sort-compare": "error",
|
|
168
|
+
"@typescript-eslint/switch-exhaustiveness-check": "error",
|
|
169
|
+
},
|
|
170
|
+
settings: {
|
|
171
|
+
"import/extensions": [
|
|
172
|
+
".cjs",
|
|
173
|
+
".mjs",
|
|
174
|
+
".js",
|
|
175
|
+
".jsx",
|
|
176
|
+
".cts",
|
|
177
|
+
".mts",
|
|
178
|
+
".ts",
|
|
179
|
+
".tsx",
|
|
180
|
+
],
|
|
181
|
+
"import/external-module-folders": ["node_modules", "node_modules/@types"],
|
|
182
|
+
"import/parsers": {
|
|
183
|
+
"@typescript-eslint/parser": [".cts", ".mts", ".ts", ".tsx"],
|
|
184
|
+
},
|
|
185
|
+
"import/resolver": {
|
|
186
|
+
node: {
|
|
187
|
+
extensions: [
|
|
188
|
+
".cjs",
|
|
189
|
+
".mjs",
|
|
190
|
+
".js",
|
|
191
|
+
".jsx",
|
|
192
|
+
".cts",
|
|
193
|
+
".mts",
|
|
194
|
+
".ts",
|
|
195
|
+
".tsx",
|
|
196
|
+
],
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
202
|
+
prettierConfig,
|
|
203
|
+
);
|
package/package.json
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nihalgonsalves/esconfig",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "Shared ECMAScript Config (TS, Lint, Prettier)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": "git@github.com:nihalgonsalves/esconfig.git",
|
|
7
7
|
"author": "Nihal Gonsalves <nihal@nihalgonsalves.com>",
|
|
8
8
|
"license": "MIT",
|
|
9
|
-
"
|
|
9
|
+
"type": "module",
|
|
10
|
+
"packageManager": "yarn@4.4.0+sha512.91d93b445d9284e7ed52931369bc89a663414e5582d00eea45c67ddc459a2582919eece27c412d6ffd1bd0793ff35399381cb229326b961798ce4f4cc60ddfdb",
|
|
10
11
|
"files": [
|
|
11
|
-
"eslint
|
|
12
|
-
".
|
|
13
|
-
".
|
|
14
|
-
".prettierrc.js",
|
|
15
|
-
"tsconfig.json"
|
|
12
|
+
"eslint.config.shared.js",
|
|
13
|
+
"eslint.config.react-shared.js",
|
|
14
|
+
"tsconfig.shared.json"
|
|
16
15
|
],
|
|
17
16
|
"scripts": {
|
|
18
17
|
"typecheck": "tsc --noEmit",
|
|
@@ -21,26 +20,27 @@
|
|
|
21
20
|
"format:check": "prettier . --check"
|
|
22
21
|
},
|
|
23
22
|
"dependencies": {
|
|
24
|
-
"@
|
|
25
|
-
"@typescript-eslint/parser": "^7.17.0",
|
|
26
|
-
"eslint-config-airbnb-typescript": "^18.0.0",
|
|
23
|
+
"@eslint/js": "^9.8.0",
|
|
27
24
|
"eslint-config-prettier": "^9.1.0",
|
|
28
25
|
"eslint-plugin-import": "^2.29.1",
|
|
29
26
|
"eslint-plugin-jsx-a11y": "^6.9.0",
|
|
30
27
|
"eslint-plugin-react": "^7.35.0",
|
|
31
|
-
"eslint-plugin-react-hooks": "^4.6.2"
|
|
28
|
+
"eslint-plugin-react-hooks": "^4.6.2",
|
|
29
|
+
"typescript-eslint": "^8.0.1"
|
|
32
30
|
},
|
|
33
31
|
"devDependencies": {
|
|
34
|
-
"@commitlint/cli": "^19.
|
|
32
|
+
"@commitlint/cli": "^19.4.0",
|
|
35
33
|
"@commitlint/config-conventional": "^19.2.2",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
34
|
+
"@types/eslint__js": "^8.42.3",
|
|
35
|
+
"@types/node": "^22.1.0",
|
|
36
|
+
"eslint": "^9.8.0",
|
|
37
|
+
"knip": "^5.27.2",
|
|
38
|
+
"lefthook": "^1.7.12",
|
|
39
39
|
"prettier": "^3.3.3",
|
|
40
40
|
"typescript": "^5.5.4"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"eslint": "^8.
|
|
43
|
+
"eslint": "^9.8.0",
|
|
44
44
|
"prettier": "^3.3.3",
|
|
45
45
|
"typescript": "^5.4.3"
|
|
46
46
|
}
|
package/.eslintrc.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
/** @type import('eslint-define-config').ESLintConfig */
|
|
4
|
-
module.exports = {
|
|
5
|
-
parser: "@typescript-eslint/parser",
|
|
6
|
-
plugins: ["@typescript-eslint", "import"],
|
|
7
|
-
parserOptions: {
|
|
8
|
-
project: "./**/tsconfig*.json",
|
|
9
|
-
warnOnUnsupportedTypeScriptVersion: false,
|
|
10
|
-
},
|
|
11
|
-
extends: [
|
|
12
|
-
"eslint:recommended",
|
|
13
|
-
"airbnb-typescript/base",
|
|
14
|
-
"plugin:@typescript-eslint/strict-type-checked",
|
|
15
|
-
"plugin:import/typescript",
|
|
16
|
-
"prettier",
|
|
17
|
-
],
|
|
18
|
-
rules: require("./eslint-rules-base"),
|
|
19
|
-
};
|
package/.eslintrc.react.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
/** @type import('eslint-define-config').ESLintConfig */
|
|
4
|
-
module.exports = {
|
|
5
|
-
parser: "@typescript-eslint/parser",
|
|
6
|
-
plugins: ["@typescript-eslint", "import", "react"],
|
|
7
|
-
parserOptions: {
|
|
8
|
-
project: "./**/tsconfig*.json",
|
|
9
|
-
warnOnUnsupportedTypeScriptVersion: false,
|
|
10
|
-
},
|
|
11
|
-
settings: {
|
|
12
|
-
react: { version: "detect" },
|
|
13
|
-
},
|
|
14
|
-
extends: [
|
|
15
|
-
"eslint:recommended",
|
|
16
|
-
"airbnb-typescript",
|
|
17
|
-
"airbnb/hooks",
|
|
18
|
-
"plugin:react/recommended",
|
|
19
|
-
"plugin:@typescript-eslint/strict-type-checked",
|
|
20
|
-
"plugin:import/typescript",
|
|
21
|
-
"prettier",
|
|
22
|
-
],
|
|
23
|
-
rules: {
|
|
24
|
-
...require("./eslint-rules-base"),
|
|
25
|
-
"react/state-in-constructor": ["error", "never"],
|
|
26
|
-
"react/static-property-placement": ["error", "static public field"],
|
|
27
|
-
"react/react-in-jsx-scope": "off",
|
|
28
|
-
// Not a problem with TypeScript
|
|
29
|
-
"react/jsx-props-no-spreading": "off",
|
|
30
|
-
"react/require-default-props": "off",
|
|
31
|
-
"react/jsx-no-useless-fragment": ["error", { allowExpressions: true }],
|
|
32
|
-
"react/no-array-index-key": "error",
|
|
33
|
-
"react/jsx-key": [
|
|
34
|
-
"error",
|
|
35
|
-
{
|
|
36
|
-
checkFragmentShorthand: true,
|
|
37
|
-
checkKeyMustBeforeSpread: true,
|
|
38
|
-
warnOnDuplicates: true,
|
|
39
|
-
},
|
|
40
|
-
],
|
|
41
|
-
},
|
|
42
|
-
};
|
package/.prettierrc.js
DELETED
package/eslint-rules-base.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
/* eslint-env node */
|
|
3
|
-
|
|
4
|
-
/** @type import('eslint-define-config').Rules */
|
|
5
|
-
module.exports = {
|
|
6
|
-
"import/prefer-default-export": "off",
|
|
7
|
-
"import/no-default-export": "error",
|
|
8
|
-
"import/order": [
|
|
9
|
-
"error",
|
|
10
|
-
{
|
|
11
|
-
pathGroups: [
|
|
12
|
-
{
|
|
13
|
-
pattern: "@nihalgonsalves/**",
|
|
14
|
-
group: "internal",
|
|
15
|
-
position: "after",
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
pathGroupsExcludedImportTypes: ["builtin"],
|
|
19
|
-
groups: [
|
|
20
|
-
"builtin",
|
|
21
|
-
"external",
|
|
22
|
-
"internal",
|
|
23
|
-
"unknown",
|
|
24
|
-
"parent",
|
|
25
|
-
"sibling",
|
|
26
|
-
"index",
|
|
27
|
-
],
|
|
28
|
-
"newlines-between": "always",
|
|
29
|
-
alphabetize: { order: "asc" },
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
"func-style": ["error", "expression"],
|
|
33
|
-
"arrow-body-style": "error",
|
|
34
|
-
"object-shorthand": "error",
|
|
35
|
-
"no-useless-rename": "error",
|
|
36
|
-
"@typescript-eslint/no-unused-vars": [
|
|
37
|
-
"error",
|
|
38
|
-
{ ignoreRestSiblings: true, argsIgnorePattern: "^_" },
|
|
39
|
-
],
|
|
40
|
-
"@typescript-eslint/consistent-type-imports": [
|
|
41
|
-
"error",
|
|
42
|
-
{ fixStyle: "inline-type-imports" },
|
|
43
|
-
],
|
|
44
|
-
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
|
|
45
|
-
"@typescript-eslint/ban-ts-comment": [
|
|
46
|
-
"error",
|
|
47
|
-
{
|
|
48
|
-
"ts-expect-error": "allow-with-description",
|
|
49
|
-
"ts-ignore": true,
|
|
50
|
-
"ts-nocheck": true,
|
|
51
|
-
"ts-check": false,
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
"@typescript-eslint/consistent-type-assertions": [
|
|
55
|
-
"error",
|
|
56
|
-
{
|
|
57
|
-
assertionStyle: "never",
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
"@typescript-eslint/strict-boolean-expressions": [
|
|
61
|
-
"error",
|
|
62
|
-
{ allowNullableBoolean: true, allowNullableString: true },
|
|
63
|
-
],
|
|
64
|
-
"@typescript-eslint/prefer-regexp-exec": "error",
|
|
65
|
-
"@typescript-eslint/promise-function-async": "error",
|
|
66
|
-
"@typescript-eslint/method-signature-style": "error",
|
|
67
|
-
"@typescript-eslint/naming-convention": "error",
|
|
68
|
-
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
69
|
-
"@typescript-eslint/require-array-sort-compare": "error",
|
|
70
|
-
"@typescript-eslint/switch-exhaustiveness-check": "error",
|
|
71
|
-
};
|
|
File without changes
|