-
Notifications
You must be signed in to change notification settings - Fork 4
/
eslint.config.js
95 lines (93 loc) · 3.14 KB
/
eslint.config.js
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
import js from "@eslint/js";
import cypress from "eslint-plugin-cypress/flat";
import react from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import storybook from "eslint-plugin-storybook";
import testingLibrary from "eslint-plugin-testing-library";
import globals from "globals";
import tseslint from "typescript-eslint";
export default tseslint.config(
{ ignores: ["dist", ".storybook"] },
{
extends: [
js.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.stylisticTypeChecked,
],
files: ["**/*.{ts,tsx}"],
settings: { react: { version: "18.3" } },
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
parserOptions: {
project: ["./tsconfig.node.json", "./tsconfig.app.json", "./cypress/tsconfig.json"],
tsconfigRootDir: import.meta.dirname,
},
},
plugins: {
react,
"react-hooks": reactHooks,
"react-refresh": reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
...react.configs.recommended.rules,
...react.configs["jsx-runtime"].rules,
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
// typescript
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": ["warn", { ignoreRestSiblings: true, argsIgnorePattern: "^_" }],
"react/prop-types": "off",
// READ-MORE: https://typescript-eslint.io/rules/consistent-type-definitions
"@typescript-eslint/consistent-type-definitions": ["warn", "type"],
// typeAlias selectors should start with prefix T
// READ-MORE: https://typescript-eslint.io/rules/naming-convention
"@typescript-eslint/naming-convention": [
"error",
{
selector: ["typeAlias"],
format: ["PascalCase"],
custom: {
regex: "^T[A-Z]",
match: true,
},
},
],
},
},
{
extends: [...storybook.configs["flat/recommended"]],
files: ["src/**/*.stories.{js,jsx,ts,tsx}"],
},
{
files: ["src/**/*.{spec,test}.{js,jsx,ts,tsx}", "src/**/__tests__/**/*.{js,jsx,ts,tsx}"],
extends: [testingLibrary.configs["flat/react"]],
rules: {
"testing-library/no-await-sync-events": [
"error",
{
eventModules: ["fire-event"],
},
],
"testing-library/no-manual-cleanup": "error",
"testing-library/prefer-explicit-assert": "error",
"testing-library/prefer-user-event": "error",
"testing-library/prefer-presence-queries": "error",
},
},
{
files: ["cypress/**/*.{js,ts,jsx,tsx}"],
extends: [cypress.configs.recommended],
rules: {
// disallow using `force: true` with action commandsx
"cypress/no-force": "warn",
// ensure screenshots are preceded by an assertion
"cypress/assertion-before-screenshot": "warn",
// only allow data-* attribute selectors
"cypress/require-data-selectors": "warn",
// disallow cy.pause() parent command
"cypress/no-pause": "error",
},
}
);