@alexlit/config-eslint 167.5.1 → 167.6.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/package.json +1 -1
- package/plugins/prettier.js +2 -11
- package/plugins/vue.js +100 -109
- package/rules/restricted-syntax.js +12 -0
- package/rules/style.js +18 -3
package/package.json
CHANGED
package/plugins/prettier.js
CHANGED
|
@@ -2,7 +2,7 @@ import config from 'eslint-config-prettier';
|
|
|
2
2
|
import { defineConfig } from 'eslint/config';
|
|
3
3
|
|
|
4
4
|
import { FILES, VUE_FILES } from '../base.js';
|
|
5
|
-
import { STYLE_RULES } from '../rules/style.js';
|
|
5
|
+
import { STYLE_RULES, VUE_HTML_SELF_CLOSING } from '../rules/style.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Отключает правила ESLint, конфликтующие с Prettier.
|
|
@@ -21,16 +21,7 @@ export const prettier = (customConfig = []) =>
|
|
|
21
21
|
{ files: FILES, ...config, rules: { ...config.rules, ...STYLE_RULES } },
|
|
22
22
|
{
|
|
23
23
|
files: VUE_FILES,
|
|
24
|
-
rules: {
|
|
25
|
-
'vue/html-self-closing': [
|
|
26
|
-
'error',
|
|
27
|
-
{
|
|
28
|
-
html: { component: 'always', normal: 'never', void: 'always' },
|
|
29
|
-
math: 'always',
|
|
30
|
-
svg: 'always',
|
|
31
|
-
},
|
|
32
|
-
],
|
|
33
|
-
},
|
|
24
|
+
rules: { 'vue/html-self-closing': VUE_HTML_SELF_CLOSING },
|
|
34
25
|
},
|
|
35
26
|
|
|
36
27
|
customConfig,
|
package/plugins/vue.js
CHANGED
|
@@ -4,6 +4,13 @@ import typescript from 'typescript-eslint';
|
|
|
4
4
|
|
|
5
5
|
import { DATA_FILES, TEST_FILES, VUE_FILES } from '../base.js';
|
|
6
6
|
import { NO_RESTRICTED_SYNTAX } from '../rules/restricted-syntax.js';
|
|
7
|
+
import { VUE_HTML_SELF_CLOSING } from '../rules/style.js';
|
|
8
|
+
|
|
9
|
+
/** Максимальное количество props у компонента */
|
|
10
|
+
const MAX_PROPS = 12;
|
|
11
|
+
|
|
12
|
+
/** Максимальная глубина вложенности шаблона */
|
|
13
|
+
const MAX_TEMPLATE_DEPTH = 8;
|
|
7
14
|
|
|
8
15
|
/**
|
|
9
16
|
* Правила для Vue.js.
|
|
@@ -39,18 +46,6 @@ export const vue = (config = []) =>
|
|
|
39
46
|
selector:
|
|
40
47
|
"TSInterfaceDeclaration[id.name='Props'], TSTypeAliasDeclaration[id.name='Props']",
|
|
41
48
|
},
|
|
42
|
-
{
|
|
43
|
-
message:
|
|
44
|
-
'При вызове useRoute() переменная должна называться строго "$route" (const $route = useRoute()).',
|
|
45
|
-
selector:
|
|
46
|
-
'VariableDeclarator[init.callee.name="useRoute"][id.name!="$route"]',
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
message:
|
|
50
|
-
'При вызове useRouter() переменная должна называться строго "$router" (const $router = useRouter()).',
|
|
51
|
-
selector:
|
|
52
|
-
'VariableDeclarator[init.callee.name="useRouter"][id.name!="$router"]',
|
|
53
|
-
},
|
|
54
49
|
],
|
|
55
50
|
'vue/attributes-order': ['error', { alphabetical: true }],
|
|
56
51
|
'vue/block-lang': [
|
|
@@ -58,7 +53,6 @@ export const vue = (config = []) =>
|
|
|
58
53
|
{
|
|
59
54
|
script: { lang: 'ts' },
|
|
60
55
|
style: { allowNoLang: true, lang: ['postcss', 'scss'] },
|
|
61
|
-
template: {},
|
|
62
56
|
},
|
|
63
57
|
],
|
|
64
58
|
'vue/block-order': [
|
|
@@ -76,8 +70,8 @@ export const vue = (config = []) =>
|
|
|
76
70
|
},
|
|
77
71
|
],
|
|
78
72
|
'vue/component-options-name-casing': ['error', 'PascalCase'],
|
|
79
|
-
'vue/custom-event-name-casing': ['error', 'camelCase'
|
|
80
|
-
'vue/define-emits-declaration': ['error'],
|
|
73
|
+
'vue/custom-event-name-casing': ['error', 'camelCase'],
|
|
74
|
+
'vue/define-emits-declaration': ['error', 'type-based'],
|
|
81
75
|
'vue/define-macros-order': [
|
|
82
76
|
'error',
|
|
83
77
|
{
|
|
@@ -98,36 +92,28 @@ export const vue = (config = []) =>
|
|
|
98
92
|
'onPrehydrate',
|
|
99
93
|
// /Nuxt (могут использоваться props)
|
|
100
94
|
|
|
101
|
-
//
|
|
95
|
+
// nuxt-ui
|
|
102
96
|
'defineLocale',
|
|
103
97
|
'defineShortcuts',
|
|
104
98
|
'extendLocale',
|
|
105
99
|
'extractShortcuts',
|
|
106
|
-
// /
|
|
100
|
+
// /nuxt-ui
|
|
107
101
|
],
|
|
108
102
|
},
|
|
109
103
|
],
|
|
110
|
-
'vue/define-props-declaration': ['error'],
|
|
104
|
+
'vue/define-props-declaration': ['error', 'type-based'],
|
|
111
105
|
'vue/define-props-destructuring': [
|
|
112
106
|
'warn',
|
|
113
107
|
{ destructure: 'only-when-assigned' },
|
|
114
108
|
],
|
|
115
|
-
'vue/dot-notation':
|
|
109
|
+
'vue/dot-notation': 'error',
|
|
116
110
|
'vue/enforce-style-attribute': ['error', { allow: ['scoped'] }],
|
|
117
|
-
'vue/eqeqeq':
|
|
118
|
-
'vue/html-button-has-type':
|
|
119
|
-
'vue/html-comment-content-newline':
|
|
120
|
-
'vue/html-comment-content-spacing':
|
|
121
|
-
'vue/html-comment-indent':
|
|
122
|
-
'vue/html-
|
|
123
|
-
'vue/html-self-closing': [
|
|
124
|
-
'error',
|
|
125
|
-
{
|
|
126
|
-
html: { component: 'always', normal: 'never', void: 'always' },
|
|
127
|
-
math: 'always',
|
|
128
|
-
svg: 'always',
|
|
129
|
-
},
|
|
130
|
-
],
|
|
111
|
+
'vue/eqeqeq': 'error',
|
|
112
|
+
'vue/html-button-has-type': 'error',
|
|
113
|
+
'vue/html-comment-content-newline': 'warn',
|
|
114
|
+
'vue/html-comment-content-spacing': 'warn',
|
|
115
|
+
'vue/html-comment-indent': 'warn',
|
|
116
|
+
'vue/html-self-closing': VUE_HTML_SELF_CLOSING,
|
|
131
117
|
// Синхронизировано с `unicorn/filename-case` в `unicorn.js`:
|
|
132
118
|
// компоненты лежат в kebab-case-файлах, поэтому имя компонента
|
|
133
119
|
// выводится из имени kebab-case-файла, а не требуется
|
|
@@ -136,38 +122,32 @@ export const vue = (config = []) =>
|
|
|
136
122
|
'error',
|
|
137
123
|
{ extensions: ['vue'], shouldMatchCase: false },
|
|
138
124
|
],
|
|
139
|
-
'vue/match-component-import-name':
|
|
140
|
-
'vue/max-attributes-per-line': ['error', { singleline: 3 }],
|
|
125
|
+
'vue/match-component-import-name': 'error',
|
|
141
126
|
'vue/max-lines-per-block': [
|
|
142
127
|
'warn',
|
|
143
128
|
{ script: 500, skipBlankLines: true, style: 500, template: 500 },
|
|
144
129
|
],
|
|
145
|
-
'vue/
|
|
130
|
+
'vue/max-props': ['warn', { maxProps: MAX_PROPS }],
|
|
131
|
+
'vue/max-template-depth': ['warn', { maxDepth: MAX_TEMPLATE_DEPTH }],
|
|
146
132
|
'vue/next-tick-style': ['error', 'promise'],
|
|
147
|
-
'vue/no-
|
|
148
|
-
'vue/no-
|
|
149
|
-
'vue/no-content-outside-block':
|
|
150
|
-
'vue/no-
|
|
151
|
-
'vue/no-
|
|
152
|
-
'vue/no-
|
|
153
|
-
'vue/no-
|
|
154
|
-
'vue/no-
|
|
155
|
-
'vue/no-
|
|
156
|
-
'vue/no-
|
|
157
|
-
'vue/no-
|
|
158
|
-
'vue/no-
|
|
159
|
-
'vue/no-
|
|
160
|
-
'vue/no-
|
|
161
|
-
'vue/no-
|
|
162
|
-
'vue/no-
|
|
163
|
-
'vue/no-
|
|
164
|
-
'vue/no-
|
|
165
|
-
'vue/no-negated-condition': ['error'],
|
|
166
|
-
'vue/no-negated-v-if-condition': ['error'],
|
|
167
|
-
'vue/no-parsing-error': ['error'],
|
|
168
|
-
'vue/no-potential-component-option-typo': ['error'],
|
|
169
|
-
'vue/no-props-shadow': ['error'],
|
|
170
|
-
'vue/no-ref-object-reactivity-loss': ['error'],
|
|
133
|
+
'vue/no-console': 'warn',
|
|
134
|
+
'vue/no-constant-condition': 'error',
|
|
135
|
+
'vue/no-content-outside-block': 'error',
|
|
136
|
+
'vue/no-deprecated-html-elements': 'error',
|
|
137
|
+
'vue/no-duplicate-attr-inheritance': 'error',
|
|
138
|
+
'vue/no-duplicate-class-names': 'error',
|
|
139
|
+
'vue/no-empty-component-block': 'error',
|
|
140
|
+
'vue/no-empty-pattern': 'error',
|
|
141
|
+
'vue/no-implicit-coercion': 'error',
|
|
142
|
+
'vue/no-import-compiler-macros': 'error',
|
|
143
|
+
'vue/no-irregular-whitespace': 'error',
|
|
144
|
+
'vue/no-loss-of-precision': 'error',
|
|
145
|
+
'vue/no-multiple-objects-in-class': 'error',
|
|
146
|
+
'vue/no-negated-condition': 'error',
|
|
147
|
+
'vue/no-negated-v-if-condition': 'error',
|
|
148
|
+
'vue/no-potential-component-option-typo': 'error',
|
|
149
|
+
'vue/no-props-shadow': 'error',
|
|
150
|
+
'vue/no-ref-object-reactivity-loss': 'error',
|
|
171
151
|
'vue/no-required-prop-with-default': ['error', { autofix: true }],
|
|
172
152
|
'vue/no-reserved-component-names': [
|
|
173
153
|
'error',
|
|
@@ -176,41 +156,50 @@ export const vue = (config = []) =>
|
|
|
176
156
|
disallowVueBuiltInComponents: true,
|
|
177
157
|
},
|
|
178
158
|
],
|
|
179
|
-
'vue/no-restricted-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
159
|
+
'vue/no-restricted-html-elements': [
|
|
160
|
+
'error',
|
|
161
|
+
{
|
|
162
|
+
element: [
|
|
163
|
+
'blink',
|
|
164
|
+
'center',
|
|
165
|
+
'font',
|
|
166
|
+
'frame',
|
|
167
|
+
'frameset',
|
|
168
|
+
'marquee',
|
|
169
|
+
'strike',
|
|
170
|
+
'tt',
|
|
171
|
+
],
|
|
172
|
+
message: 'Используйте CSS вместо устаревшего HTML-элемента.',
|
|
173
|
+
},
|
|
174
|
+
],
|
|
175
|
+
'vue/no-root-v-if': 'error',
|
|
176
|
+
'vue/no-setup-props-reactivity-loss': 'error',
|
|
177
|
+
'vue/no-shadow-native-events': 'error',
|
|
178
|
+
'vue/no-sparse-arrays': 'error',
|
|
185
179
|
'vue/no-static-inline-styles': ['error', { allowBinding: true }],
|
|
186
|
-
'vue/no-this-in-before-route-enter':
|
|
187
|
-
'vue/no-undef-components':
|
|
188
|
-
'vue/no-undef-directives':
|
|
189
|
-
'vue/no-unsupported-features':
|
|
190
|
-
'vue/no-unused-
|
|
191
|
-
'vue/no-unused-emit-declarations': ['error'],
|
|
180
|
+
'vue/no-this-in-before-route-enter': 'error',
|
|
181
|
+
'vue/no-undef-components': 'error',
|
|
182
|
+
'vue/no-undef-directives': 'error',
|
|
183
|
+
'vue/no-unsupported-features': 'error',
|
|
184
|
+
'vue/no-unused-emit-declarations': 'error',
|
|
192
185
|
'vue/no-unused-properties': [
|
|
193
186
|
'error',
|
|
194
187
|
{ groups: ['inject', 'props', 'asyncData', 'computed', 'methods'] },
|
|
195
188
|
],
|
|
196
|
-
'vue/no-unused-refs':
|
|
197
|
-
'vue/no-use-
|
|
198
|
-
'vue/no-use-v-else-with-v-for': ['warn'],
|
|
189
|
+
'vue/no-unused-refs': 'error',
|
|
190
|
+
'vue/no-use-v-else-with-v-for': 'warn',
|
|
199
191
|
'vue/no-use-v-if-with-v-for': [
|
|
200
|
-
'
|
|
192
|
+
'error',
|
|
201
193
|
{ allowUsingIterationVar: true },
|
|
202
194
|
],
|
|
203
|
-
'vue/no-useless-
|
|
204
|
-
'vue/no-useless-
|
|
205
|
-
'vue/no-useless-v-bind':
|
|
206
|
-
'vue/no-v-for-template-key': 'off',
|
|
195
|
+
'vue/no-useless-concat': 'error',
|
|
196
|
+
'vue/no-useless-mustaches': 'error',
|
|
197
|
+
'vue/no-useless-v-bind': 'error',
|
|
207
198
|
'vue/no-v-html': ['error', { ignorePattern: '^html' }],
|
|
208
|
-
'vue/no-v-
|
|
209
|
-
'vue/
|
|
210
|
-
'vue/no-v-text-v-html-on-component': ['error'],
|
|
211
|
-
'vue/object-shorthand': ['error'],
|
|
199
|
+
'vue/no-v-text': 'error',
|
|
200
|
+
'vue/object-shorthand': 'error',
|
|
212
201
|
'vue/order-in-components': 'off',
|
|
213
|
-
'vue/padding-line-between-blocks':
|
|
202
|
+
'vue/padding-line-between-blocks': 'error',
|
|
214
203
|
'vue/padding-line-between-tags': [
|
|
215
204
|
'error',
|
|
216
205
|
[{ blankLine: 'always', next: '*', prev: '*' }],
|
|
@@ -219,16 +208,15 @@ export const vue = (config = []) =>
|
|
|
219
208
|
'error',
|
|
220
209
|
{ groupSingleLineProperties: true },
|
|
221
210
|
],
|
|
222
|
-
'vue/prefer-define-options':
|
|
223
|
-
'vue/prefer-prop-type-boolean-first':
|
|
224
|
-
'vue/prefer-separate-static-class':
|
|
225
|
-
'vue/prefer-single-event-payload':
|
|
226
|
-
'vue/prefer-
|
|
227
|
-
'vue/prefer-
|
|
228
|
-
'vue/prefer-
|
|
229
|
-
'vue/
|
|
230
|
-
'vue/require-
|
|
231
|
-
'vue/require-explicit-slots': ['warn'],
|
|
211
|
+
'vue/prefer-define-options': 'error',
|
|
212
|
+
'vue/prefer-prop-type-boolean-first': 'error',
|
|
213
|
+
'vue/prefer-separate-static-class': 'error',
|
|
214
|
+
'vue/prefer-single-event-payload': 'error',
|
|
215
|
+
'vue/prefer-template': 'warn',
|
|
216
|
+
'vue/prefer-true-attribute-shorthand': 'error',
|
|
217
|
+
'vue/prefer-use-template-ref': 'error',
|
|
218
|
+
'vue/prefer-v-model': 'error',
|
|
219
|
+
'vue/require-explicit-slots': 'warn',
|
|
232
220
|
'vue/require-macro-variable-name': [
|
|
233
221
|
'error',
|
|
234
222
|
{
|
|
@@ -239,38 +227,41 @@ export const vue = (config = []) =>
|
|
|
239
227
|
useSlots: '$slots',
|
|
240
228
|
},
|
|
241
229
|
],
|
|
242
|
-
'vue/require-typed-object-prop':
|
|
243
|
-
'vue/require-typed-ref':
|
|
230
|
+
'vue/require-typed-object-prop': 'error',
|
|
231
|
+
'vue/require-typed-ref': 'error',
|
|
244
232
|
'vue/slot-name-casing': ['error', 'kebab-case'],
|
|
245
|
-
'vue/
|
|
246
|
-
'vue/static-class-names-order': ['warn'],
|
|
233
|
+
'vue/static-class-names-order': 'warn',
|
|
247
234
|
'vue/this-in-template': ['error', 'never'],
|
|
248
235
|
'vue/v-bind-style': [
|
|
249
236
|
'error',
|
|
250
237
|
'shorthand',
|
|
251
238
|
{ sameNameShorthand: 'always' },
|
|
252
239
|
],
|
|
253
|
-
'vue/v-for-delimiter-style': ['error'],
|
|
254
|
-
'vue/v-if-else-key':
|
|
255
|
-
'vue/v-on-event-hyphenation': ['error'],
|
|
256
|
-
'vue/
|
|
257
|
-
'vue/valid-next-tick': ['error'],
|
|
258
|
-
'vue/valid-v-bind-sync': ['error'],
|
|
259
|
-
'vue/valid-v-slot': ['error'],
|
|
240
|
+
'vue/v-for-delimiter-style': ['error', 'in'],
|
|
241
|
+
'vue/v-if-else-key': 'error',
|
|
242
|
+
'vue/v-on-event-hyphenation': ['error', 'always', { autofix: true }],
|
|
243
|
+
'vue/v-on-handler-style': ['error', ['method', 'inline-function']],
|
|
260
244
|
},
|
|
261
245
|
},
|
|
262
246
|
|
|
263
247
|
{
|
|
264
|
-
files:
|
|
265
|
-
rules: {
|
|
248
|
+
files: VUE_FILES,
|
|
249
|
+
rules: {
|
|
250
|
+
// Форматирование шаблонов, которое отключает `plugins.prettier()`.
|
|
251
|
+
// Блок оставлен для проектов без Prettier.
|
|
252
|
+
'vue/html-end-tags': 'error',
|
|
253
|
+
'vue/max-attributes-per-line': ['error', { singleline: 3 }],
|
|
254
|
+
'vue/quote-props': ['error', 'as-needed'],
|
|
255
|
+
},
|
|
266
256
|
},
|
|
267
257
|
|
|
268
258
|
{
|
|
269
259
|
files: [
|
|
270
260
|
'**/app/*.vue',
|
|
271
|
-
'**/
|
|
261
|
+
'**/error.vue',
|
|
272
262
|
'**/layouts/**/*.vue',
|
|
273
263
|
'**/pages/**/*.vue',
|
|
264
|
+
'**/src/*.vue',
|
|
274
265
|
],
|
|
275
266
|
rules: { 'vue/multi-word-component-names': 'off' },
|
|
276
267
|
},
|
|
@@ -25,4 +25,16 @@ export const NO_RESTRICTED_SYNTAX = [
|
|
|
25
25
|
"Используйте методы массивов(.forEach, .map и т.д.) вместо цикла 'for...of'.",
|
|
26
26
|
selector: 'ForOfStatement',
|
|
27
27
|
},
|
|
28
|
+
{
|
|
29
|
+
message:
|
|
30
|
+
'При вызове useRoute() переменная должна называться строго "$route" (const $route = useRoute()).',
|
|
31
|
+
selector:
|
|
32
|
+
'VariableDeclarator[init.callee.name="useRoute"][id.name!="$route"]',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
message:
|
|
36
|
+
'При вызове useRouter() переменная должна называться строго "$router" (const $router = useRouter()).',
|
|
37
|
+
selector:
|
|
38
|
+
'VariableDeclarator[init.callee.name="useRouter"][id.name!="$router"]',
|
|
39
|
+
},
|
|
28
40
|
];
|
package/rules/style.js
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
* Правила форматирования, которые должны пережить `eslint-config-prettier`.
|
|
3
3
|
*
|
|
4
4
|
* `eslint-config-prettier` отключает все основные правила форматирования,
|
|
5
|
-
* поэтому эти
|
|
6
|
-
*
|
|
7
|
-
* `eslint-config-prettier`.
|
|
5
|
+
* поэтому эти правила объявлены в одном месте. `javascript.js` включает их как
|
|
6
|
+
* базовые, а `prettier.js` повторно применяет после `eslint-config-prettier`.
|
|
8
7
|
*/
|
|
9
8
|
export const STYLE_RULES = {
|
|
10
9
|
curly: 'error',
|
|
@@ -14,3 +13,19 @@ export const STYLE_RULES = {
|
|
|
14
13
|
{ allowTemplateLiterals: false, avoidEscape: true },
|
|
15
14
|
],
|
|
16
15
|
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Общая настройка `vue/html-self-closing`.
|
|
19
|
+
*
|
|
20
|
+
* `eslint-config-prettier` отключает это правило, поэтому `prettier.js`
|
|
21
|
+
* повторно применяет его после Prettier. Конфигурация вынесена в константу,
|
|
22
|
+
* чтобы `vue.js` и `prettier.js` не расходились.
|
|
23
|
+
*/
|
|
24
|
+
export const VUE_HTML_SELF_CLOSING = [
|
|
25
|
+
'error',
|
|
26
|
+
{
|
|
27
|
+
html: { component: 'always', normal: 'never', void: 'always' },
|
|
28
|
+
math: 'always',
|
|
29
|
+
svg: 'always',
|
|
30
|
+
},
|
|
31
|
+
];
|