-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
145 lines (130 loc) · 4.8 KB
/
.eslintrc.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
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
module.exports = {
// https://github.com/facebook/create-react-app/issues/12070
parserOptions: {
babelOptions: { presets: [["babel-preset-react-app", false]] },
},
extends: [
// https://github.com/facebook/create-react-app/blob/main/packages/eslint-config-react-app/README.md
"react-app",
// NOTE: Enables ALL rules that are recommended. Uncomment to enable.
// Enables few key rules in [ESLint](https://eslint.org/docs/rules/) rule book.
// "eslint:recommended",
// Enables rules for import/export syntax in [eslint-plugin-import](https://www.npmjs.com/package/eslint-plugin-import)
"plugin:import/recommended",
"plugin:import/typescript",
// Enables the [recommended](https://www.npmjs.com/package/eslint-plugin-react#recommended) React rule set in [eslint-plugin-react](https://www.npmjs.com/package/eslint-plugin-react).
// "plugin:react/recommended",
// Enables the recommended accessibility rules in [eslint-plugin-jsx-a11y](https://www.npmjs.com/package/eslint-plugin-jsx-a11y).
// "plugin:jsx-a11y/recommended",
// Enables React Hooks best practices rule set in [eslint-plugin-react-hooks](https://www.npmjs.com/package/eslint-plugin-react-hooks)
// "plugin:react-hooks/recommended",
// Enables recommended rules in [eslint-plugin-jest](https://www.npmjs.com/package/eslint-plugin-jest)
// "plugin:jest/recommended",
// Enables recommended settings in [eslint-plugin-testing-library](https://www.npmjs.com/package/eslint-plugin-testing-library)
// "plugin:testing-library/react",
// "plugin:storybook/recommended",
"prettier",
],
settings: {
"import/resolver": {
typescript: true,
node: true,
},
},
rules: {
// [import/order rules](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md)
"import/order": [
// This sets the rule to a warning level, meaning ESLint will report the violations as warnings but won't fail the build.
"warn",
{
// This sub-option controls the order of import specifiers when alphabetizing.
alphabetize: {
// ensures that the sorting is case-insensitive.
caseInsensitive: true,
// specifies the sort order as ascending.
order: "ignore",
},
// defines the order of import groups
groups: [
// Node.js built-in modules.
"builtin",
// External modules (i.e., third-party libraries installed via npm)
"external",
// Files within the same project but not in the same or parent directory.
"internal",
// Files in the parent directory.
"parent",
// Other files in the same directory.
"sibling",
// index file of the current directory.
"index",
],
warnOnUnassignedImports: true,
"newlines-between": "always-and-inside-groups",
},
],
"import/no-duplicates": "error",
"import/no-named-as-default": "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,
},
},
],
"no-console": "warn",
},
overrides: [
{
files: ["playwright/**/*.{spec,test}.{js,jsx,ts,tsx}"],
extends: "plugin:playwright/recommended",
},
{
files: ["src/**/*.{spec,test}.{js,jsx,ts,tsx}", "src/**/__tests__/**/*.{js,jsx,ts,tsx}"],
extends: ["react-app/jest", "plugin:testing-library/react"],
},
{
env: {
// enable Cypress global variables.
"cypress/globals": true,
},
files: ["cypress/**/*.cy.{js,jsx,ts,tsx}"],
extends: ["plugin:cypress/recommended"],
rules: {
// disallow using `force: true` with action commands
"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",
},
},
{
files: ["**/*.d.ts", "**/*-d.ts"],
rules: {
"@typescript-eslint/consistent-type-definitions": "off",
"@typescript-eslint/naming-convention": "off",
},
},
],
ignorePatterns: [
"/build/",
"/scripts",
"/public/",
"/node_modules/",
".eslintrc.js",
"/config",
"/jest.config.js",
"/prettier.config.js",
],
};