@itcase/lint 1.1.135 → 1.1.137

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 CHANGED
@@ -1,3 +1,31 @@
1
+ ## [1.1.137](https://github.com/ITCase/itcase-lint/compare/v1.1.136...v1.1.137) (2026-11-15)
2
+
3
+ ### Features
4
+
5
+ * **stylelint:** skip [@page](https://github.com/page) in property order and allow __next id ([d233217](https://github.com/ITCase/itcase-lint/commit/d233217896e1d43f345172bce9f62c3461d5ca84))
6
+
7
+ ### Dependencies
8
+
9
+ * **other:** bump dependencies ([82f5f03](https://github.com/ITCase/itcase-lint/commit/82f5f035e2532ddbd785dd3a7107bfb23674107d))
10
+
11
+ ## [1.1.136](https://github.com/ITCase/itcase-lint/compare/v1.1.135...v1.1.136) (2026-11-13)
12
+
13
+ ### Features
14
+
15
+ * **stylelint:** add itcase selector-no-invalid for postcss-nested ^& ([6e8f9b1](https://github.com/ITCase/itcase-lint/commit/6e8f9b1c8059e6b6030190ea0198f421fb162d12))
16
+
17
+ ### Bug Fixes
18
+
19
+ * **other:** quote test script glob for shell expansion ([234ac6e](https://github.com/ITCase/itcase-lint/commit/234ac6eba40f9a4d598360db8d171dcd0579b087))
20
+
21
+ ### Tests
22
+
23
+ * **stylelint:** disable prettier rule in stylelint tests ([343671b](https://github.com/ITCase/itcase-lint/commit/343671ba44ad33992b24d0d3e67650acc01ea7c4))
24
+
25
+ ### Continuous Integrations
26
+
27
+ * **other:** add github actions workflow for tests ([92c1b88](https://github.com/ITCase/itcase-lint/commit/92c1b88289fefb2ecfeb390bc0c7f256bfa4742a))
28
+
1
29
  ## [1.1.135](https://github.com/ITCase/itcase-lint/compare/v1.1.134...v1.1.135) (2026-11-11)
2
30
 
3
31
  ### Features
@@ -12,7 +12,7 @@ import eslintReactHooks from 'eslint-plugin-react-hooks';
12
12
  import eslintReactNative from 'eslint-plugin-react-native';
13
13
  import globals from 'globals';
14
14
  import eslintTypeScript from 'typescript-eslint';
15
- import { s as sortUnionTypes, a as sortObjectTypes, b as sortObjects, c as sortExports, d as sortNamedExports, e as sortMaps, f as sortJSXProps, g as sortIntersectionTypes, h as sortInterfaces, i as sortEnums } from '../sortUnionTypes_C5VVNaF3.js';
15
+ import { i as sortUnionTypes, g as sortObjectTypes, h as sortObjects, a as sortExports, f as sortNamedExports, e as sortMaps, d as sortJSXProps, c as sortIntersectionTypes, b as sortInterfaces, s as sortEnums } from '../sortUnionTypes_2NZizu0R.js';
16
16
  import parser from '@typescript-eslint/parser';
17
17
  import { i as itcaseLintPlugin, p as pluginName, r as ruleName, a as pluginName$1, b as ruleName$1, s as storybookConfig } from '../index_CmQAJvhW.js';
18
18
  import { noRestrictedSyntaxRestrictWords } from './restrictWords/index.js';
@@ -1,4 +1,4 @@
1
- export { i as sortEnums, c as sortExports, h as sortInterfaces, g as sortIntersectionTypes, f as sortJSXProps, e as sortMaps, d as sortNamedExports, a as sortObjectTypes, b as sortObjects, s as sortUnionTypes } from '../../sortUnionTypes_C5VVNaF3.js';
1
+ export { s as sortEnums, a as sortExports, b as sortInterfaces, c as sortIntersectionTypes, d as sortJSXProps, e as sortMaps, f as sortNamedExports, g as sortObjectTypes, h as sortObjects, i as sortUnionTypes } from '../../sortUnionTypes_2NZizu0R.js';
2
2
 
3
3
  const sortClasses = [
4
4
  'error',
@@ -547,4 +547,4 @@ const sortUnionTypes = [
547
547
  },
548
548
  ];
549
549
 
550
- export { sortObjectTypes as a, sortObjects as b, sortExports as c, sortNamedExports as d, sortMaps as e, sortJSXProps as f, sortIntersectionTypes as g, sortInterfaces as h, sortEnums as i, sortUnionTypes as s };
550
+ export { sortExports as a, sortInterfaces as b, sortIntersectionTypes as c, sortJSXProps as d, sortMaps as e, sortNamedExports as f, sortObjectTypes as g, sortObjects as h, sortUnionTypes as i, sortEnums as s };
@@ -1,7 +1,16 @@
1
+ import stylelint from 'stylelint';
1
2
  declare const _default: {
2
3
  extends: string[];
3
4
  ignoreFiles: string[];
4
- plugins: string[];
5
+ plugins: (string | {
6
+ rule: stylelint.Rule;
7
+ ruleName: string;
8
+ } | {
9
+ default?: {
10
+ ruleName: string;
11
+ rule: stylelint.Rule;
12
+ };
13
+ })[];
5
14
  rules: {
6
15
  'max-nesting-depth': number;
7
16
  'alpha-value-notation': (string | {
@@ -46,6 +55,7 @@ declare const _default: {
46
55
  'function-url-quotes': string;
47
56
  'hue-degree-notation': string;
48
57
  'import-notation': string;
58
+ 'itcase/selector-no-invalid': boolean;
49
59
  'keyframes-name-pattern': (string | {
50
60
  message: string;
51
61
  })[];
@@ -78,7 +88,13 @@ declare const _default: {
78
88
  'selector-class-pattern': (string | {
79
89
  severity: string;
80
90
  })[];
81
- 'selector-nested-pattern': string;
91
+ 'selector-id-pattern': (string | {
92
+ message: (selector: string) => string;
93
+ })[];
94
+ 'selector-nested-pattern': (string | {
95
+ splitList: boolean;
96
+ })[];
97
+ 'selector-no-invalid': null;
82
98
  'selector-type-no-unknown': null;
83
99
  'shorthand-property-no-redundant-values': null;
84
100
  };
@@ -0,0 +1,19 @@
1
+ interface SelectorRule {
2
+ raws: {
3
+ selector?: unknown;
4
+ };
5
+ selector: string;
6
+ }
7
+ type ParkedRule<RuleNode extends SelectorRule> = {
8
+ next: {
9
+ parent?: unknown;
10
+ } | undefined;
11
+ node: RuleNode;
12
+ parent?: {
13
+ append: (node: RuleNode) => void;
14
+ insertBefore: (existingNode: {
15
+ parent?: unknown;
16
+ }, newNode: RuleNode) => void;
17
+ };
18
+ };
19
+ export type { ParkedRule, SelectorRule };
@@ -1,267 +1 @@
1
- // eslint-disable-next-line import/no-default-export
2
- var index = {
3
- extends: ['stylelint-config-standard'],
4
- ignoreFiles: [
5
- '**/__*.css',
6
- '**/import.css',
7
- '**/vendor/**/*.css',
8
- '**/vendor/*.css',
9
- '__*.css',
10
- '**/*.ts',
11
- '**/*.tsx',
12
- '**/*.js',
13
- '**/*.jsx',
14
- '**/*.mjs',
15
- '**/*.md',
16
- 'ios/**/*',
17
- 'android/**/*',
18
- ],
19
- plugins: [
20
- 'stylelint-prettier',
21
- 'stylelint-order',
22
- 'stylelint-no-unsupported-browser-features',
23
- ],
24
- rules: {
25
- 'max-nesting-depth': 20,
26
- 'alpha-value-notation': [
27
- 'number',
28
- {
29
- exceptProperties: ['opacity'],
30
- },
31
- ],
32
- 'at-rule-empty-line-before': [
33
- 'always',
34
- {
35
- except: ['inside-block'],
36
- ignore: [
37
- 'after-comment',
38
- 'first-nested',
39
- 'blockless-after-same-name-blockless',
40
- 'blockless-after-blockless',
41
- ],
42
- },
43
- ],
44
- 'at-rule-no-unknown': [
45
- true,
46
- {
47
- ignoreAtRules: [
48
- 'import-glob',
49
- 'for',
50
- 'each',
51
- 'mixin',
52
- 'extend',
53
- 'define-mixin',
54
- ],
55
- },
56
- ],
57
- 'block-no-empty': null,
58
- 'color-function-notation': 'legacy',
59
- 'color-no-hex': true,
60
- 'comment-empty-line-before': [
61
- 'always',
62
- {
63
- except: ['first-nested'],
64
- ignore: ['after-comment'],
65
- },
66
- ],
67
- 'custom-property-empty-line-before': null,
68
- // kebab-case и _, плюс $(token) из postcss-each.
69
- 'custom-property-pattern': '^(?:[a-z]|\\$\\([A-Za-z0-9_-]+\\))(?:[a-z0-9_-]|\\$\\([A-Za-z0-9_-]+\\))*$',
70
- 'declaration-empty-line-before': 'never',
71
- 'declaration-property-value-no-unknown': [
72
- true,
73
- {
74
- ignoreProperties: {
75
- top: '/.+/',
76
- right: '/.+/',
77
- bottom: '/.+/',
78
- left: '/.+/',
79
- border: '/.+/',
80
- margin: '/.+/',
81
- padding: '/.+/',
82
- gap: '/.+/',
83
- '/-gap$/': '/.+/',
84
- '/^border-/': '/.+/',
85
- '/^margin-/': '/.+/',
86
- '/^padding-/': '/.+/',
87
- },
88
- },
89
- ],
90
- 'function-no-unknown': [true, { ignoreFunctions: ['$', 'fluid'] }],
91
- 'function-url-quotes': 'always',
92
- 'hue-degree-notation': 'number',
93
- 'import-notation': 'string',
94
- 'keyframes-name-pattern': [
95
- '^([a-z]+)([A-Z]?[a-z]+)+$',
96
- { message: 'Expected keyframe name to be camelCase' },
97
- ],
98
- 'no-descending-specificity': null,
99
- 'order/order': [
100
- [
101
- 'declarations',
102
- {
103
- type: 'at-rule',
104
- name: 'extend',
105
- },
106
- {
107
- type: 'at-rule',
108
- name: 'mixin',
109
- },
110
- {
111
- type: 'at-rule',
112
- name: 'media',
113
- },
114
- {
115
- type: 'rule',
116
- selector: '^&::(before|after)',
117
- },
118
- {
119
- type: 'rule',
120
- selector: '^&:\\w',
121
- },
122
- {
123
- type: 'rule',
124
- selector: '^&_',
125
- },
126
- {
127
- type: 'rule',
128
- selector: '^.',
129
- },
130
- ],
131
- {
132
- unspecified: 'bottom',
133
- },
134
- ],
135
- 'order/properties-order': [
136
- [
137
- 'width',
138
- 'height',
139
- 'min-width',
140
- 'min-height',
141
- 'max-width',
142
- 'max-height',
143
- 'aspect-ratio',
144
- 'font',
145
- 'font-size',
146
- 'font-range',
147
- 'font-weight',
148
- 'color',
149
- 'text-shadow',
150
- 'text-decoration',
151
- 'text-transform',
152
- 'text-align',
153
- 'text-rendering',
154
- 'white-space',
155
- 'line-height',
156
- 'line-height-range',
157
- 'letter-spacing',
158
- 'background',
159
- 'background-position',
160
- 'background-repeat',
161
- 'background-size',
162
- 'padding',
163
- 'margin',
164
- 'border',
165
- 'border-width',
166
- 'border-color',
167
- 'border-style',
168
- 'border-radius',
169
- 'border-left',
170
- 'border-top',
171
- 'border-right',
172
- 'border-bottom',
173
- 'float',
174
- 'clear',
175
- 'position',
176
- 'overflow',
177
- 'content',
178
- 'display',
179
- 'flex',
180
- 'flex-direction',
181
- 'flex-wrap',
182
- 'flex-flow',
183
- 'order',
184
- 'justify-content',
185
- 'align-items',
186
- 'align-self',
187
- 'align-content',
188
- 'flex-grow',
189
- 'flex-shrink',
190
- 'flex-basis',
191
- 'visibility',
192
- 'box-sizing',
193
- 'box-shadow',
194
- 'left',
195
- 'top',
196
- 'right',
197
- 'bottom',
198
- 'vertical-align',
199
- 'z-index',
200
- 'transform',
201
- 'transition',
202
- 'animation',
203
- 'animation-delay',
204
- 'animation-direction',
205
- 'animation-duration',
206
- 'animation-fill-mode',
207
- 'animation-iteration-count',
208
- 'animation-name',
209
- 'animation-play-state',
210
- 'animation-timing-function',
211
- 'opacity',
212
- 'cursor',
213
- ],
214
- ],
215
- 'plugin/no-unsupported-browser-features': [
216
- true,
217
- {
218
- browsers: [
219
- 'defaults',
220
- 'not op_mini all',
221
- 'not kaios >= 0',
222
- 'not and_uc >= 0',
223
- 'not and_qq >= 0',
224
- ],
225
- ignore: [
226
- 'css-autofill',
227
- 'css-nesting',
228
- 'css-variables',
229
- 'prefers-color-scheme',
230
- ],
231
- },
232
- ],
233
- 'prettier/prettier': true,
234
- 'property-disallowed-list': ['/^margin-/', '/^padding-/'],
235
- 'property-no-unknown': [
236
- true,
237
- {
238
- ignoreProperties: [
239
- 'letter-spacing-range',
240
- 'aspect-ratio',
241
- 'font-range',
242
- 'line-height-range',
243
- ],
244
- },
245
- ],
246
- 'rule-empty-line-before': [
247
- 'always',
248
- {
249
- except: ['first-nested', 'inside-block'],
250
- ignore: ['after-comment'],
251
- },
252
- ],
253
- // block[-part][__element]*[_modifier]*[--modifier]*, $(token) в частях.
254
- 'selector-class-pattern': [
255
- '^[a-z][a-z0-9]*(-[a-z0-9]+)*(?:__[a-zA-Z0-9$()-]+)*(?:_[a-zA-Z0-9$()-]+)*(?:--[a-zA-Z0-9$()-]+)*$',
256
- {
257
- severity: 'warning',
258
- },
259
- ],
260
- // Вложенный селектор: & / ^& / &&, дальше БЭМ, псевдо, атрибут или комбинатор.
261
- 'selector-nested-pattern': '^(?:[a-z]+&+|\\.[a-z][\\w-]*&+|>\\s+\\^+&+|&+\\^+&+|\\^+&+|&+)(?:(?:__|--|_|-)[\\w$().-]*|::[\\w-]+|:[\\w-]+(?:\\([^)]*\\))?|\\[[^\\]]+\\]|\\.[\\w$().-]+|[A-Za-z0-9]+)?(?:\\s*[>~+]\\s+\\S+|\\s+\\S+|\\.[\\w$().-]+|::[\\w-]+|:[\\w-]+(?:\\([^)]*\\))?|\\[[^\\]]+\\])*$',
262
- 'selector-type-no-unknown': null,
263
- 'shorthand-property-no-redundant-values': null,
264
- },
265
- };
266
1
 
267
- export { index as default };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,237 @@
1
+ import assert from 'node:assert/strict';
2
+ import { describe, it } from 'node:test';
3
+ import stylelint from 'stylelint';
4
+ import config from './index3.js';
5
+ import 'stylelint-order';
6
+
7
+ // `prettier/prettier` грузит `prettier.config.js`, а тот импортирует `dist`.
8
+ // В CI сборки ещё нет. Эти тесты проверяют другие правила.
9
+ const testConfig = {
10
+ ...config,
11
+ rules: {
12
+ ...config.rules,
13
+ 'prettier/prettier': null,
14
+ },
15
+ };
16
+ const nestedFormsCss = `
17
+ .form {
18
+ &__group {
19
+ &_hidden {
20
+ display: none;
21
+ }
22
+ &_type_row&_hidden {
23
+ display: none;
24
+ }
25
+ &_column {
26
+ @each $count in 2, 3 {
27
+ &_$(count) {
28
+ ^^&-items {
29
+ display: grid;
30
+ }
31
+ }
32
+ }
33
+ }
34
+ &-wrapper {
35
+ ^&-message {
36
+ &_type_error {
37
+ display: block;
38
+ }
39
+ }
40
+ }
41
+ }
42
+ }
43
+
44
+ .form-field {
45
+ &-code {
46
+ &^&_type_classic {
47
+ ^^&__label {
48
+ display: block;
49
+ }
50
+ }
51
+ &^&_size {
52
+ @each $size in m, s {
53
+ &_$(size) {
54
+ gap: var(--form-filed-code-size-$(size)-gap);
55
+ }
56
+ }
57
+ }
58
+ }
59
+ }
60
+ `;
61
+ async function warningsFor(code, rule) {
62
+ const result = await stylelint.lint({
63
+ config: testConfig,
64
+ code,
65
+ codeFilename: 'fixture.css',
66
+ });
67
+ return result.results[0].warnings
68
+ .filter((warning) => warning.rule === rule)
69
+ .map((warning) => warning.text);
70
+ }
71
+ function mentions(warnings, text) {
72
+ return warnings.some((warning) => warning.includes(text));
73
+ }
74
+ describe('stylelint config', () => {
75
+ it('allows form custom properties with _ and $(token)', async () => {
76
+ const warnings = await warningsFor(`
77
+ .block {
78
+ --form-field_type_classic-padding: 0;
79
+ --form-filed-code-size-$(size)-gap: 0;
80
+ }
81
+ `, 'custom-property-pattern');
82
+ assert.equal(warnings.length, 0);
83
+ });
84
+ it('rejects a custom property that starts with a capital letter', async () => {
85
+ const warnings = await warningsFor(`
86
+ .block {
87
+ --Padding: 0;
88
+ }
89
+ `, 'custom-property-pattern');
90
+ assert.equal(mentions(warnings, 'Padding'), true);
91
+ });
92
+ it('allows BEM classes used by forms', async () => {
93
+ const warnings = await warningsFor(`
94
+ .form__group_type_row {
95
+ display: block;
96
+ }
97
+ `, 'selector-class-pattern');
98
+ assert.equal(warnings.length, 0);
99
+ });
100
+ it('rejects a class that starts with a capital letter', async () => {
101
+ const warnings = await warningsFor(`
102
+ .Form {
103
+ display: block;
104
+ }
105
+ `, 'selector-class-pattern');
106
+ assert.equal(mentions(warnings, 'Form'), true);
107
+ });
108
+ it('allows postcss-nested selectors from forms css', async () => {
109
+ const warnings = await warningsFor(nestedFormsCss, 'selector-nested-pattern');
110
+ assert.equal(warnings.length, 0);
111
+ });
112
+ it('rejects a nested selector outside the pattern', async () => {
113
+ const warnings = await warningsFor(`
114
+ .form {
115
+ NOT_A_SELECTOR {
116
+ display: block;
117
+ }
118
+ }
119
+ `, 'selector-nested-pattern');
120
+ assert.equal(mentions(warnings, 'NOT_A_SELECTOR'), true);
121
+ });
122
+ it('does not flag ^& and still flags an invalid pseudo', async () => {
123
+ const code = `
124
+ .form {
125
+ ^&-message {
126
+ display: block;
127
+ }
128
+ &:dir(sideways) {
129
+ display: block;
130
+ }
131
+ }
132
+ `;
133
+ const invalid = await warningsFor(code, 'selector-no-invalid');
134
+ const itcaseInvalid = await warningsFor(code, 'itcase/selector-no-invalid');
135
+ assert.equal(mentions(invalid, '^&'), false);
136
+ assert.equal(mentions(itcaseInvalid, '^&'), false);
137
+ assert.equal(mentions(invalid, ':dir(sideways)'), true);
138
+ });
139
+ it('allows a camelCase keyframe and rejects kebab-case', async () => {
140
+ const allowed = await warningsFor(`
141
+ @keyframes fadeIn {
142
+ from { opacity: 0; }
143
+ to { opacity: 1; }
144
+ }
145
+ `, 'keyframes-name-pattern');
146
+ const rejected = await warningsFor(`
147
+ @keyframes fade-in {
148
+ from { opacity: 0; }
149
+ to { opacity: 1; }
150
+ }
151
+ `, 'keyframes-name-pattern');
152
+ assert.equal(allowed.length, 0);
153
+ assert.equal(mentions(rejected, 'camelCase'), true);
154
+ });
155
+ it('allows @each and rejects an unknown at-rule', async () => {
156
+ const allowed = await warningsFor(`
157
+ @each $count in 2, 3 {
158
+ .item { display: block; }
159
+ }
160
+ `, 'at-rule-no-unknown');
161
+ const rejected = await warningsFor(`
162
+ @not-a-rule {
163
+ .item { display: block; }
164
+ }
165
+ `, 'at-rule-no-unknown');
166
+ assert.equal(allowed.length, 0);
167
+ assert.equal(mentions(rejected, 'not-a-rule'), true);
168
+ });
169
+ it('allows @page descriptors and still orders padding before margin', async () => {
170
+ const pageCss = `
171
+ @media print {
172
+ @page {
173
+ width: 210mm;
174
+ height: 297mm;
175
+ size: a4;
176
+ margin: 0;
177
+ padding: 5mm;
178
+ }
179
+ }
180
+ `;
181
+ const orderWarnings = await warningsFor(`
182
+ ${pageCss}
183
+ .block {
184
+ margin: 0;
185
+ padding: 0;
186
+ }
187
+ `, 'order/properties-order');
188
+ const browserWarnings = await warningsFor(pageCss, 'plugin/no-unsupported-browser-features');
189
+ assert.equal(orderWarnings.length, 1);
190
+ assert.equal(mentions(orderWarnings, 'padding'), true);
191
+ assert.equal(browserWarnings.length, 0);
192
+ });
193
+ it('allows #__next in a nested print block and rejects a non-kebab id', async () => {
194
+ const result = await stylelint.lint({
195
+ config: testConfig,
196
+ code: `
197
+ .page {
198
+ & > #__next {
199
+ position: relative;
200
+ overflow: hidden;
201
+ display: flex;
202
+ flex-direction: column;
203
+ @media print {
204
+ width: 100%;
205
+ height: auto !important;
206
+ overflow: auto;
207
+ display: block;
208
+ }
209
+ }
210
+ }
211
+ `,
212
+ codeFilename: 'fixture.css',
213
+ });
214
+ const rejected = await warningsFor(`
215
+ #next_root {
216
+ display: block;
217
+ }
218
+ `, 'selector-id-pattern');
219
+ assert.deepEqual(result.results[0].warnings, []);
220
+ assert.equal(mentions(rejected, 'next_root'), true);
221
+ });
222
+ it('allows $() and fluid() and rejects an unknown function', async () => {
223
+ const allowed = await warningsFor(`
224
+ .item {
225
+ width: $(count);
226
+ font-size: fluid(16, 24);
227
+ }
228
+ `, 'function-no-unknown');
229
+ const rejected = await warningsFor(`
230
+ .item {
231
+ width: nope(1);
232
+ }
233
+ `, 'function-no-unknown');
234
+ assert.equal(allowed.length, 0);
235
+ assert.equal(mentions(rejected, 'nope'), true);
236
+ });
237
+ });
@@ -0,0 +1,421 @@
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itcase/lint",
3
- "version": "1.1.135",
3
+ "version": "1.1.137",
4
4
  "author": "ITCase",
5
5
  "description": "Code style linter configuration presets ",
6
6
  "engines": {
@@ -15,7 +15,7 @@
15
15
  "prepack": "NODE_ENV=production npm run build",
16
16
  "pre-commit": "npm run typecheck",
17
17
  "semantic-release": "semantic-release",
18
- "test": "npx tsx --test --test-reporter=spec src/**/*.test.ts",
18
+ "test": "npx tsx --test --test-reporter=spec \"src/**/*.test.ts\"",
19
19
  "typecheck": "tsc --noEmit"
20
20
  },
21
21
  "type": "module",
@@ -44,7 +44,7 @@
44
44
  "registry": "https://registry.npmjs.org/"
45
45
  },
46
46
  "dependencies": {
47
- "@babel/eslint-parser": "^8.0.7",
47
+ "@babel/eslint-parser": "^8.1.2",
48
48
  "@babel/eslint-plugin": "^8.1.0",
49
49
  "@eslint/compat": "^2.1.1",
50
50
  "@eslint/js": "^10.0.1",
@@ -61,7 +61,7 @@
61
61
  "eslint-plugin-html": "^8.2.1",
62
62
  "eslint-plugin-import": "^2.32.0",
63
63
  "eslint-plugin-json": "^5.0.0",
64
- "eslint-plugin-mobx": "^0.2.1",
64
+ "eslint-plugin-mobx": "^0.2.2",
65
65
  "eslint-plugin-n": "^18.5.0",
66
66
  "eslint-plugin-node": "^11.1.0",
67
67
  "eslint-plugin-perfectionist": "^5.13.0",
@@ -70,10 +70,10 @@
70
70
  "eslint-plugin-react": "^7.37.5",
71
71
  "eslint-plugin-react-hooks": "^7.1.1",
72
72
  "eslint-plugin-react-native": "^5.0.0",
73
- "eslint-plugin-react-refresh": "^0.5.7",
73
+ "eslint-plugin-react-refresh": "^0.5.8",
74
74
  "eslint-plugin-storybook": "^10.6.7",
75
75
  "globals": "^17.14.0",
76
- "prettier": "^3.10.0",
76
+ "prettier": "^3.10.1",
77
77
  "stylelint": "^18.0.0",
78
78
  "stylelint-config-standard": "^41.0.0",
79
79
  "stylelint-no-unsupported-browser-features": "^8.1.2",
@@ -91,7 +91,7 @@
91
91
  "husky": "^9.1.7",
92
92
  "lint-staged": "^17.6.0",
93
93
  "react": "^19.3.1",
94
- "rollup": "4.68.2",
94
+ "rollup": "4.68.3",
95
95
  "storybook": "^10.6.7",
96
96
  "tsx": "^4.23.15",
97
97
  "typescript": "^6.0.3"