@alexlit/config-stylelint 63.0.1 → 64.1.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 +90 -38
- package/index.d.ts +9 -5
- package/index.js +7 -15
- package/package.json +4 -3
- package/plugins/a11y.js +15 -21
- package/plugins/bem.js +14 -13
- package/plugins/color-format.js +11 -9
- package/plugins/declaration-block-no-ignored-properties.js +10 -12
- package/plugins/gamut.js +9 -9
- package/plugins/high-performance-animation.js +15 -15
- package/plugins/logical-css.js +9 -8
- package/plugins/media-use-custom-media.js +10 -9
- package/plugins/no-indistinguishable-colors.js +10 -12
- package/plugins/no-nested-media.js +9 -9
- package/plugins/no-unresolved-module.js +16 -16
- package/plugins/no-unsupported-browser-features.js +16 -16
- package/plugins/order.js +15 -17
- package/plugins/prettier.js +9 -9
- package/plugins/scss.js +14 -17
- package/plugins/selector-no-empty.js +10 -9
- package/plugins/use-nesting.js +9 -12
- package/plugins/vue.js +6 -7
- package/utils/merge-configs.js +20 -0
package/README.md
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
# Stylelint Configuration
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/@alexlit/config-stylelint)
|
|
4
|
+
[](https://npmx.dev/package/@alexlit/config-stylelint)
|
|
5
|
+
[](LICENSE)
|
|
5
6
|
|
|
6
7
|
Готовая конфигурация [Stylelint](https://stylelint.io/) для проверки CSS, SCSS и
|
|
7
|
-
Vue-файлов: настроенные правила из популярных stylelint-плагинов
|
|
8
|
+
Vue-файлов: настроенные правила из популярных stylelint-плагинов - порядок и
|
|
8
9
|
синтаксис свойств, доступность, БЭМ, поддержка SCSS и т.д. Вместо того чтобы
|
|
9
10
|
подключать и настраивать каждый плагин вручную, соберите конфигурацию из готовых
|
|
10
11
|
проверок.
|
|
11
12
|
|
|
12
|
-
Проверки модульные: по умолчанию ничего не включено
|
|
13
|
+
Проверки модульные: по умолчанию ничего не включено - вы сами перечисляете
|
|
13
14
|
нужные в `defineConfig`.
|
|
14
15
|
|
|
15
16
|
## Установка
|
|
16
17
|
|
|
17
|
-
```
|
|
18
|
+
```bash
|
|
18
19
|
npm i @alexlit/config-stylelint -D
|
|
19
20
|
```
|
|
20
21
|
|
|
@@ -27,36 +28,38 @@ import { defineConfig, plugins } from '@alexlit/config-stylelint';
|
|
|
27
28
|
export default defineConfig([
|
|
28
29
|
plugins.scss(),
|
|
29
30
|
plugins.vue(),
|
|
31
|
+
|
|
30
32
|
plugins.prettier(),
|
|
31
33
|
]);
|
|
32
34
|
```
|
|
33
35
|
|
|
34
|
-
Каждый вызов `plugins.*()`
|
|
35
|
-
проекту; полный список
|
|
36
|
+
Каждый вызов `plugins.*()` - отдельная проверка. Добавьте только то, что нужно
|
|
37
|
+
проекту; полный список - в разделе [Проверки](#проверки).
|
|
36
38
|
|
|
37
|
-
Больше проверок
|
|
39
|
+
Больше проверок - просто допишите их в массив:
|
|
38
40
|
|
|
39
41
|
```js
|
|
40
42
|
// stylelint.config.js
|
|
41
43
|
import { defineConfig, plugins } from '@alexlit/config-stylelint';
|
|
42
44
|
|
|
43
45
|
export default defineConfig([
|
|
46
|
+
plugins.a11y(),
|
|
47
|
+
plugins.bem(),
|
|
44
48
|
plugins.colorFormat(),
|
|
45
49
|
plugins.declarationBlockNoIgnoredProperties(),
|
|
50
|
+
plugins.gamut(),
|
|
46
51
|
plugins.highPerformanceAnimation(),
|
|
52
|
+
plugins.logicalCss(),
|
|
53
|
+
plugins.mediaUseCustomMedia(),
|
|
47
54
|
plugins.noNestedMedia(),
|
|
55
|
+
plugins.noUnresolvedModule(),
|
|
56
|
+
plugins.noUnsupportedBrowserFeatures(),
|
|
48
57
|
plugins.order(),
|
|
49
58
|
plugins.scss(),
|
|
50
59
|
plugins.selectorNoEmpty(),
|
|
51
60
|
plugins.useNesting(),
|
|
52
61
|
plugins.vue(),
|
|
53
|
-
|
|
54
|
-
plugins.bem(),
|
|
55
|
-
plugins.gamut(),
|
|
56
|
-
plugins.logicalCss(),
|
|
57
|
-
plugins.mediaUseCustomMedia(),
|
|
58
|
-
plugins.noUnresolvedModule(),
|
|
59
|
-
plugins.noUnsupportedBrowserFeatures(),
|
|
62
|
+
|
|
60
63
|
plugins.prettier(),
|
|
61
64
|
]);
|
|
62
65
|
```
|
|
@@ -79,9 +82,43 @@ export default defineConfig([
|
|
|
79
82
|
]);
|
|
80
83
|
```
|
|
81
84
|
|
|
85
|
+
`rules` мержатся поверхностно: настройка одноимённого правила из опций заменяет
|
|
86
|
+
дефолтную целиком.
|
|
87
|
+
|
|
88
|
+
### Правила для отдельных файлов
|
|
89
|
+
|
|
90
|
+
Чтобы применить правила только к части файлов, используйте `overrides` в опциях
|
|
91
|
+
проверки. Пользовательские overrides добавляются после дефолтных, поэтому
|
|
92
|
+
выигрывают у них:
|
|
93
|
+
|
|
94
|
+
```js
|
|
95
|
+
// stylelint.config.js
|
|
96
|
+
import { defineConfig, plugins } from '@alexlit/config-stylelint';
|
|
97
|
+
|
|
98
|
+
export default defineConfig([
|
|
99
|
+
plugins.useNesting({
|
|
100
|
+
overrides: [
|
|
101
|
+
{ files: ['**/*.vue'], rules: { 'csstools/use-nesting': 'never' } },
|
|
102
|
+
],
|
|
103
|
+
}),
|
|
104
|
+
]);
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
`files` обязателен: Stylelint падает с ошибкой, если в override его нет.
|
|
108
|
+
|
|
109
|
+
### Приоритет настроек
|
|
110
|
+
|
|
111
|
+
Внутри одной проверки: дефолты → `options.rules` → `options.overrides` (для
|
|
112
|
+
подходящих файлов). Между проверками и вторым аргументом `defineConfig`
|
|
113
|
+
действует тот же порядок: база → проверки по порядку → `options`.
|
|
114
|
+
|
|
115
|
+
Коллекции (`extends`, `ignoreFiles`, `overrides`, `plugins`) дополняются,
|
|
116
|
+
`plugins` дедуплицируются. Остальные поля, например `customSyntax`, заменяются
|
|
117
|
+
значениями из опций.
|
|
118
|
+
|
|
82
119
|
### Общие настройки Stylelint
|
|
83
120
|
|
|
84
|
-
Второй аргумент `defineConfig`
|
|
121
|
+
Второй аргумент `defineConfig` - общие опции: собственные правила, файлы для
|
|
85
122
|
игнора и т.д. Он перебивает настройки всех проверок:
|
|
86
123
|
|
|
87
124
|
```js
|
|
@@ -96,30 +133,45 @@ export default defineConfig([plugins.scss(), plugins.vue()], {
|
|
|
96
133
|
|
|
97
134
|
## Проверки
|
|
98
135
|
|
|
99
|
-
| Проверка | Что делает | Плагин
|
|
100
|
-
| ----------------------------------------------- | ---------------------------------------------------- |
|
|
101
|
-
| `plugins.a11y()` | Проверяет типичные ошибки доступности | `@double-great/stylelint-a11y`
|
|
102
|
-
| `plugins.bem()` | Настраивает линтинг по методологии БЭМ | `@morev/stylelint-plugin`
|
|
103
|
-
| `plugins.colorFormat()` | Нормализует формат цветов (hex → rgb/hsl) | встроенное правило `color-format/format`
|
|
104
|
-
| `plugins.declarationBlockNoIgnoredProperties()` | Запрещает бесполезные свойства в блоке объявлений | `stylelint-declaration-block-no-ignored-properties` |
|
|
105
|
-
| `plugins.gamut()` | Проверяет цвета на выход за пределы цветового охвата | `stylelint-gamut`
|
|
106
|
-
| `plugins.highPerformanceAnimation()` | Запрещает анимации, нагружающие рендеринг | `stylelint-high-performance-animation`
|
|
107
|
-
| `plugins.logicalCss()` | Проверяет использование логических CSS-свойств | `stylelint-plugin-logical-css`
|
|
108
|
-
| `plugins.mediaUseCustomMedia()` | Требует использования кастомных медиа-запросов | `stylelint-media-use-custom-media`
|
|
109
|
-
| `plugins.noIndistinguishableColors()` | Запрещает неразличимые цвета | `stylelint-no-indistinguishable-colors`
|
|
110
|
-
| `plugins.noNestedMedia()` | Запрещает вложенные медиа-запросы | `stylelint-no-nested-media`
|
|
111
|
-
| `plugins.noUnresolvedModule()` | Проверяет разрешение импортов | `stylelint-no-unresolved-module`
|
|
112
|
-
| `plugins.noUnsupportedBrowserFeatures()` | Проверяет поддержку CSS-функций целевыми браузерами | `stylelint-no-unsupported-browser-features`
|
|
113
|
-
| `plugins.order()` | Настраивает порядок свойств и селекторов | `stylelint-order`
|
|
114
|
-
| `plugins.prettier()` | Интегрирует Prettier | `stylelint-prettier`
|
|
115
|
-
| `plugins.scss()` | Настраивает линтинг SCSS | `stylelint-scss`
|
|
116
|
-
| `plugins.selectorNoEmpty()` | Запрещает пустые селекторы | `stylelint-selector-no-empty`
|
|
117
|
-
| `plugins.useNesting()` | Требует использования CSS-вложенности | `stylelint-use-nesting`
|
|
118
|
-
| `plugins.vue()` | Подключает поддержку Vue.js SFC | `stylelint-config-recommended-vue`
|
|
136
|
+
| Проверка | Что делает | Плагин |
|
|
137
|
+
| ----------------------------------------------- | ---------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
|
|
138
|
+
| `plugins.a11y()` | Проверяет типичные ошибки доступности | [`@double-great/stylelint-a11y`](https://github.com/double-great/stylelint-a11y) |
|
|
139
|
+
| `plugins.bem()` | Настраивает линтинг по методологии БЭМ | [`@morev/stylelint-plugin`](https://morevm.github.io/stylelint-plugin/) |
|
|
140
|
+
| `plugins.colorFormat()` | Нормализует формат цветов (hex → rgb/hsl) | встроенное правило `color-format/format` |
|
|
141
|
+
| `plugins.declarationBlockNoIgnoredProperties()` | Запрещает бесполезные свойства в блоке объявлений | [`stylelint-declaration-block-no-ignored-properties`](https://github.com/kristerkari/stylelint-declaration-block-no-ignored-properties) |
|
|
142
|
+
| `plugins.gamut()` | Проверяет цвета на выход за пределы цветового охвата | [`stylelint-gamut`](https://github.com/fpetrakov/stylelint-gamut) |
|
|
143
|
+
| `plugins.highPerformanceAnimation()` | Запрещает анимации, нагружающие рендеринг | [`stylelint-high-performance-animation`](https://github.com/kristerkari/stylelint-high-performance-animation) |
|
|
144
|
+
| `plugins.logicalCss()` | Проверяет использование логических CSS-свойств | [`stylelint-plugin-logical-css`](https://github.com/yuschick/stylelint-plugin-logical-css) |
|
|
145
|
+
| `plugins.mediaUseCustomMedia()` | Требует использования кастомных медиа-запросов | [`stylelint-media-use-custom-media`](https://github.com/csstools/stylelint-media-use-custom-media) |
|
|
146
|
+
| `plugins.noIndistinguishableColors()` | Запрещает неразличимые цвета | [`stylelint-no-indistinguishable-colors`](https://github.com/ierhyna/stylelint-no-indistinguishable-colors) |
|
|
147
|
+
| `plugins.noNestedMedia()` | Запрещает вложенные медиа-запросы | [`stylelint-no-nested-media`](https://github.com/dkrnl/stylelint-no-nested-media) |
|
|
148
|
+
| `plugins.noUnresolvedModule()` | Проверяет разрешение импортов | [`stylelint-no-unresolved-module`](https://github.com/niksy/stylelint-no-unresolved-module) |
|
|
149
|
+
| `plugins.noUnsupportedBrowserFeatures()` | Проверяет поддержку CSS-функций целевыми браузерами | [`stylelint-no-unsupported-browser-features`](https://github.com/ismay/stylelint-no-unsupported-browser-features) |
|
|
150
|
+
| `plugins.order()` | Настраивает порядок свойств и селекторов | [`stylelint-order`](https://github.com/hudochenkov/stylelint-order) |
|
|
151
|
+
| `plugins.prettier()` | Интегрирует Prettier | [`stylelint-prettier`](https://github.com/prettier/stylelint-prettier) |
|
|
152
|
+
| `plugins.scss()` | Настраивает линтинг SCSS | [`stylelint-scss`](https://github.com/kristerkari/stylelint-scss) |
|
|
153
|
+
| `plugins.selectorNoEmpty()` | Запрещает пустые селекторы | [`stylelint-selector-no-empty`](https://github.com/ssivanatarajan/stylelint-selector-no-empty) |
|
|
154
|
+
| `plugins.useNesting()` | Требует использования CSS-вложенности | [`stylelint-use-nesting`](https://github.com/csstools/stylelint-use-nesting) |
|
|
155
|
+
| `plugins.vue()` | Подключает поддержку Vue.js SFC | [`stylelint-config-recommended-vue`](https://github.com/ota-meshi/stylelint-config-recommended-vue) |
|
|
156
|
+
|
|
157
|
+
## Миграция с v63
|
|
158
|
+
|
|
159
|
+
v64 - major-релиз: коллекции в опциях проверок теперь дополняют дефолты, а не
|
|
160
|
+
заменяют их.
|
|
161
|
+
|
|
162
|
+
| Было | Стало |
|
|
163
|
+
| --------------------------------------------------------- | ------------------------------------------------------------------- |
|
|
164
|
+
| `plugins.scss({ extends: ['custom'] })` заменял дефолтный | `extends` дополняется, `custom` применяется после дефолтного |
|
|
165
|
+
| `plugins.useNesting({ plugins: ['custom'] })` заменял | `plugins` дополняется, дубли убираются |
|
|
166
|
+
| `plugins.bem({ overrides: [...] })` заменял дефолтные | overrides дополняются, пользовательские применяются после дефолтных |
|
|
167
|
+
|
|
168
|
+
Отключить конкретное дефолтное правило можно через `rules: { 'rule': null }`.
|
|
169
|
+
Общие настройки, которые должны перебивать всё, передавайте вторым аргументом
|
|
170
|
+
`defineConfig`.
|
|
119
171
|
|
|
120
172
|
## Миграция с v61
|
|
121
173
|
|
|
122
|
-
v62
|
|
174
|
+
v62 - breaking-релиз: проверок по умолчанию больше нет, всё подключается явно.
|
|
123
175
|
|
|
124
176
|
| v61 | v62 |
|
|
125
177
|
| ------------------------------- | ---------------------------------------------- |
|
|
@@ -137,7 +189,7 @@ v62 — breaking-релиз: проверок по умолчанию больш
|
|
|
137
189
|
|
|
138
190
|
- Проверка актуальности правил:
|
|
139
191
|
|
|
140
|
-
```
|
|
192
|
+
```bash
|
|
141
193
|
npx stylelint-find-new-rules
|
|
142
194
|
```
|
|
143
195
|
|
package/index.d.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import type { Config } from 'stylelint';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Опции фабрики плагина
|
|
4
|
+
* Опции фабрики плагина - частичный конфиг Stylelint, накладываемый поверх
|
|
5
5
|
* значений по умолчанию.
|
|
6
|
+
*
|
|
7
|
+
* Коллекции (`extends`, `ignoreFiles`, `overrides`, `plugins`) дополняют
|
|
8
|
+
* значения по умолчанию, `rules` мержатся поверхностно, остальные поля
|
|
9
|
+
* заменяются. Для каждого элемента `overrides` обязателен `files`.
|
|
6
10
|
*/
|
|
7
11
|
type PluginOptions = Partial<Config>;
|
|
8
12
|
|
|
9
13
|
/**
|
|
10
|
-
* Пространство имён фабрик конфигов плагинов. Дефолтных плагинов нет
|
|
14
|
+
* Пространство имён фабрик конфигов плагинов. Дефолтных плагинов нет -
|
|
11
15
|
* подключайте нужные явно.
|
|
12
16
|
*/
|
|
13
17
|
interface Plugins {
|
|
@@ -39,10 +43,10 @@ declare const plugins: Plugins;
|
|
|
39
43
|
*
|
|
40
44
|
* Приоритет (от низкого к высокому): база → конфиги плагинов по порядку →
|
|
41
45
|
* `options`. `extends`, `ignoreFiles`, `overrides` и `plugins` конкатенируются
|
|
42
|
-
* (дубли `plugins` убираются), `rules`
|
|
46
|
+
* (дубли `plugins` убираются), `rules` - shallow merge.
|
|
43
47
|
*
|
|
44
|
-
* @param pluginConfigs
|
|
45
|
-
* @param options
|
|
48
|
+
* @param pluginConfigs - Конфиги плагинов (например, `[plugins.scss()]`)
|
|
49
|
+
* @param options - Базовые опции Stylelint, наивысший приоритет
|
|
46
50
|
*/
|
|
47
51
|
declare function defineConfig(
|
|
48
52
|
pluginConfigs?: Config[],
|
package/index.js
CHANGED
|
@@ -17,8 +17,9 @@ import { scss } from './plugins/scss.js';
|
|
|
17
17
|
import { selectorNoEmpty } from './plugins/selector-no-empty.js';
|
|
18
18
|
import { useNesting } from './plugins/use-nesting.js';
|
|
19
19
|
import { vue } from './plugins/vue.js';
|
|
20
|
+
import { mergeConfigs } from './utils/merge-configs.js';
|
|
20
21
|
|
|
21
|
-
/** Плагины. Дефолтных плагинов нет
|
|
22
|
+
/** Плагины. Дефолтных плагинов нет - подключайте нужные явно в `defineConfig`. */
|
|
22
23
|
const plugins = {
|
|
23
24
|
a11y,
|
|
24
25
|
bem,
|
|
@@ -141,12 +142,12 @@ const BASE_RULES = {
|
|
|
141
142
|
* Создать конфиг Stylelint.
|
|
142
143
|
*
|
|
143
144
|
* Приоритет (от низкого к высокому): база → конфиги плагинов по порядку →
|
|
144
|
-
* `options`. `extends`, `ignoreFiles`, `overrides
|
|
145
|
-
* (дубли `plugins` убираются), `rules`
|
|
145
|
+
* `options`. Коллекции (`extends`, `ignoreFiles`, `overrides`, `plugins`)
|
|
146
|
+
* конкатенируются (дубли `plugins` убираются), `rules` - shallow merge.
|
|
146
147
|
*
|
|
147
|
-
* @param {import('stylelint').Config[]} [pluginConfigs]
|
|
148
|
+
* @param {import('stylelint').Config[]} [pluginConfigs] - Конфиги плагинов
|
|
148
149
|
* (например, `[plugins.scss(), plugins.vue()]`)
|
|
149
|
-
* @param {import('stylelint').Config} [options]
|
|
150
|
+
* @param {import('stylelint').Config} [options] - Базовые опции Stylelint,
|
|
150
151
|
* наивысший приоритет
|
|
151
152
|
*
|
|
152
153
|
* @returns {import('stylelint').Config}
|
|
@@ -167,16 +168,7 @@ const defineConfig = (pluginConfigs = [], options = {}) => {
|
|
|
167
168
|
rules: BASE_RULES,
|
|
168
169
|
};
|
|
169
170
|
|
|
170
|
-
|
|
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
|
-
};
|
|
171
|
+
return mergeConfigs(baseConfig, ...pluginConfigs, options);
|
|
180
172
|
};
|
|
181
173
|
|
|
182
174
|
export { defineConfig, plugins };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alexlit/config-stylelint",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "64.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Stylelint config",
|
|
6
6
|
"keywords": [
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"README.md",
|
|
29
29
|
"index.js",
|
|
30
30
|
"index.d.ts",
|
|
31
|
-
"plugins"
|
|
31
|
+
"plugins",
|
|
32
|
+
"utils"
|
|
32
33
|
],
|
|
33
34
|
"scripts": {
|
|
34
35
|
"lint": "cd ../../ && ./scripts/lint.stylelint.sh",
|
|
@@ -59,7 +60,7 @@
|
|
|
59
60
|
"stylelint-order": "^8.1.2",
|
|
60
61
|
"stylelint-plugin-logical-css": "^2.1.0",
|
|
61
62
|
"stylelint-prettier": "^5.0.3",
|
|
62
|
-
"stylelint-scss": "^7.
|
|
63
|
+
"stylelint-scss": "^7.4.0",
|
|
63
64
|
"stylelint-selector-no-empty": "^1.0.9",
|
|
64
65
|
"stylelint-use-nesting": "^6.0.2"
|
|
65
66
|
},
|
package/plugins/a11y.js
CHANGED
|
@@ -1,31 +1,25 @@
|
|
|
1
1
|
/* eslint-disable unicorn/no-null */
|
|
2
|
+
import { mergeConfigs } from '../utils/merge-configs.js';
|
|
3
|
+
|
|
4
|
+
const DEFAULTS = {
|
|
5
|
+
plugins: ['@double-great/stylelint-a11y'],
|
|
6
|
+
rules: {
|
|
7
|
+
'a11y/media-prefers-reduced-motion': null,
|
|
8
|
+
'a11y/no-obsolete-attribute': true,
|
|
9
|
+
'a11y/no-obsolete-element': true,
|
|
10
|
+
'a11y/no-outline-none': true,
|
|
11
|
+
'a11y/no-text-align-justify': true,
|
|
12
|
+
'a11y/selector-pseudo-class-focus': true,
|
|
13
|
+
},
|
|
14
|
+
};
|
|
2
15
|
|
|
3
16
|
/**
|
|
4
17
|
* Проверяет типичные ошибки доступности.
|
|
5
18
|
*
|
|
6
|
-
* @param {Partial<import('stylelint').Config>} [options]
|
|
7
|
-
* поверх значений по умолчанию (shallow merge)
|
|
19
|
+
* @param {Partial<import('stylelint').Config>} [options]
|
|
8
20
|
*
|
|
9
21
|
* @returns {import('stylelint').Config}
|
|
10
22
|
*
|
|
11
23
|
* @see [stylelint-a11y](https://github.com/double-great/stylelint-a11y)
|
|
12
24
|
*/
|
|
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
|
-
};
|
|
31
|
-
};
|
|
25
|
+
export const a11y = (options = {}) => mergeConfigs(DEFAULTS, options);
|
package/plugins/bem.js
CHANGED
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
/* eslint-disable unicorn/no-null */
|
|
2
2
|
import { createDefineRules } from '@morev/stylelint-plugin';
|
|
3
3
|
|
|
4
|
+
import { mergeConfigs } from '../utils/merge-configs.js';
|
|
5
|
+
|
|
4
6
|
const defineRules = createDefineRules({
|
|
5
7
|
separators: { element: '__', modifier: '--', modifierValue: '--' },
|
|
6
8
|
});
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
* Настраивает линтинг по методологии БЭМ.
|
|
10
|
-
*
|
|
11
|
-
* @param {Partial<import('stylelint').Config>} [options] — опции, накладываемые
|
|
12
|
-
* поверх значений по умолчанию (shallow merge)
|
|
13
|
-
*
|
|
14
|
-
* @returns {import('stylelint').Config}
|
|
15
|
-
*
|
|
16
|
-
* @see [@morev/stylelint-plugin](https://morevm.github.io/stylelint-plugin/)
|
|
17
|
-
*/
|
|
18
|
-
export const bem = (options = {}) => ({
|
|
10
|
+
const DEFAULTS = {
|
|
19
11
|
overrides: [
|
|
20
12
|
{
|
|
21
13
|
files: ['**/*.{css,scss,vue}'],
|
|
@@ -45,6 +37,15 @@ export const bem = (options = {}) => ({
|
|
|
45
37
|
},
|
|
46
38
|
],
|
|
47
39
|
plugins: ['@morev/stylelint-plugin'],
|
|
40
|
+
};
|
|
48
41
|
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Настраивает линтинг по методологии БЭМ.
|
|
44
|
+
*
|
|
45
|
+
* @param {Partial<import('stylelint').Config>} [options]
|
|
46
|
+
*
|
|
47
|
+
* @returns {import('stylelint').Config}
|
|
48
|
+
*
|
|
49
|
+
* @see [@morev/stylelint-plugin](https://morevm.github.io/stylelint-plugin/)
|
|
50
|
+
*/
|
|
51
|
+
export const bem = (options = {}) => mergeConfigs(DEFAULTS, options);
|
package/plugins/color-format.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import stylelint from 'stylelint';
|
|
2
2
|
|
|
3
|
+
import { mergeConfigs } from '../utils/merge-configs.js';
|
|
4
|
+
|
|
3
5
|
const { createPlugin } = stylelint;
|
|
4
6
|
const { report, ruleMessages, validateOptions } = stylelint.utils;
|
|
5
7
|
|
|
@@ -168,18 +170,18 @@ const rule = function (actual, options, context) {
|
|
|
168
170
|
rule.ruleName = ruleName;
|
|
169
171
|
rule.messages = messages;
|
|
170
172
|
|
|
173
|
+
const DEFAULTS = {
|
|
174
|
+
plugins: [createPlugin(ruleName, rule)],
|
|
175
|
+
rules: { 'color-format/format': { format: 'rgb' } },
|
|
176
|
+
};
|
|
177
|
+
|
|
171
178
|
/**
|
|
172
179
|
* Нормализует формат цветов (hex → rgb/hsl).
|
|
173
180
|
*
|
|
174
|
-
* @param {Partial<import('stylelint').Config>} [options]
|
|
175
|
-
* поверх значений по
|
|
181
|
+
* @param {Partial<import('stylelint').Config>} [options] - Опции, накладываемые
|
|
182
|
+
* поверх значений по умолчанию. Коллекции (`extends`, `ignoreFiles`,
|
|
183
|
+
* `overrides`, `plugins`) дополняются, `rules` мержатся поверхностно
|
|
176
184
|
*
|
|
177
185
|
* @returns {import('stylelint').Config}
|
|
178
186
|
*/
|
|
179
|
-
export const colorFormat = (options = {}) => (
|
|
180
|
-
plugins: [createPlugin(ruleName, rule)],
|
|
181
|
-
|
|
182
|
-
...options,
|
|
183
|
-
|
|
184
|
-
rules: { 'color-format/format': { format: 'rgb' }, ...options.rules },
|
|
185
|
-
});
|
|
187
|
+
export const colorFormat = (options = {}) => mergeConfigs(DEFAULTS, options);
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
+
import { mergeConfigs } from '../utils/merge-configs.js';
|
|
2
|
+
|
|
3
|
+
const DEFAULTS = {
|
|
4
|
+
plugins: ['stylelint-declaration-block-no-ignored-properties'],
|
|
5
|
+
rules: { 'plugin/declaration-block-no-ignored-properties': true },
|
|
6
|
+
};
|
|
7
|
+
|
|
1
8
|
/**
|
|
2
9
|
* Запрещает бесполезные свойства в блоке объявлений.
|
|
3
10
|
*
|
|
4
|
-
* @param {Partial<import('stylelint').Config>} [options]
|
|
5
|
-
* поверх значений по умолчанию (shallow merge)
|
|
11
|
+
* @param {Partial<import('stylelint').Config>} [options]
|
|
6
12
|
*
|
|
7
13
|
* @returns {import('stylelint').Config}
|
|
8
14
|
*
|
|
9
15
|
* @see [stylelint-declaration-block-no-ignored-properties](https://github.com/kristerkari/stylelint-declaration-block-no-ignored-properties)
|
|
10
16
|
*/
|
|
11
|
-
export const declarationBlockNoIgnoredProperties = (options = {}) =>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
...options,
|
|
15
|
-
|
|
16
|
-
rules: {
|
|
17
|
-
'plugin/declaration-block-no-ignored-properties': true,
|
|
18
|
-
...options.rules,
|
|
19
|
-
},
|
|
20
|
-
});
|
|
17
|
+
export const declarationBlockNoIgnoredProperties = (options = {}) =>
|
|
18
|
+
mergeConfigs(DEFAULTS, options);
|
package/plugins/gamut.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
+
import { mergeConfigs } from '../utils/merge-configs.js';
|
|
2
|
+
|
|
3
|
+
const DEFAULTS = {
|
|
4
|
+
plugins: ['stylelint-gamut'],
|
|
5
|
+
rules: { 'gamut/color-no-out-gamut-range': true },
|
|
6
|
+
};
|
|
7
|
+
|
|
1
8
|
/**
|
|
2
9
|
* Проверяет цвета на выход за пределы цветового охвата (gamut).
|
|
3
10
|
*
|
|
4
|
-
* @param {Partial<import('stylelint').Config>} [options]
|
|
5
|
-
* поверх значений по умолчанию (shallow merge)
|
|
11
|
+
* @param {Partial<import('stylelint').Config>} [options]
|
|
6
12
|
*
|
|
7
13
|
* @returns {import('stylelint').Config}
|
|
8
14
|
*
|
|
9
15
|
* @see [stylelint-gamut](https://github.com/fpetrakov/stylelint-gamut)
|
|
10
16
|
*/
|
|
11
|
-
export const gamut = (options = {}) => (
|
|
12
|
-
plugins: ['stylelint-gamut'],
|
|
13
|
-
|
|
14
|
-
...options,
|
|
15
|
-
|
|
16
|
-
rules: { 'gamut/color-no-out-gamut-range': true, ...options.rules },
|
|
17
|
-
});
|
|
17
|
+
export const gamut = (options = {}) => mergeConfigs(DEFAULTS, options);
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
+
import { mergeConfigs } from '../utils/merge-configs.js';
|
|
2
|
+
|
|
3
|
+
const DEFAULTS = {
|
|
4
|
+
plugins: ['stylelint-high-performance-animation'],
|
|
5
|
+
rules: {
|
|
6
|
+
'plugin/no-low-performance-animation-properties': [
|
|
7
|
+
true,
|
|
8
|
+
{ ignore: 'paint-properties', ignoreProperties: [] },
|
|
9
|
+
],
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
|
|
1
13
|
/**
|
|
2
14
|
* Запрещает анимации, нагружающие рендеринг.
|
|
3
15
|
*
|
|
4
|
-
* @param {Partial<import('stylelint').Config>} [options]
|
|
5
|
-
* поверх значений по умолчанию (shallow merge)
|
|
16
|
+
* @param {Partial<import('stylelint').Config>} [options]
|
|
6
17
|
*
|
|
7
18
|
* @returns {import('stylelint').Config}
|
|
8
19
|
*
|
|
9
20
|
* @see [stylelint-high-performance-animation](https://github.com/kristerkari/stylelint-high-performance-animation)
|
|
10
21
|
*/
|
|
11
|
-
export const highPerformanceAnimation = (options = {}) =>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
...options,
|
|
15
|
-
|
|
16
|
-
rules: {
|
|
17
|
-
'plugin/no-low-performance-animation-properties': [
|
|
18
|
-
true,
|
|
19
|
-
{ ignore: 'paint-properties', ignoreProperties: [] },
|
|
20
|
-
],
|
|
21
|
-
...options.rules,
|
|
22
|
-
},
|
|
23
|
-
});
|
|
22
|
+
export const highPerformanceAnimation = (options = {}) =>
|
|
23
|
+
mergeConfigs(DEFAULTS, options);
|
package/plugins/logical-css.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
import { mergeConfigs } from '../utils/merge-configs.js';
|
|
2
|
+
|
|
3
|
+
const DEFAULTS = {
|
|
4
|
+
extends: ['stylelint-plugin-logical-css/configs/recommended'],
|
|
5
|
+
plugins: ['stylelint-plugin-logical-css'],
|
|
6
|
+
};
|
|
7
|
+
|
|
1
8
|
/**
|
|
2
9
|
* Проверяет использование логических CSS-свойств.
|
|
3
10
|
*
|
|
4
|
-
* @param {Partial<import('stylelint').Config>} [options]
|
|
5
|
-
* поверх значений по умолчанию (shallow merge)
|
|
11
|
+
* @param {Partial<import('stylelint').Config>} [options]
|
|
6
12
|
*
|
|
7
13
|
* @returns {import('stylelint').Config}
|
|
8
14
|
*
|
|
9
15
|
* @see [stylelint-plugin-logical-css](https://github.com/yuschick/stylelint-plugin-logical-css)
|
|
10
16
|
*/
|
|
11
|
-
export const logicalCss = (options = {}) => (
|
|
12
|
-
extends: ['stylelint-plugin-logical-css/configs/recommended'],
|
|
13
|
-
plugins: ['stylelint-plugin-logical-css'],
|
|
14
|
-
|
|
15
|
-
...options,
|
|
16
|
-
});
|
|
17
|
+
export const logicalCss = (options = {}) => mergeConfigs(DEFAULTS, options);
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
+
import { mergeConfigs } from '../utils/merge-configs.js';
|
|
2
|
+
|
|
3
|
+
const DEFAULTS = {
|
|
4
|
+
plugins: ['stylelint-media-use-custom-media'],
|
|
5
|
+
rules: { 'csstools/media-use-custom-media': 'always' },
|
|
6
|
+
};
|
|
7
|
+
|
|
1
8
|
/**
|
|
2
9
|
* Требует использования кастомных медиа-запросов.
|
|
3
10
|
*
|
|
4
|
-
* @param {Partial<import('stylelint').Config>} [options]
|
|
5
|
-
* поверх значений по умолчанию (shallow merge)
|
|
11
|
+
* @param {Partial<import('stylelint').Config>} [options]
|
|
6
12
|
*
|
|
7
13
|
* @returns {import('stylelint').Config}
|
|
8
14
|
*
|
|
9
15
|
* @see [stylelint-media-use-custom-media](https://github.com/csstools/stylelint-media-use-custom-media)
|
|
10
16
|
*/
|
|
11
|
-
export const mediaUseCustomMedia = (options = {}) =>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
...options,
|
|
15
|
-
|
|
16
|
-
rules: { 'csstools/media-use-custom-media': 'always', ...options.rules },
|
|
17
|
-
});
|
|
17
|
+
export const mediaUseCustomMedia = (options = {}) =>
|
|
18
|
+
mergeConfigs(DEFAULTS, options);
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
+
import { mergeConfigs } from '../utils/merge-configs.js';
|
|
2
|
+
|
|
3
|
+
const DEFAULTS = {
|
|
4
|
+
plugins: ['stylelint-no-indistinguishable-colors'],
|
|
5
|
+
rules: { 'plugin/stylelint-no-indistinguishable-colors': true },
|
|
6
|
+
};
|
|
7
|
+
|
|
1
8
|
/**
|
|
2
9
|
* Запрещает неразличимые цвета.
|
|
3
10
|
*
|
|
4
|
-
* @param {Partial<import('stylelint').Config>} [options]
|
|
5
|
-
* поверх значений по умолчанию (shallow merge)
|
|
11
|
+
* @param {Partial<import('stylelint').Config>} [options]
|
|
6
12
|
*
|
|
7
13
|
* @returns {import('stylelint').Config}
|
|
8
14
|
*
|
|
9
15
|
* @see [stylelint-no-indistinguishable-colors](https://github.com/ierhyna/stylelint-no-indistinguishable-colors)
|
|
10
16
|
*/
|
|
11
|
-
export const noIndistinguishableColors = (options = {}) =>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
...options,
|
|
15
|
-
|
|
16
|
-
rules: {
|
|
17
|
-
'plugin/stylelint-no-indistinguishable-colors': true,
|
|
18
|
-
...options.rules,
|
|
19
|
-
},
|
|
20
|
-
});
|
|
17
|
+
export const noIndistinguishableColors = (options = {}) =>
|
|
18
|
+
mergeConfigs(DEFAULTS, options);
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
+
import { mergeConfigs } from '../utils/merge-configs.js';
|
|
2
|
+
|
|
3
|
+
const DEFAULTS = {
|
|
4
|
+
plugins: ['stylelint-no-nested-media'],
|
|
5
|
+
rules: { 'pitcher/no-nested-media': true },
|
|
6
|
+
};
|
|
7
|
+
|
|
1
8
|
/**
|
|
2
9
|
* Запрещает вложенные медиа-запросы.
|
|
3
10
|
*
|
|
4
|
-
* @param {Partial<import('stylelint').Config>} [options]
|
|
5
|
-
* поверх значений по умолчанию (shallow merge)
|
|
11
|
+
* @param {Partial<import('stylelint').Config>} [options]
|
|
6
12
|
*
|
|
7
13
|
* @returns {import('stylelint').Config}
|
|
8
14
|
*
|
|
9
15
|
* @see [stylelint-no-nested-media](https://github.com/dkrnl/stylelint-no-nested-media)
|
|
10
16
|
*/
|
|
11
|
-
export const noNestedMedia = (options = {}) => (
|
|
12
|
-
plugins: ['stylelint-no-nested-media'],
|
|
13
|
-
|
|
14
|
-
...options,
|
|
15
|
-
|
|
16
|
-
rules: { 'pitcher/no-nested-media': true, ...options.rules },
|
|
17
|
-
});
|
|
17
|
+
export const noNestedMedia = (options = {}) => mergeConfigs(DEFAULTS, options);
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
* Проверяет разрешение импортов.
|
|
3
|
-
*
|
|
4
|
-
* @param {Partial<import('stylelint').Config>} [options] — опции, накладываемые
|
|
5
|
-
* поверх значений по умолчанию (shallow merge)
|
|
6
|
-
*
|
|
7
|
-
* @returns {import('stylelint').Config}
|
|
8
|
-
*
|
|
9
|
-
* @see [stylelint-no-unresolved-module](https://github.com/niksy/stylelint-no-unresolved-module)
|
|
10
|
-
*/
|
|
11
|
-
export const noUnresolvedModule = (options = {}) => ({
|
|
12
|
-
plugins: ['stylelint-no-unresolved-module'],
|
|
13
|
-
|
|
14
|
-
...options,
|
|
1
|
+
import { mergeConfigs } from '../utils/merge-configs.js';
|
|
15
2
|
|
|
3
|
+
const DEFAULTS = {
|
|
4
|
+
plugins: ['stylelint-no-unresolved-module'],
|
|
16
5
|
rules: {
|
|
17
6
|
'plugin/no-unresolved-module': {
|
|
18
7
|
alias: { '~assets': 'assets', '~public': 'public', '~static': 'static' },
|
|
@@ -27,6 +16,17 @@ export const noUnresolvedModule = (options = {}) => ({
|
|
|
27
16
|
'static',
|
|
28
17
|
],
|
|
29
18
|
},
|
|
30
|
-
...options.rules,
|
|
31
19
|
},
|
|
32
|
-
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Проверяет разрешение импортов.
|
|
24
|
+
*
|
|
25
|
+
* @param {Partial<import('stylelint').Config>} [options]
|
|
26
|
+
*
|
|
27
|
+
* @returns {import('stylelint').Config}
|
|
28
|
+
*
|
|
29
|
+
* @see [stylelint-no-unresolved-module](https://github.com/niksy/stylelint-no-unresolved-module)
|
|
30
|
+
*/
|
|
31
|
+
export const noUnresolvedModule = (options = {}) =>
|
|
32
|
+
mergeConfigs(DEFAULTS, options);
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
* Проверяет поддержку CSS-функций целевыми браузерами.
|
|
3
|
-
*
|
|
4
|
-
* @param {Partial<import('stylelint').Config>} [options] — опции, накладываемые
|
|
5
|
-
* поверх значений по умолчанию (shallow merge)
|
|
6
|
-
*
|
|
7
|
-
* @returns {import('stylelint').Config}
|
|
8
|
-
*
|
|
9
|
-
* @see [stylelint-no-unsupported-browser-features](https://github.com/ismay/stylelint-no-unsupported-browser-features)
|
|
10
|
-
*/
|
|
11
|
-
export const noUnsupportedBrowserFeatures = (options = {}) => ({
|
|
12
|
-
plugins: ['stylelint-no-unsupported-browser-features'],
|
|
13
|
-
|
|
14
|
-
...options,
|
|
1
|
+
import { mergeConfigs } from '../utils/merge-configs.js';
|
|
15
2
|
|
|
3
|
+
const DEFAULTS = {
|
|
4
|
+
plugins: ['stylelint-no-unsupported-browser-features'],
|
|
16
5
|
rules: {
|
|
17
6
|
'plugin/no-unsupported-browser-features': [
|
|
18
7
|
true,
|
|
@@ -22,6 +11,17 @@ export const noUnsupportedBrowserFeatures = (options = {}) => ({
|
|
|
22
11
|
severity: 'warning',
|
|
23
12
|
},
|
|
24
13
|
],
|
|
25
|
-
...options.rules,
|
|
26
14
|
},
|
|
27
|
-
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Проверяет поддержку CSS-функций целевыми браузерами.
|
|
19
|
+
*
|
|
20
|
+
* @param {Partial<import('stylelint').Config>} [options]
|
|
21
|
+
*
|
|
22
|
+
* @returns {import('stylelint').Config}
|
|
23
|
+
*
|
|
24
|
+
* @see [stylelint-no-unsupported-browser-features](https://github.com/ismay/stylelint-no-unsupported-browser-features)
|
|
25
|
+
*/
|
|
26
|
+
export const noUnsupportedBrowserFeatures = (options = {}) =>
|
|
27
|
+
mergeConfigs(DEFAULTS, options);
|
package/plugins/order.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { mergeConfigs } from '../utils/merge-configs.js';
|
|
2
|
+
|
|
1
3
|
const LETTERS = 'abcdefghijklmnopqrstuvwxyz'.split('');
|
|
2
4
|
|
|
3
5
|
const MEDIA_FEATURES = [
|
|
@@ -115,21 +117,8 @@ const buildPseudoElementRules = () => [
|
|
|
115
117
|
{ selector: '::', type: 'rule' },
|
|
116
118
|
];
|
|
117
119
|
|
|
118
|
-
|
|
119
|
-
* Настраивает порядок свойств и селекторов.
|
|
120
|
-
*
|
|
121
|
-
* @param {Partial<import('stylelint').Config>} [options] — опции, накладываемые
|
|
122
|
-
* поверх значений по умолчанию (shallow merge)
|
|
123
|
-
*
|
|
124
|
-
* @returns {import('stylelint').Config}
|
|
125
|
-
*
|
|
126
|
-
* @see [stylelint-order](https://github.com/hudochenkov/stylelint-order)
|
|
127
|
-
*/
|
|
128
|
-
export const order = (options = {}) => ({
|
|
120
|
+
const DEFAULTS = {
|
|
129
121
|
plugins: ['stylelint-order'],
|
|
130
|
-
|
|
131
|
-
...options,
|
|
132
|
-
|
|
133
122
|
rules: {
|
|
134
123
|
'order/custom-properties-alphabetical-order': true,
|
|
135
124
|
'order/order': [
|
|
@@ -198,7 +187,16 @@ export const order = (options = {}) => ({
|
|
|
198
187
|
...buildLetterRules('__'),
|
|
199
188
|
],
|
|
200
189
|
'order/properties-alphabetical-order': true,
|
|
201
|
-
|
|
202
|
-
...options.rules,
|
|
203
190
|
},
|
|
204
|
-
}
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Настраивает порядок свойств и селекторов.
|
|
195
|
+
*
|
|
196
|
+
* @param {Partial<import('stylelint').Config>} [options]
|
|
197
|
+
*
|
|
198
|
+
* @returns {import('stylelint').Config}
|
|
199
|
+
*
|
|
200
|
+
* @see [stylelint-order](https://github.com/hudochenkov/stylelint-order)
|
|
201
|
+
*/
|
|
202
|
+
export const order = (options = {}) => mergeConfigs(DEFAULTS, options);
|
package/plugins/prettier.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
+
import { mergeConfigs } from '../utils/merge-configs.js';
|
|
2
|
+
|
|
3
|
+
const DEFAULTS = {
|
|
4
|
+
plugins: ['stylelint-prettier'],
|
|
5
|
+
rules: { 'prettier/prettier': true },
|
|
6
|
+
};
|
|
7
|
+
|
|
1
8
|
/**
|
|
2
9
|
* Интегрирует Prettier.
|
|
3
10
|
*
|
|
4
|
-
* @param {Partial<import('stylelint').Config>} [options]
|
|
5
|
-
* поверх значений по умолчанию (shallow merge)
|
|
11
|
+
* @param {Partial<import('stylelint').Config>} [options]
|
|
6
12
|
*
|
|
7
13
|
* @returns {import('stylelint').Config}
|
|
8
14
|
*
|
|
9
15
|
* @see [stylelint-prettier](https://github.com/prettier/stylelint-prettier)
|
|
10
16
|
*/
|
|
11
|
-
export const prettier = (options = {}) => (
|
|
12
|
-
plugins: ['stylelint-prettier'],
|
|
13
|
-
|
|
14
|
-
...options,
|
|
15
|
-
|
|
16
|
-
rules: { 'prettier/prettier': true, ...options.rules },
|
|
17
|
-
});
|
|
17
|
+
export const prettier = (options = {}) => mergeConfigs(DEFAULTS, options);
|
package/plugins/scss.js
CHANGED
|
@@ -1,23 +1,11 @@
|
|
|
1
1
|
/* eslint-disable unicorn/no-null */
|
|
2
|
+
import { mergeConfigs } from '../utils/merge-configs.js';
|
|
2
3
|
|
|
3
4
|
const KEBAB_CASE_PATTERN = '^[a-z]+([a-z0-9-]+[a-z0-9]+)?$';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
* Настраивает линтинг SCSS.
|
|
7
|
-
*
|
|
8
|
-
* @param {Partial<import('stylelint').Config>} [options] — опции, накладываемые
|
|
9
|
-
* поверх значений по умолчанию (shallow merge)
|
|
10
|
-
*
|
|
11
|
-
* @returns {import('stylelint').Config}
|
|
12
|
-
*
|
|
13
|
-
* @see [stylelint-scss](https://github.com/kristerkari/stylelint-scss)
|
|
14
|
-
*/
|
|
15
|
-
export const scss = (options = {}) => ({
|
|
6
|
+
const DEFAULTS = {
|
|
16
7
|
extends: ['stylelint-config-standard-scss'],
|
|
17
8
|
plugins: ['stylelint-scss'],
|
|
18
|
-
|
|
19
|
-
...options,
|
|
20
|
-
|
|
21
9
|
rules: {
|
|
22
10
|
'scss/at-each-key-value-single-line': true,
|
|
23
11
|
'scss/at-else-if-parentheses-space-before': 'always',
|
|
@@ -100,7 +88,16 @@ export const scss = (options = {}) => ({
|
|
|
100
88
|
true,
|
|
101
89
|
{ ignoreKeywords: [] },
|
|
102
90
|
],
|
|
103
|
-
|
|
104
|
-
...options.rules,
|
|
105
91
|
},
|
|
106
|
-
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Настраивает линтинг SCSS.
|
|
96
|
+
*
|
|
97
|
+
* @param {Partial<import('stylelint').Config>} [options]
|
|
98
|
+
*
|
|
99
|
+
* @returns {import('stylelint').Config}
|
|
100
|
+
*
|
|
101
|
+
* @see [stylelint-scss](https://github.com/kristerkari/stylelint-scss)
|
|
102
|
+
*/
|
|
103
|
+
export const scss = (options = {}) => mergeConfigs(DEFAULTS, options);
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
+
import { mergeConfigs } from '../utils/merge-configs.js';
|
|
2
|
+
|
|
3
|
+
const DEFAULTS = {
|
|
4
|
+
plugins: ['stylelint-selector-no-empty'],
|
|
5
|
+
rules: { 'plugin/stylelint-selector-no-empty': true },
|
|
6
|
+
};
|
|
7
|
+
|
|
1
8
|
/**
|
|
2
9
|
* Запрещает пустые селекторы.
|
|
3
10
|
*
|
|
4
|
-
* @param {Partial<import('stylelint').Config>} [options]
|
|
5
|
-
* поверх значений по умолчанию (shallow merge)
|
|
11
|
+
* @param {Partial<import('stylelint').Config>} [options]
|
|
6
12
|
*
|
|
7
13
|
* @returns {import('stylelint').Config}
|
|
8
14
|
*
|
|
9
15
|
* @see [stylelint-selector-no-empty](https://github.com/ssivanatarajan/stylelint-selector-no-empty)
|
|
10
16
|
*/
|
|
11
|
-
export const selectorNoEmpty = (options = {}) =>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
...options,
|
|
15
|
-
|
|
16
|
-
rules: { 'plugin/stylelint-selector-no-empty': true, ...options.rules },
|
|
17
|
-
});
|
|
17
|
+
export const selectorNoEmpty = (options = {}) =>
|
|
18
|
+
mergeConfigs(DEFAULTS, options);
|
package/plugins/use-nesting.js
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
|
+
import { mergeConfigs } from '../utils/merge-configs.js';
|
|
2
|
+
|
|
3
|
+
const DEFAULTS = {
|
|
4
|
+
plugins: ['stylelint-use-nesting'],
|
|
5
|
+
rules: { 'csstools/use-nesting': ['always', { except: [], syntax: 'scss' }] },
|
|
6
|
+
};
|
|
7
|
+
|
|
1
8
|
/**
|
|
2
9
|
* Требует использования CSS-вложенности.
|
|
3
10
|
*
|
|
4
|
-
* @param {Partial<import('stylelint').Config>} [options]
|
|
5
|
-
* поверх значений по умолчанию (shallow merge)
|
|
11
|
+
* @param {Partial<import('stylelint').Config>} [options]
|
|
6
12
|
*
|
|
7
13
|
* @returns {import('stylelint').Config}
|
|
8
14
|
*
|
|
9
15
|
* @see [stylelint-use-nesting](https://github.com/csstools/stylelint-use-nesting)
|
|
10
16
|
*/
|
|
11
|
-
export const useNesting = (options = {}) => (
|
|
12
|
-
plugins: ['stylelint-use-nesting'],
|
|
13
|
-
|
|
14
|
-
...options,
|
|
15
|
-
|
|
16
|
-
rules: {
|
|
17
|
-
'csstools/use-nesting': ['always', { except: [], syntax: 'scss' }],
|
|
18
|
-
...options.rules,
|
|
19
|
-
},
|
|
20
|
-
});
|
|
17
|
+
export const useNesting = (options = {}) => mergeConfigs(DEFAULTS, options);
|
package/plugins/vue.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
+
import { mergeConfigs } from '../utils/merge-configs.js';
|
|
2
|
+
|
|
3
|
+
const DEFAULTS = { extends: 'stylelint-config-recommended-vue' };
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* Подключает поддержку Vue.js SFC.
|
|
3
7
|
*
|
|
4
|
-
* @param {Partial<import('stylelint').Config>} [options]
|
|
5
|
-
* поверх значений по умолчанию (shallow merge)
|
|
8
|
+
* @param {Partial<import('stylelint').Config>} [options]
|
|
6
9
|
*
|
|
7
10
|
* @returns {import('stylelint').Config}
|
|
8
11
|
*
|
|
9
12
|
* @see [stylelint-config-recommended-vue](https://github.com/ota-meshi/stylelint-config-recommended-vue)
|
|
10
13
|
*/
|
|
11
|
-
export const vue = (options = {}) => (
|
|
12
|
-
extends: 'stylelint-config-recommended-vue',
|
|
13
|
-
|
|
14
|
-
...options,
|
|
15
|
-
});
|
|
14
|
+
export const vue = (options = {}) => mergeConfigs(DEFAULTS, options);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Объединяет конфиги Stylelint по единой политике.
|
|
3
|
+
*
|
|
4
|
+
* Коллекции (`extends`, `ignoreFiles`, `overrides`, `plugins`) дополняются в
|
|
5
|
+
* порядке аргументов, `plugins` дедуплицируются. `rules` мержатся поверхностно:
|
|
6
|
+
* настройка одноимённого правила из последнего конфига заменяет предыдущую
|
|
7
|
+
* целиком. Остальные поля перезаписываются последним конфигом.
|
|
8
|
+
*
|
|
9
|
+
* @param {...import('stylelint').Config} configs - Конфиги в порядке приоритета
|
|
10
|
+
*
|
|
11
|
+
* @returns {import('stylelint').Config}
|
|
12
|
+
*/
|
|
13
|
+
export const mergeConfigs = (...configs) => ({
|
|
14
|
+
...Object.assign({}, ...configs),
|
|
15
|
+
extends: configs.flatMap((config) => config.extends ?? []),
|
|
16
|
+
ignoreFiles: configs.flatMap((config) => config.ignoreFiles ?? []),
|
|
17
|
+
overrides: configs.flatMap((config) => config.overrides ?? []),
|
|
18
|
+
plugins: [...new Set(configs.flatMap((config) => config.plugins ?? []))],
|
|
19
|
+
rules: Object.assign({}, ...configs.map((config) => config.rules ?? {})),
|
|
20
|
+
});
|