@itcase/lint 1.1.136 → 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,13 @@
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
+
1
11
  ## [1.1.136](https://github.com/ITCase/itcase-lint/compare/v1.1.135...v1.1.136) (2026-11-13)
2
12
 
3
13
  ### Features
@@ -2,7 +2,15 @@ import stylelint from 'stylelint';
2
2
  declare const _default: {
3
3
  extends: string[];
4
4
  ignoreFiles: string[];
5
- plugins: (string | stylelint.Plugin)[];
5
+ plugins: (string | {
6
+ rule: stylelint.Rule;
7
+ ruleName: string;
8
+ } | {
9
+ default?: {
10
+ ruleName: string;
11
+ rule: stylelint.Rule;
12
+ };
13
+ })[];
6
14
  rules: {
7
15
  'max-nesting-depth': number;
8
16
  'alpha-value-notation': (string | {
@@ -80,6 +88,9 @@ declare const _default: {
80
88
  'selector-class-pattern': (string | {
81
89
  severity: string;
82
90
  })[];
91
+ 'selector-id-pattern': (string | {
92
+ message: (selector: string) => string;
93
+ })[];
83
94
  'selector-nested-pattern': (string | {
84
95
  splitList: boolean;
85
96
  })[];
@@ -2,6 +2,7 @@ import assert from 'node:assert/strict';
2
2
  import { describe, it } from 'node:test';
3
3
  import stylelint from 'stylelint';
4
4
  import config from './index3.js';
5
+ import 'stylelint-order';
5
6
 
6
7
  // `prettier/prettier` грузит `prettier.config.js`, а тот импортирует `dist`.
7
8
  // В CI сборки ещё нет. Эти тесты проверяют другие правила.
@@ -165,6 +166,59 @@ describe('stylelint config', () => {
165
166
  assert.equal(allowed.length, 0);
166
167
  assert.equal(mentions(rejected, 'not-a-rule'), true);
167
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
+ });
168
222
  it('allows $() and fluid() and rejects an unknown function', async () => {
169
223
  const allowed = await warningsFor(`
170
224
  .item {
@@ -1,4 +1,5 @@
1
1
  import stylelint from 'stylelint';
2
+ import orderPlugins from 'stylelint-order';
2
3
 
3
4
  // postcss-nested: ^& / ^^& / &^&. Не [attr^="..."] — там после ^ стоит =, не &.
4
5
  const postcssNestedParentSelector = /(?:^|[\s>~+,])\^+&|&\^+&/;
@@ -37,6 +38,65 @@ function collectParked(walkRules) {
37
38
  });
38
39
  return parked;
39
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
+ }
40
100
  // css-tree в selector-no-invalid не парсит ^&. Снимаем такие правила на время проверки.
41
101
  const selectorNoInvalidRuleName = 'itcase/selector-no-invalid';
42
102
  const selectorNoInvalidRule = Object.assign((primary, _secondaryOptions, context) => {
@@ -90,7 +150,11 @@ var config = {
90
150
  ],
91
151
  plugins: [
92
152
  'stylelint-prettier',
93
- 'stylelint-order',
153
+ ...orderPlugins.map((plugin) => {
154
+ if (plugin.ruleName !== 'order/properties-order')
155
+ return plugin;
156
+ return stylelint.createPlugin(plugin.ruleName, skipPageDescriptors(plugin.rule));
157
+ }),
94
158
  'stylelint-no-unsupported-browser-features',
95
159
  stylelint.createPlugin(selectorNoInvalidRuleName, selectorNoInvalidRule),
96
160
  ],
@@ -299,6 +363,7 @@ var config = {
299
363
  ignore: [
300
364
  'css-autofill',
301
365
  'css-nesting',
366
+ 'css-paged-media',
302
367
  'css-variables',
303
368
  'prefers-color-scheme',
304
369
  ],
@@ -331,6 +396,13 @@ var config = {
331
396
  severity: 'warning',
332
397
  },
333
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
+ ],
334
406
  // Вложенный селектор: & / ^& / && / &_mod&_mod, дальше БЭМ, псевдо, атрибут или комбинатор.
335
407
  // splitList — каждая часть списка селекторов отдельно.
336
408
  'selector-nested-pattern': [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itcase/lint",
3
- "version": "1.1.136",
3
+ "version": "1.1.137",
4
4
  "author": "ITCase",
5
5
  "description": "Code style linter configuration presets ",
6
6
  "engines": {
@@ -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"