@szum-tech/eslint-config 2.0.0 → 2.1.0
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 +199 -51
- package/dist/index.cjs +414 -0
- package/dist/index.js +396 -0
- package/package.json +28 -30
- package/index.js +0 -437
package/index.js
DELETED
|
@@ -1,437 +0,0 @@
|
|
|
1
|
-
import importPlugin from "eslint-plugin-import";
|
|
2
|
-
import jestDomPlugin from "eslint-plugin-jest-dom";
|
|
3
|
-
import playwrightPlugin from "eslint-plugin-playwright";
|
|
4
|
-
import reactPlugin from "eslint-plugin-react";
|
|
5
|
-
import reactHooksPlugin from "eslint-plugin-react-hooks";
|
|
6
|
-
import storybookPlugin from "eslint-plugin-storybook";
|
|
7
|
-
import tailwindcssPlugin from "eslint-plugin-tailwindcss";
|
|
8
|
-
import testingLibraryPlugin from "eslint-plugin-testing-library";
|
|
9
|
-
import globals from "globals";
|
|
10
|
-
import tsEslint from "typescript-eslint";
|
|
11
|
-
|
|
12
|
-
import nextPlugin from "@next/eslint-plugin-next";
|
|
13
|
-
import vitestPlugin from "@vitest/eslint-plugin";
|
|
14
|
-
|
|
15
|
-
const ERROR = "error";
|
|
16
|
-
const WARN = "warn";
|
|
17
|
-
const OFF = "off";
|
|
18
|
-
|
|
19
|
-
const has = (pkg) => {
|
|
20
|
-
try {
|
|
21
|
-
import.meta.resolve(pkg, import.meta.url);
|
|
22
|
-
return true;
|
|
23
|
-
} catch {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const hasTypeScript = has("typescript");
|
|
29
|
-
const hasTailwindcss = has("tailwindcss");
|
|
30
|
-
const hasReact = has("react");
|
|
31
|
-
const hasNext = has("next");
|
|
32
|
-
const hasTestingLibrary = has("@testing-library/dom");
|
|
33
|
-
const hasJestDom = has("@testing-library/jest-dom");
|
|
34
|
-
const hasVitest = has("vitest");
|
|
35
|
-
const hasPlaywright = has("@playwright/test");
|
|
36
|
-
const hasStorybook = has("storybook");
|
|
37
|
-
|
|
38
|
-
const vitestFiles = ["**/__tests__/**/*", "**/*.test.*"];
|
|
39
|
-
const testFiles = ["**/tests/**", ...vitestFiles];
|
|
40
|
-
const playwrightFiles = ["**/e2e/**", "**/*.e2e.*"];
|
|
41
|
-
|
|
42
|
-
export const config = [
|
|
43
|
-
{
|
|
44
|
-
name: "eslint/ignores",
|
|
45
|
-
ignores: [
|
|
46
|
-
"**/.cache/**",
|
|
47
|
-
"**/node_modules/**",
|
|
48
|
-
"**/build/**",
|
|
49
|
-
"**/public/build/**",
|
|
50
|
-
"**/playwright-report/**",
|
|
51
|
-
"**/server-build/**",
|
|
52
|
-
"**/dist/**",
|
|
53
|
-
"**/.next/**"
|
|
54
|
-
]
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
{
|
|
58
|
-
name: "eslint/config/base&import",
|
|
59
|
-
plugins: {
|
|
60
|
-
import: importPlugin
|
|
61
|
-
},
|
|
62
|
-
languageOptions: {
|
|
63
|
-
globals: {
|
|
64
|
-
...globals.browser,
|
|
65
|
-
...globals.node
|
|
66
|
-
},
|
|
67
|
-
parserOptions: {
|
|
68
|
-
warnOnUnsupportedTypeScriptVersion: false
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
rules: {
|
|
72
|
-
"no-unexpected-multiline": ERROR,
|
|
73
|
-
"no-warning-comments": [ERROR, { terms: ["FIXME"], location: "anywhere" }],
|
|
74
|
-
"no-console": WARN,
|
|
75
|
-
"no-unused-vars": [
|
|
76
|
-
WARN,
|
|
77
|
-
{
|
|
78
|
-
args: "after-used",
|
|
79
|
-
argsIgnorePattern: "^_",
|
|
80
|
-
ignoreRestSiblings: true,
|
|
81
|
-
varsIgnorePattern: "^ignored"
|
|
82
|
-
}
|
|
83
|
-
],
|
|
84
|
-
|
|
85
|
-
// analysis/correctness
|
|
86
|
-
"import/default": ERROR,
|
|
87
|
-
"import/namespace": ERROR,
|
|
88
|
-
"import/export": ERROR,
|
|
89
|
-
"import/no-unresolved": OFF,
|
|
90
|
-
"import/named": OFF,
|
|
91
|
-
|
|
92
|
-
// red flags (thus, warnings)
|
|
93
|
-
"import/consistent-type-specifier-style": [WARN, "prefer-inline"],
|
|
94
|
-
"import/no-named-as-default": WARN,
|
|
95
|
-
"import/no-named-as-default-member": WARN,
|
|
96
|
-
"import/no-duplicates": [WARN, { "prefer-inline": true }],
|
|
97
|
-
"import/order": [
|
|
98
|
-
WARN,
|
|
99
|
-
{
|
|
100
|
-
groups: ["builtin", "external", "internal", "parent", "sibling", "index"],
|
|
101
|
-
pathGroups: [
|
|
102
|
-
{
|
|
103
|
-
pattern: "react",
|
|
104
|
-
group: "external",
|
|
105
|
-
position: "before"
|
|
106
|
-
},
|
|
107
|
-
{ pattern: "*/**", group: "internal" }
|
|
108
|
-
],
|
|
109
|
-
pathGroupsExcludedImportTypes: ["react"],
|
|
110
|
-
"newlines-between": "always",
|
|
111
|
-
alphabetize: {
|
|
112
|
-
order: "asc",
|
|
113
|
-
caseInsensitive: true
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
]
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
|
|
120
|
-
hasReact
|
|
121
|
-
? {
|
|
122
|
-
name: "eslint/config/react&react-hooks",
|
|
123
|
-
files: ["**/*.tsx", "**/*.jsx"],
|
|
124
|
-
plugins: {
|
|
125
|
-
react: reactPlugin,
|
|
126
|
-
"react-hooks": reactHooksPlugin
|
|
127
|
-
},
|
|
128
|
-
languageOptions: {
|
|
129
|
-
parser: tsEslint.parser,
|
|
130
|
-
parserOptions: {
|
|
131
|
-
jsx: true
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
settings: {
|
|
135
|
-
react: {
|
|
136
|
-
version: "detect"
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
rules: {
|
|
140
|
-
"react/display-name": ERROR,
|
|
141
|
-
"react/jsx-no-comment-textnodes": ERROR,
|
|
142
|
-
"react/jsx-no-duplicate-props": ERROR,
|
|
143
|
-
"react/jsx-no-target-blank": ERROR,
|
|
144
|
-
"react/jsx-no-undef": ERROR,
|
|
145
|
-
"react/jsx-uses-react": ERROR,
|
|
146
|
-
"react/jsx-uses-vars": ERROR,
|
|
147
|
-
"react/no-children-prop": ERROR,
|
|
148
|
-
"react/no-danger-with-children": ERROR,
|
|
149
|
-
"react/no-deprecated": ERROR,
|
|
150
|
-
"react/no-direct-mutation-state": ERROR,
|
|
151
|
-
"react/no-find-dom-node": ERROR,
|
|
152
|
-
"react/no-is-mounted": ERROR,
|
|
153
|
-
"react/no-render-return-value": ERROR,
|
|
154
|
-
"react/no-unescaped-entities": ERROR,
|
|
155
|
-
"react/no-unknown-property": ERROR,
|
|
156
|
-
"react/require-render-return": ERROR,
|
|
157
|
-
"react/jsx-key": WARN,
|
|
158
|
-
"react/react-in-jsx-scope": OFF,
|
|
159
|
-
"react/no-unsafe": OFF,
|
|
160
|
-
|
|
161
|
-
"react-hooks/rules-of-hooks": ERROR,
|
|
162
|
-
"react-hooks/exhaustive-deps": WARN
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
: null,
|
|
166
|
-
|
|
167
|
-
hasTailwindcss
|
|
168
|
-
? {
|
|
169
|
-
name: "eslint/config/tailwindcss",
|
|
170
|
-
plugins: {
|
|
171
|
-
tailwindcss: tailwindcssPlugin
|
|
172
|
-
},
|
|
173
|
-
languageOptions: {
|
|
174
|
-
parserOptions: {
|
|
175
|
-
ecmaFeatures: {
|
|
176
|
-
jsx: true
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
rules: {
|
|
181
|
-
"tailwindcss/no-contradicting-classname": ERROR,
|
|
182
|
-
"tailwindcss/classnames-order": WARN,
|
|
183
|
-
"tailwindcss/enforces-negative-arbitrary-values": WARN,
|
|
184
|
-
"tailwindcss/enforces-shorthand": WARN,
|
|
185
|
-
"tailwindcss/migration-from-tailwind-2": WARN,
|
|
186
|
-
"tailwindcss/no-custom-classname": WARN,
|
|
187
|
-
"tailwindcss/no-unnecessary-arbitrary-value": WARN,
|
|
188
|
-
"tailwindcss/no-arbitrary-value": OFF
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
: null,
|
|
192
|
-
|
|
193
|
-
hasNext
|
|
194
|
-
? {
|
|
195
|
-
name: "eslint/config/next",
|
|
196
|
-
files: ["**/*.ts?(x)", "**/*.js?(x)"],
|
|
197
|
-
plugins: {
|
|
198
|
-
"@next/next": nextPlugin
|
|
199
|
-
},
|
|
200
|
-
rules: {
|
|
201
|
-
"@next/next/inline-script-id": ERROR,
|
|
202
|
-
"@next/next/no-assign-module-variable": ERROR,
|
|
203
|
-
"@next/next/no-document-import-in-page": ERROR,
|
|
204
|
-
"@next/next/no-duplicate-head": ERROR,
|
|
205
|
-
"@next/next/no-head-import-in-document": ERROR,
|
|
206
|
-
"@next/next/no-script-component-in-head": ERROR,
|
|
207
|
-
"@next/next/google-font-display": WARN,
|
|
208
|
-
"@next/next/google-font-preconnect": WARN,
|
|
209
|
-
"@next/next/next-script-for-ga": WARN,
|
|
210
|
-
"@next/next/no-async-client-component": WARN,
|
|
211
|
-
"@next/next/no-before-interactive-script-outside-document": WARN,
|
|
212
|
-
"@next/next/no-css-tags": WARN,
|
|
213
|
-
"@next/next/no-head-element": WARN,
|
|
214
|
-
"@next/next/no-html-link-for-pages": WARN,
|
|
215
|
-
"@next/next/no-img-element": WARN,
|
|
216
|
-
"@next/next/no-page-custom-font": WARN,
|
|
217
|
-
"@next/next/no-styled-jsx-in-document": WARN,
|
|
218
|
-
"@next/next/no-sync-scripts": WARN,
|
|
219
|
-
"@next/next/no-title-in-document-head": WARN,
|
|
220
|
-
"@next/next/no-typos": WARN,
|
|
221
|
-
"@next/next/no-unwanted-polyfillio": WARN
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
: null,
|
|
225
|
-
|
|
226
|
-
hasTypeScript
|
|
227
|
-
? {
|
|
228
|
-
name: "eslint/config/typescript",
|
|
229
|
-
files: ["**/*.ts?(x)"],
|
|
230
|
-
languageOptions: {
|
|
231
|
-
parser: tsEslint.parser,
|
|
232
|
-
parserOptions: {
|
|
233
|
-
projectService: true
|
|
234
|
-
},
|
|
235
|
-
sourceType: "module"
|
|
236
|
-
},
|
|
237
|
-
plugins: {
|
|
238
|
-
"@typescript-eslint": tsEslint.plugin
|
|
239
|
-
},
|
|
240
|
-
rules: {
|
|
241
|
-
"no-unused-expressions": OFF,
|
|
242
|
-
"no-array-constructor": OFF,
|
|
243
|
-
"no-unused-vars": OFF,
|
|
244
|
-
|
|
245
|
-
"@typescript-eslint/no-misused-promises": [ERROR, { checksVoidReturn: false }],
|
|
246
|
-
"@typescript-eslint/no-floating-promises": ERROR,
|
|
247
|
-
"@typescript-eslint/ban-ts-comment": ERROR,
|
|
248
|
-
"@typescript-eslint/no-array-constructor": ERROR,
|
|
249
|
-
"@typescript-eslint/no-duplicate-enum-values": ERROR,
|
|
250
|
-
"@typescript-eslint/no-explicit-any": ERROR,
|
|
251
|
-
"@typescript-eslint/no-extra-non-null-assertion": ERROR,
|
|
252
|
-
"@typescript-eslint/no-misused-new": ERROR,
|
|
253
|
-
"@typescript-eslint/no-namespace": ERROR,
|
|
254
|
-
"@typescript-eslint/no-non-null-asserted-optional-chain": ERROR,
|
|
255
|
-
"@typescript-eslint/no-require-imports": ERROR,
|
|
256
|
-
"@typescript-eslint/no-this-alias": ERROR,
|
|
257
|
-
"@typescript-eslint/no-unnecessary-type-constraint": ERROR,
|
|
258
|
-
"@typescript-eslint/no-unsafe-declaration-merging": ERROR,
|
|
259
|
-
"@typescript-eslint/no-unsafe-function-type": ERROR,
|
|
260
|
-
"@typescript-eslint/no-wrapper-object-types": ERROR,
|
|
261
|
-
"@typescript-eslint/prefer-as-const": "error",
|
|
262
|
-
"@typescript-eslint/prefer-namespace-keyword": ERROR,
|
|
263
|
-
"@typescript-eslint/triple-slash-reference": ERROR,
|
|
264
|
-
"@typescript-eslint/no-empty-object-type": WARN,
|
|
265
|
-
"@typescript-eslint/no-unused-vars": [
|
|
266
|
-
WARN,
|
|
267
|
-
{
|
|
268
|
-
args: "all",
|
|
269
|
-
argsIgnorePattern: "^_",
|
|
270
|
-
caughtErrors: "all",
|
|
271
|
-
caughtErrorsIgnorePattern: "^_",
|
|
272
|
-
destructuredArrayIgnorePattern: "^_",
|
|
273
|
-
varsIgnorePattern: "^_",
|
|
274
|
-
ignoreRestSiblings: true
|
|
275
|
-
}
|
|
276
|
-
],
|
|
277
|
-
"@typescript-eslint/consistent-type-imports": [
|
|
278
|
-
WARN,
|
|
279
|
-
{
|
|
280
|
-
prefer: "type-imports",
|
|
281
|
-
disallowTypeAnnotations: true,
|
|
282
|
-
fixStyle: "inline-type-imports"
|
|
283
|
-
}
|
|
284
|
-
]
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
: null,
|
|
288
|
-
|
|
289
|
-
hasTestingLibrary
|
|
290
|
-
? {
|
|
291
|
-
name: "eslint/config/testing-library",
|
|
292
|
-
files: testFiles,
|
|
293
|
-
ignores: playwrightFiles,
|
|
294
|
-
plugins: {
|
|
295
|
-
"testing-library": testingLibraryPlugin
|
|
296
|
-
},
|
|
297
|
-
rules: {
|
|
298
|
-
"testing-library/no-unnecessary-act": [ERROR, { isStrict: false }],
|
|
299
|
-
"testing-library/no-wait-for-side-effects": ERROR,
|
|
300
|
-
"testing-library/prefer-find-by": ERROR
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
: null,
|
|
304
|
-
|
|
305
|
-
hasJestDom
|
|
306
|
-
? {
|
|
307
|
-
name: "eslint/config/jest-dom",
|
|
308
|
-
files: testFiles,
|
|
309
|
-
ignores: playwrightFiles,
|
|
310
|
-
plugins: {
|
|
311
|
-
"jest-dom": jestDomPlugin
|
|
312
|
-
},
|
|
313
|
-
rules: {
|
|
314
|
-
"jest-dom/prefer-checked": ERROR,
|
|
315
|
-
"jest-dom/prefer-enabled-disabled": ERROR,
|
|
316
|
-
"jest-dom/prefer-focus": ERROR,
|
|
317
|
-
"jest-dom/prefer-empty": ERROR,
|
|
318
|
-
"jest-dom/prefer-to-have-value": ERROR,
|
|
319
|
-
"jest-dom/prefer-to-have-text-content": ERROR,
|
|
320
|
-
"jest-dom/prefer-required": ERROR
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
: null,
|
|
324
|
-
|
|
325
|
-
hasVitest
|
|
326
|
-
? {
|
|
327
|
-
name: "eslint/config/vitest",
|
|
328
|
-
files: testFiles,
|
|
329
|
-
ignores: playwrightFiles,
|
|
330
|
-
plugins: {
|
|
331
|
-
vitest: vitestPlugin
|
|
332
|
-
},
|
|
333
|
-
settings: {
|
|
334
|
-
vitest: {
|
|
335
|
-
typecheck: hasTypeScript
|
|
336
|
-
}
|
|
337
|
-
},
|
|
338
|
-
languageOptions: {
|
|
339
|
-
globals: {
|
|
340
|
-
...vitestPlugin.environments.env.globals
|
|
341
|
-
}
|
|
342
|
-
},
|
|
343
|
-
rules: {
|
|
344
|
-
"vitest/expect-expect": ERROR,
|
|
345
|
-
"vitest/no-identical-title": ERROR,
|
|
346
|
-
"vitest/no-commented-out-tests": ERROR,
|
|
347
|
-
"vitest/valid-title": ERROR,
|
|
348
|
-
"vitest/valid-expect": ERROR,
|
|
349
|
-
"vitest/valid-describe-callback": ERROR,
|
|
350
|
-
"vitest/require-local-test-context-for-concurrent-snapshots": ERROR,
|
|
351
|
-
"vitest/no-import-node-test": ERROR,
|
|
352
|
-
"vitest/no-focused-tests": [WARN, { fixable: false }]
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
: null,
|
|
356
|
-
|
|
357
|
-
hasPlaywright
|
|
358
|
-
? {
|
|
359
|
-
name: "eslint/config/playwright",
|
|
360
|
-
files: playwrightFiles,
|
|
361
|
-
|
|
362
|
-
plugins: {
|
|
363
|
-
playwright: playwrightPlugin
|
|
364
|
-
},
|
|
365
|
-
languageOptions: {
|
|
366
|
-
globals: globals["shared-node-browser"]
|
|
367
|
-
},
|
|
368
|
-
rules: {
|
|
369
|
-
"no-empty-pattern": OFF,
|
|
370
|
-
|
|
371
|
-
"playwright/missing-playwright-await": ERROR,
|
|
372
|
-
"playwright/no-focused-test": ERROR,
|
|
373
|
-
"playwright/no-networkidle": ERROR,
|
|
374
|
-
"playwright/no-unsafe-references": ERROR,
|
|
375
|
-
"playwright/valid-describe-callback": ERROR,
|
|
376
|
-
"playwright/valid-expect": ERROR,
|
|
377
|
-
"playwright/valid-expect-in-promise": ERROR,
|
|
378
|
-
"playwright/valid-title": ERROR,
|
|
379
|
-
"playwright/prefer-web-first-assertions": ERROR,
|
|
380
|
-
"playwright/no-standalone-expect": ERROR,
|
|
381
|
-
"playwright/expect-expect": WARN,
|
|
382
|
-
"playwright/max-nested-describe": WARN,
|
|
383
|
-
"playwright/no-conditional-expect": WARN,
|
|
384
|
-
"playwright/no-conditional-in-test": WARN,
|
|
385
|
-
"playwright/no-element-handle": WARN,
|
|
386
|
-
"playwright/no-eval": WARN,
|
|
387
|
-
"playwright/no-force-option": WARN,
|
|
388
|
-
"playwright/no-nested-step": WARN,
|
|
389
|
-
"playwright/no-page-pause": WARN,
|
|
390
|
-
"playwright/no-skipped-test": WARN,
|
|
391
|
-
"playwright/no-useless-await": WARN,
|
|
392
|
-
"playwright/no-useless-not": WARN,
|
|
393
|
-
"playwright/no-wait-for-selector": WARN,
|
|
394
|
-
"playwright/no-wait-for-timeout": WARN
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
: null,
|
|
398
|
-
|
|
399
|
-
hasStorybook
|
|
400
|
-
? {
|
|
401
|
-
name: "eslint/config/storybook",
|
|
402
|
-
plugins: {
|
|
403
|
-
storybook: storybookPlugin
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
: null,
|
|
407
|
-
hasStorybook
|
|
408
|
-
? {
|
|
409
|
-
name: "eslint/config/storybook/stories",
|
|
410
|
-
files: ["**/*.stories.@(ts|tsx|js|jsx|mjs|cjs)", "**/*.story.@(ts|tsx|js|jsx|mjs|cjs)"],
|
|
411
|
-
rules: {
|
|
412
|
-
"storybook/await-interactions": ERROR,
|
|
413
|
-
"storybook/context-in-play-function": ERROR,
|
|
414
|
-
"storybook/default-exports": ERROR,
|
|
415
|
-
"storybook/story-exports": ERROR,
|
|
416
|
-
"storybook/use-storybook-expect": ERROR,
|
|
417
|
-
"storybook/use-storybook-testing-library": ERROR,
|
|
418
|
-
"storybook/no-redundant-story-name": WARN,
|
|
419
|
-
"storybook/prefer-pascal-case": WARN,
|
|
420
|
-
"storybook/hierarchy-separator": WARN,
|
|
421
|
-
"react-hooks/rules-of-hooks": OFF,
|
|
422
|
-
"import/no-anonymous-default-export": OFF
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
: null,
|
|
426
|
-
hasStorybook
|
|
427
|
-
? {
|
|
428
|
-
name: "eslint/config/storybook/main",
|
|
429
|
-
files: [".storybook/main.@(js|cjs|mjs|ts|tsx)"],
|
|
430
|
-
rules: {
|
|
431
|
-
"storybook/no-uninstalled-addons": ERROR
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
: null
|
|
435
|
-
].filter(Boolean);
|
|
436
|
-
|
|
437
|
-
export default config;
|