@itcase/lint 1.1.137 → 1.1.139
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/CHANGELOG.md +23 -0
- package/dist/eslint/index.js +1 -1
- package/dist/eslint/mobx/index.d.ts +0 -3
- package/dist/eslint/perfectionist/index.js +1 -1
- package/dist/eslint/storybook/index.d.ts +25 -25
- package/dist/{sortUnionTypes_2NZizu0R.js → sortUnionTypes_C5VVNaF3.js} +1 -1
- package/dist/stylelint/index.js +410 -0
- package/package.json +26 -26
- package/dist/stylelint/index2.js +0 -237
- package/dist/stylelint/index3.js +0 -421
package/dist/stylelint/index3.js
DELETED
|
@@ -1,421 +0,0 @@
|
|
|
1
|
-
import stylelint from 'stylelint';
|
|
2
|
-
import orderPlugins from 'stylelint-order';
|
|
3
|
-
|
|
4
|
-
// postcss-nested: ^& / ^^& / &^&. Не [attr^="..."] — там после ^ стоит =, не &.
|
|
5
|
-
const postcssNestedParentSelector = /(?:^|[\s>~+,])\^+&|&\^+&/;
|
|
6
|
-
// Кусок после &: БЭМ, псевдо, атрибут, класс или тег. $(token) из postcss-each.
|
|
7
|
-
const nestedSelectorChunk = '(?:(?:__|--|_|-)[\\w$().-]*|::[\\w-]+|:[\\w-]+(?:\\([^)]*\\))?|\\[[^\\]]+\\]|\\.[\\w$().-]+|[A-Za-z0-9]+)?';
|
|
8
|
-
const nestedSelectorPattern = [
|
|
9
|
-
'^(?:[a-z]+&+|\\.[a-z][\\w-]*&+|>\\s+\\^+&+|&+\\^+&+|\\^+&+|&+)',
|
|
10
|
-
nestedSelectorChunk,
|
|
11
|
-
'(?:\\s*[>~+]\\s+\\S+|\\s+\\S+|\\.[\\w$().-]+|::[\\w-]+|:[\\w-]+(?:\\([^)]*\\))?|\\[[^\\]]+\\]|',
|
|
12
|
-
'&+',
|
|
13
|
-
nestedSelectorChunk,
|
|
14
|
-
')*$',
|
|
15
|
-
].join('');
|
|
16
|
-
function readRuleSelector(ruleNode) {
|
|
17
|
-
const raw = ruleNode.raws.selector;
|
|
18
|
-
if (typeof raw === 'string' && raw)
|
|
19
|
-
return raw;
|
|
20
|
-
if (raw &&
|
|
21
|
-
typeof raw === 'object' &&
|
|
22
|
-
'raw' in raw &&
|
|
23
|
-
typeof raw.raw === 'string') {
|
|
24
|
-
return raw.raw;
|
|
25
|
-
}
|
|
26
|
-
return ruleNode.selector;
|
|
27
|
-
}
|
|
28
|
-
function collectParked(walkRules) {
|
|
29
|
-
const parked = [];
|
|
30
|
-
walkRules((ruleNode) => {
|
|
31
|
-
if (!postcssNestedParentSelector.test(readRuleSelector(ruleNode)))
|
|
32
|
-
return;
|
|
33
|
-
parked.push({
|
|
34
|
-
next: ruleNode.next(),
|
|
35
|
-
node: ruleNode,
|
|
36
|
-
parent: ruleNode.parent,
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
return parked;
|
|
40
|
-
}
|
|
41
|
-
// order/properties-order — порядок свойств компонента.
|
|
42
|
-
// У @page другие дескрипторы (size, margin, padding), их из проверки убираем.
|
|
43
|
-
function collectPageAtRules(walkAtRules) {
|
|
44
|
-
const parked = [];
|
|
45
|
-
walkAtRules((atRule) => {
|
|
46
|
-
parked.push({
|
|
47
|
-
next: atRule.next(),
|
|
48
|
-
node: atRule,
|
|
49
|
-
parent: atRule.parent,
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
return parked;
|
|
53
|
-
}
|
|
54
|
-
function restorePageAtRules(parked) {
|
|
55
|
-
// С конца: соседний @page уже снова в дереве, insertBefore попадает в него.
|
|
56
|
-
for (let index = parked.length - 1; index >= 0; index -= 1) {
|
|
57
|
-
const item = parked[index];
|
|
58
|
-
if (!item.parent)
|
|
59
|
-
continue;
|
|
60
|
-
if (item.next && item.next.parent === item.parent) {
|
|
61
|
-
item.parent.insertBefore(item.next, item.node);
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
item.parent.append(item.node);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function skipPageDescriptors(orderRule) {
|
|
69
|
-
const wrapped = (primary, secondaryOptions, context) => {
|
|
70
|
-
return (root, result) => {
|
|
71
|
-
const parked = collectPageAtRules((callback) => {
|
|
72
|
-
root.walkAtRules('page', callback);
|
|
73
|
-
});
|
|
74
|
-
for (let index = parked.length - 1; index >= 0; index -= 1) {
|
|
75
|
-
parked[index].node.remove();
|
|
76
|
-
}
|
|
77
|
-
try {
|
|
78
|
-
const outcome = orderRule(primary, secondaryOptions, context)(root, result);
|
|
79
|
-
if (outcome instanceof Promise) {
|
|
80
|
-
return outcome.finally(() => {
|
|
81
|
-
restorePageAtRules(parked);
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
restorePageAtRules(parked);
|
|
85
|
-
return outcome;
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
restorePageAtRules(parked);
|
|
89
|
-
throw error;
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
return Object.assign(wrapped, {
|
|
94
|
-
messages: orderRule.messages,
|
|
95
|
-
meta: orderRule.meta,
|
|
96
|
-
primaryOptionArray: orderRule.primaryOptionArray,
|
|
97
|
-
ruleName: orderRule.ruleName,
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
// css-tree в selector-no-invalid не парсит ^&. Снимаем такие правила на время проверки.
|
|
101
|
-
const selectorNoInvalidRuleName = 'itcase/selector-no-invalid';
|
|
102
|
-
const selectorNoInvalidRule = Object.assign((primary, _secondaryOptions, context) => {
|
|
103
|
-
return async (root, result) => {
|
|
104
|
-
if (primary !== true)
|
|
105
|
-
return;
|
|
106
|
-
const parked = collectParked((callback) => {
|
|
107
|
-
root.walkRules(callback);
|
|
108
|
-
});
|
|
109
|
-
for (let index = parked.length - 1; index >= 0; index -= 1) {
|
|
110
|
-
parked[index].node.remove();
|
|
111
|
-
}
|
|
112
|
-
try {
|
|
113
|
-
const coreRule = await stylelint.rules['selector-no-invalid'];
|
|
114
|
-
await coreRule(true, {}, context)(root, result);
|
|
115
|
-
}
|
|
116
|
-
finally {
|
|
117
|
-
for (const item of parked) {
|
|
118
|
-
if (!item.parent)
|
|
119
|
-
continue;
|
|
120
|
-
if (item.next && item.next.parent === item.parent) {
|
|
121
|
-
item.parent.insertBefore(item.next, item.node);
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
item.parent.append(item.node);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
}, {
|
|
130
|
-
messages: {},
|
|
131
|
-
ruleName: selectorNoInvalidRuleName,
|
|
132
|
-
});
|
|
133
|
-
// eslint-disable-next-line import/no-default-export
|
|
134
|
-
var config = {
|
|
135
|
-
extends: ['stylelint-config-standard'],
|
|
136
|
-
ignoreFiles: [
|
|
137
|
-
'**/__*.css',
|
|
138
|
-
'**/import.css',
|
|
139
|
-
'**/vendor/**/*.css',
|
|
140
|
-
'**/vendor/*.css',
|
|
141
|
-
'__*.css',
|
|
142
|
-
'**/*.ts',
|
|
143
|
-
'**/*.tsx',
|
|
144
|
-
'**/*.js',
|
|
145
|
-
'**/*.jsx',
|
|
146
|
-
'**/*.mjs',
|
|
147
|
-
'**/*.md',
|
|
148
|
-
'ios/**/*',
|
|
149
|
-
'android/**/*',
|
|
150
|
-
],
|
|
151
|
-
plugins: [
|
|
152
|
-
'stylelint-prettier',
|
|
153
|
-
...orderPlugins.map((plugin) => {
|
|
154
|
-
if (plugin.ruleName !== 'order/properties-order')
|
|
155
|
-
return plugin;
|
|
156
|
-
return stylelint.createPlugin(plugin.ruleName, skipPageDescriptors(plugin.rule));
|
|
157
|
-
}),
|
|
158
|
-
'stylelint-no-unsupported-browser-features',
|
|
159
|
-
stylelint.createPlugin(selectorNoInvalidRuleName, selectorNoInvalidRule),
|
|
160
|
-
],
|
|
161
|
-
rules: {
|
|
162
|
-
'max-nesting-depth': 20,
|
|
163
|
-
'alpha-value-notation': [
|
|
164
|
-
'number',
|
|
165
|
-
{
|
|
166
|
-
exceptProperties: ['opacity'],
|
|
167
|
-
},
|
|
168
|
-
],
|
|
169
|
-
'at-rule-empty-line-before': [
|
|
170
|
-
'always',
|
|
171
|
-
{
|
|
172
|
-
except: ['inside-block'],
|
|
173
|
-
ignore: [
|
|
174
|
-
'after-comment',
|
|
175
|
-
'first-nested',
|
|
176
|
-
'blockless-after-same-name-blockless',
|
|
177
|
-
'blockless-after-blockless',
|
|
178
|
-
],
|
|
179
|
-
},
|
|
180
|
-
],
|
|
181
|
-
'at-rule-no-unknown': [
|
|
182
|
-
true,
|
|
183
|
-
{
|
|
184
|
-
ignoreAtRules: [
|
|
185
|
-
'import-glob',
|
|
186
|
-
'for',
|
|
187
|
-
'each',
|
|
188
|
-
'mixin',
|
|
189
|
-
'extend',
|
|
190
|
-
'define-mixin',
|
|
191
|
-
],
|
|
192
|
-
},
|
|
193
|
-
],
|
|
194
|
-
'block-no-empty': null,
|
|
195
|
-
'color-function-notation': 'legacy',
|
|
196
|
-
'color-no-hex': true,
|
|
197
|
-
'comment-empty-line-before': [
|
|
198
|
-
'always',
|
|
199
|
-
{
|
|
200
|
-
except: ['first-nested'],
|
|
201
|
-
ignore: ['after-comment'],
|
|
202
|
-
},
|
|
203
|
-
],
|
|
204
|
-
'custom-property-empty-line-before': null,
|
|
205
|
-
// kebab-case и _, плюс $(token) из postcss-each.
|
|
206
|
-
'custom-property-pattern': '^(?:[a-z]|\\$\\([A-Za-z0-9_-]+\\))(?:[a-z0-9_-]|\\$\\([A-Za-z0-9_-]+\\))*$',
|
|
207
|
-
'declaration-empty-line-before': 'never',
|
|
208
|
-
'declaration-property-value-no-unknown': [
|
|
209
|
-
true,
|
|
210
|
-
{
|
|
211
|
-
ignoreProperties: {
|
|
212
|
-
top: '/.+/',
|
|
213
|
-
right: '/.+/',
|
|
214
|
-
bottom: '/.+/',
|
|
215
|
-
left: '/.+/',
|
|
216
|
-
border: '/.+/',
|
|
217
|
-
margin: '/.+/',
|
|
218
|
-
padding: '/.+/',
|
|
219
|
-
gap: '/.+/',
|
|
220
|
-
'/-gap$/': '/.+/',
|
|
221
|
-
'/^border-/': '/.+/',
|
|
222
|
-
'/^margin-/': '/.+/',
|
|
223
|
-
'/^padding-/': '/.+/',
|
|
224
|
-
},
|
|
225
|
-
},
|
|
226
|
-
],
|
|
227
|
-
'function-no-unknown': [true, { ignoreFunctions: ['$', 'fluid'] }],
|
|
228
|
-
'function-url-quotes': 'always',
|
|
229
|
-
'hue-degree-notation': 'number',
|
|
230
|
-
'import-notation': 'string',
|
|
231
|
-
'itcase/selector-no-invalid': true,
|
|
232
|
-
'keyframes-name-pattern': [
|
|
233
|
-
'^([a-z]+)([A-Z]?[a-z]+)+$',
|
|
234
|
-
{ message: 'Expected keyframe name to be camelCase' },
|
|
235
|
-
],
|
|
236
|
-
'no-descending-specificity': null,
|
|
237
|
-
'order/order': [
|
|
238
|
-
[
|
|
239
|
-
'declarations',
|
|
240
|
-
{
|
|
241
|
-
type: 'at-rule',
|
|
242
|
-
name: 'extend',
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
type: 'at-rule',
|
|
246
|
-
name: 'mixin',
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
type: 'at-rule',
|
|
250
|
-
name: 'media',
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
type: 'rule',
|
|
254
|
-
selector: '^&::(before|after)',
|
|
255
|
-
},
|
|
256
|
-
{
|
|
257
|
-
type: 'rule',
|
|
258
|
-
selector: '^&:\\w',
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
type: 'rule',
|
|
262
|
-
selector: '^&_',
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
type: 'rule',
|
|
266
|
-
selector: '^.',
|
|
267
|
-
},
|
|
268
|
-
],
|
|
269
|
-
{
|
|
270
|
-
unspecified: 'bottom',
|
|
271
|
-
},
|
|
272
|
-
],
|
|
273
|
-
'order/properties-order': [
|
|
274
|
-
[
|
|
275
|
-
'width',
|
|
276
|
-
'height',
|
|
277
|
-
'min-width',
|
|
278
|
-
'min-height',
|
|
279
|
-
'max-width',
|
|
280
|
-
'max-height',
|
|
281
|
-
'aspect-ratio',
|
|
282
|
-
'font',
|
|
283
|
-
'font-size',
|
|
284
|
-
'font-range',
|
|
285
|
-
'font-weight',
|
|
286
|
-
'color',
|
|
287
|
-
'text-shadow',
|
|
288
|
-
'text-decoration',
|
|
289
|
-
'text-transform',
|
|
290
|
-
'text-align',
|
|
291
|
-
'text-rendering',
|
|
292
|
-
'white-space',
|
|
293
|
-
'line-height',
|
|
294
|
-
'line-height-range',
|
|
295
|
-
'letter-spacing',
|
|
296
|
-
'background',
|
|
297
|
-
'background-position',
|
|
298
|
-
'background-repeat',
|
|
299
|
-
'background-size',
|
|
300
|
-
'padding',
|
|
301
|
-
'margin',
|
|
302
|
-
'border',
|
|
303
|
-
'border-width',
|
|
304
|
-
'border-color',
|
|
305
|
-
'border-style',
|
|
306
|
-
'border-radius',
|
|
307
|
-
'border-left',
|
|
308
|
-
'border-top',
|
|
309
|
-
'border-right',
|
|
310
|
-
'border-bottom',
|
|
311
|
-
'float',
|
|
312
|
-
'clear',
|
|
313
|
-
'position',
|
|
314
|
-
'overflow',
|
|
315
|
-
'content',
|
|
316
|
-
'display',
|
|
317
|
-
'flex',
|
|
318
|
-
'flex-direction',
|
|
319
|
-
'flex-wrap',
|
|
320
|
-
'flex-flow',
|
|
321
|
-
'order',
|
|
322
|
-
'justify-content',
|
|
323
|
-
'align-items',
|
|
324
|
-
'align-self',
|
|
325
|
-
'align-content',
|
|
326
|
-
'flex-grow',
|
|
327
|
-
'flex-shrink',
|
|
328
|
-
'flex-basis',
|
|
329
|
-
'visibility',
|
|
330
|
-
'box-sizing',
|
|
331
|
-
'box-shadow',
|
|
332
|
-
'left',
|
|
333
|
-
'top',
|
|
334
|
-
'right',
|
|
335
|
-
'bottom',
|
|
336
|
-
'vertical-align',
|
|
337
|
-
'z-index',
|
|
338
|
-
'transform',
|
|
339
|
-
'transition',
|
|
340
|
-
'animation',
|
|
341
|
-
'animation-delay',
|
|
342
|
-
'animation-direction',
|
|
343
|
-
'animation-duration',
|
|
344
|
-
'animation-fill-mode',
|
|
345
|
-
'animation-iteration-count',
|
|
346
|
-
'animation-name',
|
|
347
|
-
'animation-play-state',
|
|
348
|
-
'animation-timing-function',
|
|
349
|
-
'opacity',
|
|
350
|
-
'cursor',
|
|
351
|
-
],
|
|
352
|
-
],
|
|
353
|
-
'plugin/no-unsupported-browser-features': [
|
|
354
|
-
true,
|
|
355
|
-
{
|
|
356
|
-
browsers: [
|
|
357
|
-
'defaults',
|
|
358
|
-
'not op_mini all',
|
|
359
|
-
'not kaios >= 0',
|
|
360
|
-
'not and_uc >= 0',
|
|
361
|
-
'not and_qq >= 0',
|
|
362
|
-
],
|
|
363
|
-
ignore: [
|
|
364
|
-
'css-autofill',
|
|
365
|
-
'css-nesting',
|
|
366
|
-
'css-paged-media',
|
|
367
|
-
'css-variables',
|
|
368
|
-
'prefers-color-scheme',
|
|
369
|
-
],
|
|
370
|
-
},
|
|
371
|
-
],
|
|
372
|
-
'prettier/prettier': true,
|
|
373
|
-
'property-disallowed-list': ['/^margin-/', '/^padding-/'],
|
|
374
|
-
'property-no-unknown': [
|
|
375
|
-
true,
|
|
376
|
-
{
|
|
377
|
-
ignoreProperties: [
|
|
378
|
-
'letter-spacing-range',
|
|
379
|
-
'aspect-ratio',
|
|
380
|
-
'font-range',
|
|
381
|
-
'line-height-range',
|
|
382
|
-
],
|
|
383
|
-
},
|
|
384
|
-
],
|
|
385
|
-
'rule-empty-line-before': [
|
|
386
|
-
'always',
|
|
387
|
-
{
|
|
388
|
-
except: ['first-nested', 'inside-block'],
|
|
389
|
-
ignore: ['after-comment'],
|
|
390
|
-
},
|
|
391
|
-
],
|
|
392
|
-
// block[-part][__element]*[_modifier]*[--modifier]*, $(token) в частях.
|
|
393
|
-
'selector-class-pattern': [
|
|
394
|
-
'^[a-z][a-z0-9]*(-[a-z0-9]+)*(?:__[a-zA-Z0-9$()-]+)*(?:_[a-zA-Z0-9$()-]+)*(?:--[a-zA-Z0-9$()-]+)*$',
|
|
395
|
-
{
|
|
396
|
-
severity: 'warning',
|
|
397
|
-
},
|
|
398
|
-
],
|
|
399
|
-
// kebab-case, плюс #__next — корень Next.js.
|
|
400
|
-
'selector-id-pattern': [
|
|
401
|
-
'^(?:__next|[a-z][a-z0-9]*(?:-[a-z0-9]+)*)$',
|
|
402
|
-
{
|
|
403
|
-
message: (selector) => `Expected id selector "${selector}" to be kebab-case`,
|
|
404
|
-
},
|
|
405
|
-
],
|
|
406
|
-
// Вложенный селектор: & / ^& / && / &_mod&_mod, дальше БЭМ, псевдо, атрибут или комбинатор.
|
|
407
|
-
// splitList — каждая часть списка селекторов отдельно.
|
|
408
|
-
'selector-nested-pattern': [
|
|
409
|
-
nestedSelectorPattern,
|
|
410
|
-
{
|
|
411
|
-
splitList: true,
|
|
412
|
-
},
|
|
413
|
-
],
|
|
414
|
-
// css-tree не парсит postcss-nested ^&. Проверка в itcase/selector-no-invalid.
|
|
415
|
-
'selector-no-invalid': null,
|
|
416
|
-
'selector-type-no-unknown': null,
|
|
417
|
-
'shorthand-property-no-redundant-values': null,
|
|
418
|
-
},
|
|
419
|
-
};
|
|
420
|
-
|
|
421
|
-
export { config as default };
|