forked from VKCOM/VKUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.json
166 lines (166 loc) · 4.54 KB
/
.eslintrc.json
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
{
"extends": [
"@vkontakte/eslint-config/typescript/react",
"prettier",
"plugin:react-hooks/recommended",
"plugin:compat/recommended"
],
"parserOptions": {
"project": "./tsconfig.json",
"ecmaVersion": 2018, // Allows for the parsing of modern ECMAScript features
"sourceType": "module", // Allows for the use of imports
"ecmaFeatures": {
"jsx": true, // Allows for the parsing of JSX
"restParams": true,
"spread": true
}
},
"settings": {
"lintAllEsApis": true,
"polyfills": [
"Array.includes",
"Array.find",
"String.padStart",
"Intl" // Отсутствует. Не поддерживается в iOS Safari 9, Calendar должен использоваться только на desktop
]
},
"globals": {
"Element": true
},
"ignorePatterns": ["tokenized/**/*.ts", "packages/**/*.ts"],
"env": {
"es6": true, // Enable global es6 variables, like Set, Map, etc
"browser": true,
"node": true
},
"plugins": ["import", "vkui"],
"rules": {
"no-shadow": "off", // Need using @typescript-eslint/no-shadow
"@typescript-eslint/ban-ts-comment": [
"error",
{
"ts-expect-error": {
"descriptionFormat": "^: TS\\d+ .+$"
}
}
],
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/no-unnecessary-condition": "off",
"@typescript-eslint/no-magic-numbers": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
"ignoreRestSiblings": true
}
],
"@typescript-eslint/no-non-null-assertion": "off",
"no-restricted-globals": ["error", "window", "document"],
"no-restricted-imports": [
"error",
{
"paths": [
// prevent absolute imports from src subfolders like `import { ... } from "lib"`
"appearance",
"components",
"helpers",
"hoc",
"hooks",
"lib",
"styles",
"testing",
"types",
"tokenized"
],
"patterns": [
"@vkontakte/icons/dist/*",
// prevent absolute imports from src subfolders like `import { ... } from "lib/platform"`
"appearance/*",
"components/*",
"helpers/*",
"hoc/*",
"hooks/*",
"lib/*",
"styles/*",
"testing/*",
"types/*",
"tokenized/*"
]
}
],
"no-restricted-properties": [
"error",
{
"property": "querySelector",
"message": "Make sure to use [data-*] selector, not class"
},
{
"property": "querySelectorAll",
"message": "Make sure to use [data-*] selector, not class"
},
{
"property": "matches",
"message": "Make sure to use [data-*] selector, not class"
},
{
"property": "closest",
"message": "Make sure to use [data-*] selector, not class"
},
{
"property": "getElementsByClassName",
"message": "Use .querySelectorAll('[data-*]')"
},
{
"property": "classList",
"message": "Make sure to use 'vkui' prefix"
},
{
"property": "getElementById",
"message": "Absolutely do not use id"
},
{
"object": "React",
"property": "useLayoutEffect",
"message": "Prefer lib/useIsomorphicLayoutEffect"
}
],
"react/react-in-jsx-scope": "off",
"no-restricted-syntax": [
"error",
{
"selector": "ImportDeclaration[source.value=/^\\W+(index(\\.ts)?)?$/i]",
"message": "Do not import index"
},
{
"selector": "ImportDeclaration[source.value=/\\.css$/i] ~ ImportDeclaration[source.value!=/\\.css$/i]",
"message": "CSS import must be last"
}
],
"import/no-default-export": "error",
"vkui/no-object-expression-in-arguments": [
"error",
{
"onlyForFunctionsWithNames": ["classNames", "classNamesString"]
}
],
"compat/compat": "error",
"react/no-unknown-property": ["error"]
},
"overrides": [
{
"files": ["src/**/*.{test,spec,e2e}.{ts,tsx}", "e2e/**/*", "src/testing/**/*"],
"env": {
"jest": true
},
"rules": {
"no-restricted-properties": "off",
"no-restricted-globals": "off",
"compat/compat": "off",
"react/display-name": "off"
}
},
{
"files": ["src/**/*.e2e.{ts,tsx}", "e2e/**/*", "src/testing/**/*"],
"extends": ["plugin:jest-playwright/recommended"]
}
]
}