generated from yandex-praktikum/algososh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.cjs
129 lines (127 loc) · 3.76 KB
/
.eslintrc.cjs
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
module.exports = {
root: true,
env: {
browser: true,
es2020: true,
jest: true,
node: true,
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:react-hooks/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:cypress/recommended",
"plugin:storybook/recommended",
// prettier must be the last in extends
"prettier",
],
overrides: [
{
// disable type checking for configs and cypress
extends: ["plugin:@typescript-eslint/disable-type-checked"],
files: [
"./jest/**/*.js",
"./cypress/**/*.ts",
"./**/*.spec.ts",
"./**/*.test.ts",
"./storybook/**/*.ts",
"./src/stories/**/*.{ts,tsx}",
],
},
],
settings: {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"],
},
"import/resolver": {
typescript: {
//always try to resolve types under `<root>@types` directory
// even it doesn't contain any source code, like `@types/unist`
alwaysTryTypes: true,
project: "./tsconfig.json",
},
},
react: {
// Pragma to use, default to "React"
pragma: "React",
// Fragment to use (may be a property of <pragma>), default to "Fragment"
fragment: "Fragment",
// React version. "detect" automatically picks the version you have installed.
// You can also use `16.0`, `16.3`, etc, if you want to override the detected value.
// It will default to "latest" and warn if missing, and to "detect" in the future
version: "detect",
flowVersion: "0.53",
},
},
ignorePatterns: ["build", ".eslintrc.cjs", "vite.config.ts", ".lintstagedrc.cjs"],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "latest",
ecmaFeatures: {
jsx: true,
},
sourceType: "module",
// indicates to find the closest tsconfig.json for each source file
project: true,
tsconfigRootDir: __dirname,
},
plugins: ["prettier", "react", "react-hooks", "react-refresh", "import", "@typescript-eslint"],
rules: {
"prettier/prettier": ["error"],
camelcase: ["error"],
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
"react/jsx-uses-react": "error",
"react/jsx-uses-vars": "error",
"no-console": ["error", { allow: ["warn", "error"] }],
semi: "error",
"no-var": 0,
"no-multi-spaces": "error",
"space-in-parens": "error",
"no-multiple-empty-lines": "error",
"prefer-const": "error",
"no-unused-vars": [
"off",
{
vars: "all",
args: "after-used",
ignoreRestSiblings: true,
argsIgnorePattern: "^_",
},
],
"@typescript-eslint/no-unused-vars": ["error"],
"react/react-in-jsx-scope": "off",
"react/require-default-props": "off",
"react/function-component-definition": [
2,
{
namedComponents: "arrow-function",
unnamedComponents: ["function-expression", "arrow-function"],
},
],
"import/no-named-as-default": "off",
// Prevent importing from deep nested subfolders, only top level folder index.ts
"no-restricted-imports": [
"error",
{
patterns: [
{
group: ["/#feature/*/*"],
message: "Please use imports only from /feature/{slice} index.ts file",
},
{
group: ["/#pages/*/*"],
message: "Please use imports only from /pages/{slice} index.ts file",
},
{
group: ["/#shared/*/*"],
message: "Please use imports only from /shared/{slice} index.ts file",
},
],
},
],
},
};