@alexlit/config-stylelint 61.5.1 → 63.0.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/README.md CHANGED
@@ -1,62 +1,145 @@
1
- # StyleLint Configuration
1
+ # Stylelint Configuration
2
2
 
3
- ## Installation
3
+ Готовая конфигурация [Stylelint](https://stylelint.io/) для проверки CSS, SCSS и
4
+ Vue-файлов: настроенные правила из популярных stylelint-плагинов — порядок и
5
+ синтаксис свойств, доступность, БЭМ, поддержка SCSS и т.д. Вместо того чтобы
6
+ подключать и настраивать каждый плагин вручную, соберите конфигурацию из готовых
7
+ проверок.
8
+
9
+ Проверки модульные: по умолчанию ничего не включено — вы сами перечисляете
10
+ нужные в `defineConfig`.
11
+
12
+ ## Установка
4
13
 
5
14
  ```sh
6
15
  npm i @alexlit/config-stylelint -D
7
16
  ```
8
17
 
9
- ## Connection
18
+ ## Быстрый старт
10
19
 
11
- - Default
12
- ([see plugins enabled by default](https://github.com/alex-lit/lint-kit/blob/master/packages/config-stylelint/index.js))
20
+ ```js
21
+ // stylelint.config.js
22
+ import { defineConfig, plugins } from '@alexlit/config-stylelint';
13
23
 
14
- ```js
15
- // stylelint.config.js
16
- import { createConfig } from '@alexlit/config-stylelint';
24
+ export default defineConfig([
25
+ plugins.scss(),
26
+ plugins.vue(),
27
+ plugins.prettier(),
28
+ ]);
29
+ ```
17
30
 
18
- export default createConfig();
19
- ```
31
+ Каждый вызов `plugins.*()` — отдельная проверка. Добавьте только то, что нужно
32
+ проекту; полный список — в разделе [Проверки](#проверки).
20
33
 
21
- - Custom
22
-
23
- ```js
24
- // stylelint.config.js
25
- import { createConfig } from '@alexlit/config-stylelint';
26
-
27
- export default createConfig(
28
- {
29
- // disable some default plugins
30
- 'no-nested-media': false,
31
-
32
- // enable some optional plugins
33
- 'gamut': true,
34
- 'logical-css': true,
35
- },
36
- {
37
- // add custom rules
38
- rules: {
39
- 'custom-property-empty-line-before': [
40
- 'always',
41
- {
42
- except: ['after-comment', 'after-custom-property', 'first-nested'],
43
- },
44
- ],
45
- },
46
- },
47
- );
48
- ```
34
+ Больше проверок — просто допишите их в массив:
35
+
36
+ ```js
37
+ // stylelint.config.js
38
+ import { defineConfig, plugins } from '@alexlit/config-stylelint';
39
+
40
+ export default defineConfig([
41
+ plugins.colorFormat(),
42
+ plugins.declarationBlockNoIgnoredProperties(),
43
+ plugins.highPerformanceAnimation(),
44
+ plugins.noNestedMedia(),
45
+ plugins.order(),
46
+ plugins.scss(),
47
+ plugins.selectorNoEmpty(),
48
+ plugins.useNesting(),
49
+ plugins.vue(),
50
+ plugins.a11y(),
51
+ plugins.bem(),
52
+ plugins.gamut(),
53
+ plugins.logicalCss(),
54
+ plugins.mediaUseCustomMedia(),
55
+ plugins.noUnresolvedModule(),
56
+ plugins.noUnsupportedBrowserFeatures(),
57
+ plugins.prettier(),
58
+ ]);
59
+ ```
60
+
61
+ ## Настройка
62
+
63
+ ### Правила конкретной проверки
64
+
65
+ Чтобы переопределить правила одной проверки, передайте объект в её вызов:
66
+
67
+ ```js
68
+ // stylelint.config.js
69
+ import { defineConfig, plugins } from '@alexlit/config-stylelint';
70
+
71
+ export default defineConfig([
72
+ plugins.useNesting({ rules: { 'csstools/use-nesting': 'never' } }),
73
+ plugins.noUnresolvedModule({
74
+ rules: { 'plugin/no-unresolved-module': { alias: { '~': 'src' } } },
75
+ }),
76
+ ]);
77
+ ```
78
+
79
+ ### Общие настройки Stylelint
80
+
81
+ Второй аргумент `defineConfig` — общие опции: собственные правила, файлы для
82
+ игнора и т.д. Он перебивает настройки всех проверок:
83
+
84
+ ```js
85
+ // stylelint.config.js
86
+ import { defineConfig, plugins } from '@alexlit/config-stylelint';
87
+
88
+ export default defineConfig([plugins.scss(), plugins.vue()], {
89
+ ignoreFiles: ['fixtures/**'],
90
+ rules: { 'max-nesting-depth': 3 },
91
+ });
92
+ ```
93
+
94
+ ## Проверки
95
+
96
+ | Проверка | Что делает | Плагин |
97
+ | ----------------------------------------------- | ---------------------------------------------------- | --------------------------------------------------- |
98
+ | `plugins.a11y()` | Проверяет типичные ошибки доступности | `@double-great/stylelint-a11y` |
99
+ | `plugins.bem()` | Настраивает линтинг по методологии БЭМ | `@morev/stylelint-plugin` |
100
+ | `plugins.colorFormat()` | Нормализует формат цветов (hex → rgb/hsl) | встроенное правило `color-format/format` |
101
+ | `plugins.declarationBlockNoIgnoredProperties()` | Запрещает бесполезные свойства в блоке объявлений | `stylelint-declaration-block-no-ignored-properties` |
102
+ | `plugins.gamut()` | Проверяет цвета на выход за пределы цветового охвата | `stylelint-gamut` |
103
+ | `plugins.highPerformanceAnimation()` | Запрещает анимации, нагружающие рендеринг | `stylelint-high-performance-animation` |
104
+ | `plugins.logicalCss()` | Проверяет использование логических CSS-свойств | `stylelint-plugin-logical-css` |
105
+ | `plugins.mediaUseCustomMedia()` | Требует использования кастомных медиа-запросов | `stylelint-media-use-custom-media` |
106
+ | `plugins.noIndistinguishableColors()` | Запрещает неразличимые цвета | `stylelint-no-indistinguishable-colors` |
107
+ | `plugins.noNestedMedia()` | Запрещает вложенные медиа-запросы | `stylelint-no-nested-media` |
108
+ | `plugins.noUnresolvedModule()` | Проверяет разрешение импортов | `stylelint-no-unresolved-module` |
109
+ | `plugins.noUnsupportedBrowserFeatures()` | Проверяет поддержку CSS-функций целевыми браузерами | `stylelint-no-unsupported-browser-features` |
110
+ | `plugins.order()` | Настраивает порядок свойств и селекторов | `stylelint-order` |
111
+ | `plugins.prettier()` | Интегрирует Prettier | `stylelint-prettier` |
112
+ | `plugins.scss()` | Настраивает линтинг SCSS | `stylelint-scss` |
113
+ | `plugins.selectorNoEmpty()` | Запрещает пустые селекторы | `stylelint-selector-no-empty` |
114
+ | `plugins.useNesting()` | Требует использования CSS-вложенности | `stylelint-use-nesting` |
115
+ | `plugins.vue()` | Подключает поддержку Vue.js SFC | `stylelint-config-recommended-vue` |
116
+
117
+ ## Миграция с v61
118
+
119
+ v62 — breaking-релиз: проверок по умолчанию больше нет, всё подключается явно.
120
+
121
+ | v61 | v62 |
122
+ | ------------------------------- | ---------------------------------------------- |
123
+ | `createConfig()` | перечислите нужные проверки явно |
124
+ | `createConfig({ gamut: true })` | `defineConfig([plugins.gamut()])` |
125
+ | `createConfig({ scss: false })` | просто не добавляйте `plugins.scss()` в список |
126
+ | `createConfig({}, options)` | `defineConfig([...], options)` |
127
+
128
+ Проверки, включённые по умолчанию в v61: `color-format`,
129
+ `declaration-block-no-ignored-properties`, `high-performance-animation`,
130
+ `no-nested-media`, `order`, `scss`, `selector-no-empty`, `use-nesting`, `vue`, а
131
+ также `prettier`.
49
132
 
50
- ## Development
133
+ ## Разработка
51
134
 
52
- - Check rules
135
+ - Проверка актуальности правил:
53
136
 
54
137
  ```sh
55
138
  npx stylelint-find-new-rules
56
139
  ```
57
140
 
58
- ## Useful links
141
+ ## Полезные ссылки
59
142
 
60
- - [Awesome StyleLint](https://github.com/stylelint/awesome-stylelint)
143
+ - [awesome-stylelint](https://github.com/stylelint/awesome-stylelint)
61
144
  - [stylelint-scales](https://github.com/jeddy3/stylelint-scales)
62
145
  - [stylelint-value-no-unknown-custom-properties](https://github.com/csstools/stylelint-value-no-unknown-custom-properties)
package/index.d.ts ADDED
@@ -0,0 +1,52 @@
1
+ import type { Config } from 'stylelint';
2
+
3
+ /**
4
+ * Опции фабрики плагина — частичный конфиг Stylelint, накладываемый поверх
5
+ * значений по умолчанию.
6
+ */
7
+ type PluginOptions = Partial<Config>;
8
+
9
+ /**
10
+ * Пространство имён фабрик конфигов плагинов. Дефолтных плагинов нет —
11
+ * подключайте нужные явно.
12
+ */
13
+ interface Plugins {
14
+ a11y: (options?: PluginOptions) => Config;
15
+ bem: (options?: PluginOptions) => Config;
16
+ colorFormat: (options?: PluginOptions) => Config;
17
+ declarationBlockNoIgnoredProperties: (options?: PluginOptions) => Config;
18
+ gamut: (options?: PluginOptions) => Config;
19
+ highPerformanceAnimation: (options?: PluginOptions) => Config;
20
+ logicalCss: (options?: PluginOptions) => Config;
21
+ mediaUseCustomMedia: (options?: PluginOptions) => Config;
22
+ noIndistinguishableColors: (options?: PluginOptions) => Config;
23
+ noNestedMedia: (options?: PluginOptions) => Config;
24
+ noUnresolvedModule: (options?: PluginOptions) => Config;
25
+ noUnsupportedBrowserFeatures: (options?: PluginOptions) => Config;
26
+ order: (options?: PluginOptions) => Config;
27
+ prettier: (options?: PluginOptions) => Config;
28
+ scss: (options?: PluginOptions) => Config;
29
+ selectorNoEmpty: (options?: PluginOptions) => Config;
30
+ useNesting: (options?: PluginOptions) => Config;
31
+ vue: (options?: PluginOptions) => Config;
32
+ }
33
+
34
+ /** Пространство имён фабрик конфигов плагинов. */
35
+ declare const plugins: Plugins;
36
+
37
+ /**
38
+ * Создать конфиг Stylelint.
39
+ *
40
+ * Приоритет (от низкого к высокому): база → конфиги плагинов по порядку →
41
+ * `options`. `extends`, `ignoreFiles`, `overrides` и `plugins` конкатенируются
42
+ * (дубли `plugins` убираются), `rules` — shallow merge.
43
+ *
44
+ * @param pluginConfigs — конфиги плагинов (например, `[plugins.scss()]`)
45
+ * @param options — базовые опции Stylelint, наивысший приоритет
46
+ */
47
+ declare function defineConfig(
48
+ pluginConfigs?: Config[],
49
+ options?: Config,
50
+ ): Config;
51
+
52
+ export { defineConfig, plugins };
package/index.js CHANGED
@@ -1,178 +1,182 @@
1
1
  /* eslint-disable unicorn/no-null */
2
+ import { a11y } from './plugins/a11y.js';
3
+ import { bem } from './plugins/bem.js';
4
+ import { colorFormat } from './plugins/color-format.js';
5
+ import { declarationBlockNoIgnoredProperties } from './plugins/declaration-block-no-ignored-properties.js';
6
+ import { gamut } from './plugins/gamut.js';
7
+ import { highPerformanceAnimation } from './plugins/high-performance-animation.js';
8
+ import { logicalCss } from './plugins/logical-css.js';
9
+ import { mediaUseCustomMedia } from './plugins/media-use-custom-media.js';
10
+ import { noIndistinguishableColors } from './plugins/no-indistinguishable-colors.js';
11
+ import { noNestedMedia } from './plugins/no-nested-media.js';
12
+ import { noUnresolvedModule } from './plugins/no-unresolved-module.js';
13
+ import { noUnsupportedBrowserFeatures } from './plugins/no-unsupported-browser-features.js';
14
+ import { order } from './plugins/order.js';
15
+ import { prettier } from './plugins/prettier.js';
16
+ import { scss } from './plugins/scss.js';
17
+ import { selectorNoEmpty } from './plugins/selector-no-empty.js';
18
+ import { useNesting } from './plugins/use-nesting.js';
19
+ import { vue } from './plugins/vue.js';
2
20
 
3
- const DEFAULT_PLUGINS = {
4
- 'color-format': true,
5
- 'declaration-block-no-ignored-properties': true,
6
- 'high-performance-animation': true,
7
- 'no-nested-media': true,
8
- 'order': true,
9
- 'scss': true,
10
- 'selector-no-empty': true,
11
- 'use-nesting': true,
12
- 'vue': true,
21
+ /** Плагины. Дефолтных плагинов нет — подключайте нужные явно в `defineConfig`. */
22
+ const plugins = {
23
+ a11y,
24
+ bem,
25
+ colorFormat,
26
+ declarationBlockNoIgnoredProperties,
27
+ gamut,
28
+ highPerformanceAnimation,
29
+ logicalCss,
30
+ mediaUseCustomMedia,
31
+ noIndistinguishableColors,
32
+ noNestedMedia,
33
+ noUnresolvedModule,
34
+ noUnsupportedBrowserFeatures,
35
+ order,
36
+ prettier,
37
+ scss,
38
+ selectorNoEmpty,
39
+ useNesting,
40
+ vue,
13
41
  };
14
42
 
15
- const OPTIONAL_PLUGINS = {
16
- 'a11y': false,
17
- 'bem': false,
18
- 'gamut': false,
19
- 'logical-css': false,
20
- 'media-use-custom-media': false,
21
- 'no-indistinguishable-colors': false,
22
- 'no-unresolved-module': false,
23
- 'no-unsupported-browser-features': false,
24
- };
25
-
26
- const CODESTYLE_PLUGINS = { prettier: true };
27
-
28
- const PLUGINS = {
29
- ...DEFAULT_PLUGINS,
30
- ...OPTIONAL_PLUGINS,
31
- ...CODESTYLE_PLUGINS,
43
+ /** Базовые правила, применяются всегда (ниже опций плагинов и `options`). */
44
+ const BASE_RULES = {
45
+ 'alpha-value-notation': 'number',
46
+ 'annotation-no-unknown': [true, { ignoreAnnotations: ['default'] }],
47
+ 'at-rule-disallowed-list': ['debug'],
48
+ 'at-rule-empty-line-before': [
49
+ 'always',
50
+ {
51
+ except: ['blockless-after-same-name-blockless', 'first-nested'],
52
+ ignoreAtRules: ['else'],
53
+ },
54
+ ],
55
+ 'at-rule-no-deprecated': [true, { ignoreAtRules: ['apply', 'tailwind'] }],
56
+ 'at-rule-no-unknown': null,
57
+ 'at-rule-no-vendor-prefix': true,
58
+ 'block-no-empty': null,
59
+ 'color-function-notation': 'modern',
60
+ 'color-hex-length': 'short',
61
+ 'color-no-hex': true,
62
+ 'color-no-invalid-hex': true,
63
+ 'custom-property-empty-line-before': [
64
+ 'always',
65
+ { except: ['after-comment', 'after-custom-property', 'first-nested'] },
66
+ ],
67
+ 'custom-property-pattern': '^_?[a-z]+([a-z0-9-]+[a-z0-9]+)?$',
68
+ 'declaration-block-no-redundant-longhand-properties': null,
69
+ 'declaration-property-value-no-unknown': [
70
+ true,
71
+ {
72
+ ignoreProperties: {
73
+ '/.+/': /(v-(bind|deep|global|slotted)|calc-size|rgb|theme|view)|\$/,
74
+ },
75
+ },
76
+ ],
77
+ 'font-family-name-quotes': 'always-unless-keyword',
78
+ 'function-no-unknown': null, // delegate to scss/function-no-unknown
79
+ 'function-url-quotes': 'always',
80
+ 'function-url-scheme-disallowed-list': ['/^data/', 'ftp', '/^http/'],
81
+ 'hue-degree-notation': 'angle',
82
+ 'keyframes-name-pattern': '^[a-z]+(-[a-z]+)*$',
83
+ 'max-nesting-depth': [
84
+ 6,
85
+ { ignoreAtRules: ['each', 'media', 'supports', 'include'] },
86
+ ],
87
+ 'media-feature-name-no-unknown': [
88
+ true,
89
+ { ignoreMediaFeatureNames: ['screen'] },
90
+ ],
91
+ 'media-feature-name-no-vendor-prefix': true,
92
+ 'no-descending-specificity': null,
93
+ 'no-empty-source': null,
94
+ 'no-unknown-animations': true,
95
+ 'number-max-precision': 3,
96
+ 'property-no-unknown': [
97
+ true,
98
+ {
99
+ ignoreProperties: [
100
+ 'align-tracks',
101
+ 'animation-timeline',
102
+ 'interpolate-size',
103
+ 'text-stroke',
104
+ ],
105
+ },
106
+ ],
107
+ 'property-no-vendor-prefix': true,
108
+ 'rule-empty-line-before': [
109
+ 'always',
110
+ { except: ['after-single-line-comment', 'first-nested'], ignore: [] },
111
+ ],
112
+ 'selector-class-pattern': [
113
+ '^[a-z]([a-z0-9-]+)?(__([a-z0-9]+-?)+)?(--([a-z0-9]+-?)+){0,2}$',
114
+ {
115
+ message:
116
+ 'Selector should be written as BEM "block__element--modifier--value" (selector-class-pattern)',
117
+ },
118
+ ],
119
+ 'selector-combinator-disallowed-list': ['>>>', '/deep/'],
120
+ 'selector-max-compound-selectors': 6,
121
+ 'selector-max-id': 0,
122
+ 'selector-no-qualifying-type': null,
123
+ 'selector-no-vendor-prefix': true,
124
+ 'selector-pseudo-element-disallowed-list': ['shadow'],
125
+ 'selector-pseudo-element-no-unknown': [
126
+ true,
127
+ { ignorePseudoElements: ['v-deep', 'file-selector-button'] },
128
+ ],
129
+ 'selector-type-no-unknown': [true, { ignoreTypes: ['ymaps'] }],
130
+ 'shorthand-property-no-redundant-values': true,
131
+ 'string-no-newline': null,
132
+ 'time-min-milliseconds': 16,
133
+ 'value-keyword-case': [
134
+ 'lower',
135
+ { camelCaseSvgKeywords: true, ignoreFunctions: ['v-bind'] },
136
+ ],
137
+ 'value-no-vendor-prefix': true,
32
138
  };
33
139
 
34
140
  /**
35
- * Create "extends" field
141
+ * Создать конфиг Stylelint.
36
142
  *
37
- * @param {PLUGINS} plugins Enabled/disabled plugins list
38
- */
39
- const createPluginsList = (plugins = {}) => {
40
- const pluginsList = [];
41
-
42
- Object.entries({ ...PLUGINS, ...plugins })?.forEach(([name, isActive]) => {
43
- if (isActive) {
44
- pluginsList.push(`@alexlit/config-stylelint/plugins/${name}`);
45
- }
46
- });
47
-
48
- return pluginsList;
49
- };
50
-
51
- /**
52
- * Create stylelint config
143
+ * Приоритет (от низкого к высокому): база → конфиги плагинов по порядку →
144
+ * `options`. `extends`, `ignoreFiles`, `overrides` и `plugins` конкатенируются
145
+ * (дубли `plugins` убираются), `rules` — shallow merge.
146
+ *
147
+ * @param {import('stylelint').Config[]} [pluginConfigs] — конфиги плагинов
148
+ * (например, `[plugins.scss(), plugins.vue()]`)
149
+ * @param {import('stylelint').Config} [options] — базовые опции Stylelint,
150
+ * наивысший приоритет
53
151
  *
54
- * @param {PLUGINS} plugins Enabled/disabled plugins list
55
- * @param {import('stylelint').Config} options Stylelint options
152
+ * @returns {import('stylelint').Config}
56
153
  */
57
- const createConfig = (plugins = {}, options = {}) => ({
58
- ...options,
59
-
60
- extends: [
61
- 'stylelint-config-standard',
62
-
63
- ...createPluginsList(plugins),
64
-
65
- ...(options.extends ?? []),
66
- ],
67
- ignoreFiles: [
68
- '.*',
69
- '.*/**',
70
- 'build/**',
71
- 'dist/**',
72
- 'docs/**',
73
- 'node_modules/**',
74
- 'storybook-*/**',
75
-
76
- ...(options.ignoreFiles ?? []),
77
- ],
78
- plugins: options.plugins ?? [],
79
- rules: {
80
- 'alpha-value-notation': 'number',
81
- 'annotation-no-unknown': [true, { ignoreAnnotations: ['default'] }],
82
- 'at-rule-disallowed-list': ['debug'],
83
- 'at-rule-empty-line-before': [
84
- 'always',
85
- {
86
- except: ['blockless-after-same-name-blockless', 'first-nested'],
87
- ignoreAtRules: ['else'],
88
- },
89
- ],
90
- 'at-rule-no-deprecated': [true, { ignoreAtRules: ['apply', 'tailwind'] }],
91
- 'at-rule-no-unknown': null,
92
- 'at-rule-no-vendor-prefix': true,
93
- 'block-no-empty': null,
94
- 'color-function-notation': 'modern',
95
- 'color-hex-length': 'short',
96
- 'color-no-hex': true,
97
- 'color-no-invalid-hex': true,
98
- 'custom-property-empty-line-before': [
99
- 'always',
100
- { except: ['after-comment', 'after-custom-property', 'first-nested'] },
101
- ],
102
- 'custom-property-pattern': '^_?[a-z]+([a-z0-9-]+[a-z0-9]+)?$',
103
- 'declaration-block-no-redundant-longhand-properties': null,
104
- 'declaration-property-value-no-unknown': [
105
- true,
106
- {
107
- ignoreProperties: {
108
- '/.+/': /(v-(bind|deep|global|slotted)|calc-size|rgb|theme|view)|\$/,
109
- },
110
- },
111
- ],
112
- 'font-family-name-quotes': 'always-unless-keyword',
113
- 'function-no-unknown': null, // delegate to scss/function-no-unknown
114
- 'function-url-quotes': 'always',
115
- 'function-url-scheme-disallowed-list': ['/^data/', 'ftp', '/^http/'],
116
- 'hue-degree-notation': 'angle',
117
- 'keyframes-name-pattern': '^[a-z]+(-[a-z]+)*$',
118
- 'max-nesting-depth': [
119
- 6,
120
- { ignoreAtRules: ['each', 'media', 'supports', 'include'] },
154
+ const defineConfig = (pluginConfigs = [], options = {}) => {
155
+ const baseConfig = {
156
+ extends: ['stylelint-config-standard'],
157
+ ignoreFiles: [
158
+ '.*',
159
+ '.*/**',
160
+ 'build/**',
161
+ 'dist/**',
162
+ 'docs/**',
163
+ 'node_modules/**',
164
+ 'storybook-*/**',
121
165
  ],
122
- 'media-feature-name-no-unknown': [
123
- true,
124
- { ignoreMediaFeatureNames: ['screen'] },
125
- ],
126
- 'media-feature-name-no-vendor-prefix': true,
127
- 'no-descending-specificity': null,
128
- 'no-empty-source': null,
129
- 'no-unknown-animations': true,
130
- 'number-max-precision': 3,
131
- 'property-no-unknown': [
132
- true,
133
- {
134
- ignoreProperties: [
135
- 'align-tracks',
136
- 'animation-timeline',
137
- 'interpolate-size',
138
- 'text-stroke',
139
- ],
140
- },
141
- ],
142
- 'property-no-vendor-prefix': true,
143
- 'rule-empty-line-before': [
144
- 'always',
145
- { except: ['after-single-line-comment', 'first-nested'], ignore: [] },
146
- ],
147
- 'selector-class-pattern': [
148
- '^[a-z]([a-z0-9-]+)?(__([a-z0-9]+-?)+)?(--([a-z0-9]+-?)+){0,2}$',
149
- {
150
- message:
151
- 'Selector should be written as BEM "block__element--modifier--value" (selector-class-pattern)',
152
- },
153
- ],
154
- 'selector-combinator-disallowed-list': ['>>>', '/deep/'],
155
- 'selector-max-compound-selectors': 6,
156
- 'selector-max-id': 0,
157
- 'selector-no-qualifying-type': null,
158
- 'selector-no-vendor-prefix': true,
159
- 'selector-pseudo-element-disallowed-list': ['shadow'],
160
- 'selector-pseudo-element-no-unknown': [
161
- true,
162
- { ignorePseudoElements: ['v-deep', 'file-selector-button'] },
163
- ],
164
- 'selector-type-no-unknown': [true, { ignoreTypes: ['ymaps'] }],
165
- 'shorthand-property-no-redundant-values': true,
166
- 'string-no-newline': null,
167
- 'time-min-milliseconds': 16,
168
- 'value-keyword-case': [
169
- 'lower',
170
- { camelCaseSvgKeywords: true, ignoreFunctions: ['v-bind'] },
171
- ],
172
- 'value-no-vendor-prefix': true,
166
+ plugins: [],
167
+ rules: BASE_RULES,
168
+ };
173
169
 
174
- ...options.rules,
175
- },
176
- });
170
+ const sources = [baseConfig, ...pluginConfigs, options];
171
+
172
+ return {
173
+ ...Object.assign({}, ...sources),
174
+ extends: sources.flatMap((source) => source.extends ?? []),
175
+ ignoreFiles: sources.flatMap((source) => source.ignoreFiles ?? []),
176
+ overrides: sources.flatMap((source) => source.overrides ?? []),
177
+ plugins: [...new Set(sources.flatMap((source) => source.plugins ?? []))],
178
+ rules: Object.assign({}, ...sources.map((source) => source.rules ?? {})),
179
+ };
180
+ };
177
181
 
178
- export { createConfig };
182
+ export { defineConfig, plugins };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexlit/config-stylelint",
3
- "version": "61.5.1",
3
+ "version": "63.0.0",
4
4
  "private": false,
5
5
  "description": "Stylelint config",
6
6
  "keywords": [
@@ -23,9 +23,11 @@
23
23
  ],
24
24
  "type": "module",
25
25
  "main": "index.js",
26
+ "types": "index.d.ts",
26
27
  "files": [
27
28
  "README.md",
28
29
  "index.js",
30
+ "index.d.ts",
29
31
  "plugins"
30
32
  ],
31
33
  "scripts": {
@@ -38,7 +40,7 @@
38
40
  "dependencies": {
39
41
  "@double-great/stylelint-a11y": "^3.8.1",
40
42
  "@morev/stylelint-plugin": "^0.7.0",
41
- "postcss": "^8.5.30",
43
+ "postcss": "^8.5.31",
42
44
  "postcss-html": "^2.0.0",
43
45
  "prettier": "^3.9.10",
44
46
  "stylelint": "17.16.0",
package/plugins/a11y.js CHANGED
@@ -1,18 +1,31 @@
1
1
  /* eslint-disable unicorn/no-null */
2
2
 
3
3
  /**
4
- * @type {import('stylelint').Config}
4
+ * Проверяет типичные ошибки доступности.
5
+ *
6
+ * @param {Partial<import('stylelint').Config>} [options] — опции, накладываемые
7
+ * поверх значений по умолчанию (shallow merge)
8
+ *
9
+ * @returns {import('stylelint').Config}
5
10
  *
6
11
  * @see [stylelint-a11y](https://github.com/double-great/stylelint-a11y)
7
12
  */
8
- export default {
9
- plugins: ['@double-great/stylelint-a11y'],
10
- rules: {
11
- 'a11y/media-prefers-reduced-motion': null,
12
- 'a11y/no-obsolete-attribute': true,
13
- 'a11y/no-obsolete-element': true,
14
- 'a11y/no-outline-none': true,
15
- 'a11y/no-text-align-justify': true,
16
- 'a11y/selector-pseudo-class-focus': true,
17
- },
13
+ export const a11y = (options = {}) => {
14
+ const baseConfig = {
15
+ plugins: ['@double-great/stylelint-a11y'],
16
+ rules: {
17
+ 'a11y/media-prefers-reduced-motion': null,
18
+ 'a11y/no-obsolete-attribute': true,
19
+ 'a11y/no-obsolete-element': true,
20
+ 'a11y/no-outline-none': true,
21
+ 'a11y/no-text-align-justify': true,
22
+ 'a11y/selector-pseudo-class-focus': true,
23
+ },
24
+ };
25
+
26
+ return {
27
+ ...baseConfig,
28
+ ...options,
29
+ rules: { ...baseConfig.rules, ...options.rules },
30
+ };
18
31
  };
package/plugins/bem.js CHANGED
@@ -6,11 +6,16 @@ const defineRules = createDefineRules({
6
6
  });
7
7
 
8
8
  /**
9
- * @type {import('stylelint').Config}
9
+ * Настраивает линтинг по методологии БЭМ.
10
+ *
11
+ * @param {Partial<import('stylelint').Config>} [options] — опции, накладываемые
12
+ * поверх значений по умолчанию (shallow merge)
13
+ *
14
+ * @returns {import('stylelint').Config}
10
15
  *
11
16
  * @see [@morev/stylelint-plugin](https://morevm.github.io/stylelint-plugin/)
12
17
  */
13
- export default {
18
+ export const bem = (options = {}) => ({
14
19
  overrides: [
15
20
  {
16
21
  files: ['**/*.{css,scss,vue}'],
@@ -40,4 +45,6 @@ export default {
40
45
  },
41
46
  ],
42
47
  plugins: ['@morev/stylelint-plugin'],
43
- };
48
+
49
+ ...options,
50
+ });
@@ -168,8 +168,18 @@ const rule = function (actual, options, context) {
168
168
  rule.ruleName = ruleName;
169
169
  rule.messages = messages;
170
170
 
171
- /** @type {import('stylelint').Config} */
172
- export default {
171
+ /**
172
+ * Нормализует формат цветов (hex → rgb/hsl).
173
+ *
174
+ * @param {Partial<import('stylelint').Config>} [options] — опции, накладываемые
175
+ * поверх значений по умолчанию (shallow merge)
176
+ *
177
+ * @returns {import('stylelint').Config}
178
+ */
179
+ export const colorFormat = (options = {}) => ({
173
180
  plugins: [createPlugin(ruleName, rule)],
174
- rules: { 'color-format/format': { format: 'rgb' } },
175
- };
181
+
182
+ ...options,
183
+
184
+ rules: { 'color-format/format': { format: 'rgb' }, ...options.rules },
185
+ });
@@ -1,9 +1,20 @@
1
1
  /**
2
- * @type {import('stylelint').Config}
2
+ * Запрещает бесполезные свойства в блоке объявлений.
3
+ *
4
+ * @param {Partial<import('stylelint').Config>} [options] — опции, накладываемые
5
+ * поверх значений по умолчанию (shallow merge)
6
+ *
7
+ * @returns {import('stylelint').Config}
3
8
  *
4
9
  * @see [stylelint-declaration-block-no-ignored-properties](https://github.com/kristerkari/stylelint-declaration-block-no-ignored-properties)
5
10
  */
6
- export default {
11
+ export const declarationBlockNoIgnoredProperties = (options = {}) => ({
7
12
  plugins: ['stylelint-declaration-block-no-ignored-properties'],
8
- rules: { 'plugin/declaration-block-no-ignored-properties': true },
9
- };
13
+
14
+ ...options,
15
+
16
+ rules: {
17
+ 'plugin/declaration-block-no-ignored-properties': true,
18
+ ...options.rules,
19
+ },
20
+ });
package/plugins/gamut.js CHANGED
@@ -1,9 +1,17 @@
1
1
  /**
2
- * @type {import('stylelint').Config}
2
+ * Проверяет цвета на выход за пределы цветового охвата (gamut).
3
+ *
4
+ * @param {Partial<import('stylelint').Config>} [options] — опции, накладываемые
5
+ * поверх значений по умолчанию (shallow merge)
6
+ *
7
+ * @returns {import('stylelint').Config}
3
8
  *
4
9
  * @see [stylelint-gamut](https://github.com/fpetrakov/stylelint-gamut)
5
10
  */
6
- export default {
11
+ export const gamut = (options = {}) => ({
7
12
  plugins: ['stylelint-gamut'],
8
- rules: { 'gamut/color-no-out-gamut-range': true },
9
- };
13
+
14
+ ...options,
15
+
16
+ rules: { 'gamut/color-no-out-gamut-range': true, ...options.rules },
17
+ });
@@ -1,14 +1,23 @@
1
1
  /**
2
- * @type {import('stylelint').Config}
2
+ * Запрещает анимации, нагружающие рендеринг.
3
+ *
4
+ * @param {Partial<import('stylelint').Config>} [options] — опции, накладываемые
5
+ * поверх значений по умолчанию (shallow merge)
6
+ *
7
+ * @returns {import('stylelint').Config}
3
8
  *
4
9
  * @see [stylelint-high-performance-animation](https://github.com/kristerkari/stylelint-high-performance-animation)
5
10
  */
6
- export default {
11
+ export const highPerformanceAnimation = (options = {}) => ({
7
12
  plugins: ['stylelint-high-performance-animation'],
13
+
14
+ ...options,
15
+
8
16
  rules: {
9
17
  'plugin/no-low-performance-animation-properties': [
10
18
  true,
11
19
  { ignore: 'paint-properties', ignoreProperties: [] },
12
20
  ],
21
+ ...options.rules,
13
22
  },
14
- };
23
+ });
@@ -1,9 +1,16 @@
1
1
  /**
2
- * @type {import('stylelint').Config}
2
+ * Проверяет использование логических CSS-свойств.
3
+ *
4
+ * @param {Partial<import('stylelint').Config>} [options] — опции, накладываемые
5
+ * поверх значений по умолчанию (shallow merge)
6
+ *
7
+ * @returns {import('stylelint').Config}
3
8
  *
4
9
  * @see [stylelint-plugin-logical-css](https://github.com/yuschick/stylelint-plugin-logical-css)
5
10
  */
6
- export default {
11
+ export const logicalCss = (options = {}) => ({
7
12
  extends: ['stylelint-plugin-logical-css/configs/recommended'],
8
13
  plugins: ['stylelint-plugin-logical-css'],
9
- };
14
+
15
+ ...options,
16
+ });
@@ -1,9 +1,17 @@
1
1
  /**
2
- * @type {import('stylelint').Config}
2
+ * Требует использования кастомных медиа-запросов.
3
+ *
4
+ * @param {Partial<import('stylelint').Config>} [options] — опции, накладываемые
5
+ * поверх значений по умолчанию (shallow merge)
6
+ *
7
+ * @returns {import('stylelint').Config}
3
8
  *
4
9
  * @see [stylelint-media-use-custom-media](https://github.com/csstools/stylelint-media-use-custom-media)
5
10
  */
6
- export default {
11
+ export const mediaUseCustomMedia = (options = {}) => ({
7
12
  plugins: ['stylelint-media-use-custom-media'],
8
- rules: { 'csstools/media-use-custom-media': 'always' },
9
- };
13
+
14
+ ...options,
15
+
16
+ rules: { 'csstools/media-use-custom-media': 'always', ...options.rules },
17
+ });
@@ -1,9 +1,20 @@
1
1
  /**
2
- * @type {import('stylelint').Config}
2
+ * Запрещает неразличимые цвета.
3
+ *
4
+ * @param {Partial<import('stylelint').Config>} [options] — опции, накладываемые
5
+ * поверх значений по умолчанию (shallow merge)
6
+ *
7
+ * @returns {import('stylelint').Config}
3
8
  *
4
9
  * @see [stylelint-no-indistinguishable-colors](https://github.com/ierhyna/stylelint-no-indistinguishable-colors)
5
10
  */
6
- export default {
11
+ export const noIndistinguishableColors = (options = {}) => ({
7
12
  plugins: ['stylelint-no-indistinguishable-colors'],
8
- rules: { 'plugin/stylelint-no-indistinguishable-colors': true },
9
- };
13
+
14
+ ...options,
15
+
16
+ rules: {
17
+ 'plugin/stylelint-no-indistinguishable-colors': true,
18
+ ...options.rules,
19
+ },
20
+ });
@@ -1,9 +1,17 @@
1
1
  /**
2
- * @type {import('stylelint').Config}
2
+ * Запрещает вложенные медиа-запросы.
3
+ *
4
+ * @param {Partial<import('stylelint').Config>} [options] — опции, накладываемые
5
+ * поверх значений по умолчанию (shallow merge)
6
+ *
7
+ * @returns {import('stylelint').Config}
3
8
  *
4
9
  * @see [stylelint-no-nested-media](https://github.com/dkrnl/stylelint-no-nested-media)
5
10
  */
6
- export default {
11
+ export const noNestedMedia = (options = {}) => ({
7
12
  plugins: ['stylelint-no-nested-media'],
8
- rules: { 'pitcher/no-nested-media': true },
9
- };
13
+
14
+ ...options,
15
+
16
+ rules: { 'pitcher/no-nested-media': true, ...options.rules },
17
+ });
@@ -1,10 +1,18 @@
1
1
  /**
2
- * @type {import('stylelint').Config}
2
+ * Проверяет разрешение импортов.
3
+ *
4
+ * @param {Partial<import('stylelint').Config>} [options] — опции, накладываемые
5
+ * поверх значений по умолчанию (shallow merge)
6
+ *
7
+ * @returns {import('stylelint').Config}
3
8
  *
4
9
  * @see [stylelint-no-unresolved-module](https://github.com/niksy/stylelint-no-unresolved-module)
5
10
  */
6
- export default {
11
+ export const noUnresolvedModule = (options = {}) => ({
7
12
  plugins: ['stylelint-no-unresolved-module'],
13
+
14
+ ...options,
15
+
8
16
  rules: {
9
17
  'plugin/no-unresolved-module': {
10
18
  alias: { '~assets': 'assets', '~public': 'public', '~static': 'static' },
@@ -19,5 +27,6 @@ export default {
19
27
  'static',
20
28
  ],
21
29
  },
30
+ ...options.rules,
22
31
  },
23
- };
32
+ });
@@ -1,10 +1,18 @@
1
1
  /**
2
- * @type {import('stylelint').Config}
2
+ * Проверяет поддержку CSS-функций целевыми браузерами.
3
+ *
4
+ * @param {Partial<import('stylelint').Config>} [options] — опции, накладываемые
5
+ * поверх значений по умолчанию (shallow merge)
6
+ *
7
+ * @returns {import('stylelint').Config}
3
8
  *
4
9
  * @see [stylelint-no-unsupported-browser-features](https://github.com/ismay/stylelint-no-unsupported-browser-features)
5
10
  */
6
- export default {
11
+ export const noUnsupportedBrowserFeatures = (options = {}) => ({
7
12
  plugins: ['stylelint-no-unsupported-browser-features'],
13
+
14
+ ...options,
15
+
8
16
  rules: {
9
17
  'plugin/no-unsupported-browser-features': [
10
18
  true,
@@ -14,5 +22,6 @@ export default {
14
22
  severity: 'warning',
15
23
  },
16
24
  ],
25
+ ...options.rules,
17
26
  },
18
- };
27
+ });
package/plugins/order.js CHANGED
@@ -116,12 +116,20 @@ const buildPseudoElementRules = () => [
116
116
  ];
117
117
 
118
118
  /**
119
- * @type {import('stylelint').Config}
119
+ * Настраивает порядок свойств и селекторов.
120
+ *
121
+ * @param {Partial<import('stylelint').Config>} [options] — опции, накладываемые
122
+ * поверх значений по умолчанию (shallow merge)
123
+ *
124
+ * @returns {import('stylelint').Config}
120
125
  *
121
126
  * @see [stylelint-order](https://github.com/hudochenkov/stylelint-order)
122
127
  */
123
- export default {
128
+ export const order = (options = {}) => ({
124
129
  plugins: ['stylelint-order'],
130
+
131
+ ...options,
132
+
125
133
  rules: {
126
134
  'order/custom-properties-alphabetical-order': true,
127
135
  'order/order': [
@@ -190,5 +198,7 @@ export default {
190
198
  ...buildLetterRules('__'),
191
199
  ],
192
200
  'order/properties-alphabetical-order': true,
201
+
202
+ ...options.rules,
193
203
  },
194
- };
204
+ });
@@ -1,9 +1,17 @@
1
1
  /**
2
- * @type {import('stylelint').Config}
2
+ * Интегрирует Prettier.
3
+ *
4
+ * @param {Partial<import('stylelint').Config>} [options] — опции, накладываемые
5
+ * поверх значений по умолчанию (shallow merge)
6
+ *
7
+ * @returns {import('stylelint').Config}
3
8
  *
4
9
  * @see [stylelint-prettier](https://github.com/prettier/stylelint-prettier)
5
10
  */
6
- export default {
11
+ export const prettier = (options = {}) => ({
7
12
  plugins: ['stylelint-prettier'],
8
- rules: { 'prettier/prettier': true },
9
- };
13
+
14
+ ...options,
15
+
16
+ rules: { 'prettier/prettier': true, ...options.rules },
17
+ });
package/plugins/scss.js CHANGED
@@ -3,13 +3,21 @@
3
3
  const KEBAB_CASE_PATTERN = '^[a-z]+([a-z0-9-]+[a-z0-9]+)?$';
4
4
 
5
5
  /**
6
- * @type {import('stylelint').Config}
6
+ * Настраивает линтинг SCSS.
7
+ *
8
+ * @param {Partial<import('stylelint').Config>} [options] — опции, накладываемые
9
+ * поверх значений по умолчанию (shallow merge)
10
+ *
11
+ * @returns {import('stylelint').Config}
7
12
  *
8
13
  * @see [stylelint-scss](https://github.com/kristerkari/stylelint-scss)
9
14
  */
10
- export default {
15
+ export const scss = (options = {}) => ({
11
16
  extends: ['stylelint-config-standard-scss'],
12
17
  plugins: ['stylelint-scss'],
18
+
19
+ ...options,
20
+
13
21
  rules: {
14
22
  'scss/at-each-key-value-single-line': true,
15
23
  'scss/at-else-if-parentheses-space-before': 'always',
@@ -92,5 +100,7 @@ export default {
92
100
  true,
93
101
  { ignoreKeywords: [] },
94
102
  ],
103
+
104
+ ...options.rules,
95
105
  },
96
- };
106
+ });
@@ -1,9 +1,17 @@
1
1
  /**
2
- * @type {import('stylelint').Config} *
2
+ * Запрещает пустые селекторы.
3
+ *
4
+ * @param {Partial<import('stylelint').Config>} [options] — опции, накладываемые
5
+ * поверх значений по умолчанию (shallow merge)
6
+ *
7
+ * @returns {import('stylelint').Config}
3
8
  *
4
9
  * @see [stylelint-selector-no-empty](https://github.com/ssivanatarajan/stylelint-selector-no-empty)
5
10
  */
6
- export default {
11
+ export const selectorNoEmpty = (options = {}) => ({
7
12
  plugins: ['stylelint-selector-no-empty'],
8
- rules: { 'plugin/stylelint-selector-no-empty': true },
9
- };
13
+
14
+ ...options,
15
+
16
+ rules: { 'plugin/stylelint-selector-no-empty': true, ...options.rules },
17
+ });
@@ -1,9 +1,20 @@
1
1
  /**
2
- * @type {import('stylelint').Config}
2
+ * Требует использования CSS-вложенности.
3
+ *
4
+ * @param {Partial<import('stylelint').Config>} [options] — опции, накладываемые
5
+ * поверх значений по умолчанию (shallow merge)
6
+ *
7
+ * @returns {import('stylelint').Config}
3
8
  *
4
9
  * @see [stylelint-use-nesting](https://github.com/csstools/stylelint-use-nesting)
5
10
  */
6
- export default {
11
+ export const useNesting = (options = {}) => ({
7
12
  plugins: ['stylelint-use-nesting'],
8
- rules: { 'csstools/use-nesting': ['always', { except: [], syntax: 'scss' }] },
9
- };
13
+
14
+ ...options,
15
+
16
+ rules: {
17
+ 'csstools/use-nesting': ['always', { except: [], syntax: 'scss' }],
18
+ ...options.rules,
19
+ },
20
+ });
package/plugins/vue.js CHANGED
@@ -1,6 +1,15 @@
1
1
  /**
2
- * @type {import('stylelint').Config}
2
+ * Подключает поддержку Vue.js SFC.
3
+ *
4
+ * @param {Partial<import('stylelint').Config>} [options] — опции, накладываемые
5
+ * поверх значений по умолчанию (shallow merge)
6
+ *
7
+ * @returns {import('stylelint').Config}
3
8
  *
4
9
  * @see [stylelint-config-recommended-vue](https://github.com/ota-meshi/stylelint-config-recommended-vue)
5
10
  */
6
- export default { extends: 'stylelint-config-recommended-vue' };
11
+ export const vue = (options = {}) => ({
12
+ extends: 'stylelint-config-recommended-vue',
13
+
14
+ ...options,
15
+ });