@alexlit/config-stylelint 65.0.1 → 66.0.1
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 +63 -50
- package/index.d.ts +7 -6
- package/index.js +6 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -25,12 +25,9 @@ npm i @alexlit/config-stylelint -D
|
|
|
25
25
|
// stylelint.config.js
|
|
26
26
|
import { defineConfig, plugins } from '@alexlit/config-stylelint';
|
|
27
27
|
|
|
28
|
-
export default defineConfig(
|
|
29
|
-
plugins.scss(),
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
plugins.prettier(),
|
|
33
|
-
]);
|
|
28
|
+
export default defineConfig({
|
|
29
|
+
plugins: [plugins.scss(), plugins.vue(), plugins.prettier()],
|
|
30
|
+
});
|
|
34
31
|
```
|
|
35
32
|
|
|
36
33
|
## Пример скриптов для package.json
|
|
@@ -52,26 +49,28 @@ export default defineConfig([
|
|
|
52
49
|
// stylelint.config.js
|
|
53
50
|
import { defineConfig, plugins } from '@alexlit/config-stylelint';
|
|
54
51
|
|
|
55
|
-
export default defineConfig(
|
|
56
|
-
plugins
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
52
|
+
export default defineConfig({
|
|
53
|
+
plugins: [
|
|
54
|
+
plugins.a11y(),
|
|
55
|
+
plugins.bem(),
|
|
56
|
+
plugins.colorFormat(),
|
|
57
|
+
plugins.declarationBlockNoIgnoredProperties(),
|
|
58
|
+
plugins.gamut(),
|
|
59
|
+
plugins.highPerformanceAnimation(),
|
|
60
|
+
plugins.logicalCss(),
|
|
61
|
+
plugins.mediaUseCustomMedia(),
|
|
62
|
+
plugins.noNestedMedia(),
|
|
63
|
+
plugins.noUnresolvedModule(),
|
|
64
|
+
plugins.noUnsupportedBrowserFeatures(),
|
|
65
|
+
plugins.order(),
|
|
66
|
+
plugins.scss(),
|
|
67
|
+
plugins.selectorNoEmpty(),
|
|
68
|
+
plugins.useNesting(),
|
|
69
|
+
plugins.vue(),
|
|
70
|
+
|
|
71
|
+
plugins.prettier(),
|
|
72
|
+
],
|
|
73
|
+
});
|
|
75
74
|
```
|
|
76
75
|
|
|
77
76
|
## Настройка
|
|
@@ -84,12 +83,14 @@ export default defineConfig([
|
|
|
84
83
|
// stylelint.config.js
|
|
85
84
|
import { defineConfig, plugins } from '@alexlit/config-stylelint';
|
|
86
85
|
|
|
87
|
-
export default defineConfig(
|
|
88
|
-
plugins
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
86
|
+
export default defineConfig({
|
|
87
|
+
plugins: [
|
|
88
|
+
plugins.useNesting({ rules: { 'csstools/use-nesting': 'never' } }),
|
|
89
|
+
plugins.noUnresolvedModule({
|
|
90
|
+
rules: { 'plugin/no-unresolved-module': { alias: { '~': 'src' } } },
|
|
91
|
+
}),
|
|
92
|
+
],
|
|
93
|
+
});
|
|
93
94
|
```
|
|
94
95
|
|
|
95
96
|
`rules` мержатся поверхностно: настройка одноимённого правила из опций заменяет
|
|
@@ -105,13 +106,15 @@ export default defineConfig([
|
|
|
105
106
|
// stylelint.config.js
|
|
106
107
|
import { defineConfig, plugins } from '@alexlit/config-stylelint';
|
|
107
108
|
|
|
108
|
-
export default defineConfig(
|
|
109
|
-
plugins
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
109
|
+
export default defineConfig({
|
|
110
|
+
plugins: [
|
|
111
|
+
plugins.useNesting({
|
|
112
|
+
overrides: [
|
|
113
|
+
{ files: ['**/*.vue'], rules: { 'csstools/use-nesting': 'never' } },
|
|
114
|
+
],
|
|
115
|
+
}),
|
|
116
|
+
],
|
|
117
|
+
});
|
|
115
118
|
```
|
|
116
119
|
|
|
117
120
|
`files` обязателен: Stylelint падает с ошибкой, если в override его нет.
|
|
@@ -119,25 +122,25 @@ export default defineConfig([
|
|
|
119
122
|
### Приоритет настроек
|
|
120
123
|
|
|
121
124
|
Внутри одной проверки: дефолты → `options.rules` → `options.overrides` (для
|
|
122
|
-
подходящих файлов). Между проверками и
|
|
123
|
-
|
|
125
|
+
подходящих файлов). Между проверками и `options` из `defineConfig` действует тот
|
|
126
|
+
же порядок: база → проверки по порядку → `options`.
|
|
124
127
|
|
|
125
|
-
Коллекции (`extends`, `ignoreFiles`, `overrides`, `plugins`)
|
|
126
|
-
`plugins` дедуплицируются. Остальные поля, например `customSyntax`,
|
|
127
|
-
значениями из опций.
|
|
128
|
+
Коллекции внутри опций (`extends`, `ignoreFiles`, `overrides`, `plugins`)
|
|
129
|
+
дополняются, `plugins` дедуплицируются. Остальные поля, например `customSyntax`,
|
|
130
|
+
заменяются значениями из опций.
|
|
128
131
|
|
|
129
132
|
### Общие настройки Stylelint
|
|
130
133
|
|
|
131
|
-
|
|
132
|
-
|
|
134
|
+
Свойство `options` - общие опции: собственные правила, файлы для игнора и т.д.
|
|
135
|
+
Они перебивают настройки всех проверок:
|
|
133
136
|
|
|
134
137
|
```js
|
|
135
138
|
// stylelint.config.js
|
|
136
139
|
import { defineConfig, plugins } from '@alexlit/config-stylelint';
|
|
137
140
|
|
|
138
|
-
export default defineConfig(
|
|
139
|
-
|
|
140
|
-
rules: { 'max-nesting-depth': 3 },
|
|
141
|
+
export default defineConfig({
|
|
142
|
+
plugins: [plugins.scss(), plugins.vue()],
|
|
143
|
+
options: { ignoreFiles: ['fixtures/**'], rules: { 'max-nesting-depth': 3 } },
|
|
141
144
|
});
|
|
142
145
|
```
|
|
143
146
|
|
|
@@ -164,6 +167,16 @@ export default defineConfig([plugins.scss(), plugins.vue()], {
|
|
|
164
167
|
| `plugins.useNesting()` | Требует использования CSS-вложенности | [`stylelint-use-nesting`](https://github.com/csstools/stylelint-use-nesting) |
|
|
165
168
|
| `plugins.vue()` | Подключает поддержку Vue.js SFC | [`stylelint-config-recommended-vue`](https://github.com/ota-meshi/stylelint-config-recommended-vue) |
|
|
166
169
|
|
|
170
|
+
## Миграция с v65
|
|
171
|
+
|
|
172
|
+
v66 - breaking-релиз: позиционные аргументы заменены одним объектом.
|
|
173
|
+
|
|
174
|
+
| v65 | v66 |
|
|
175
|
+
| -------------------------------------- | ------------------------------------ |
|
|
176
|
+
| `defineConfig()` | `defineConfig()` |
|
|
177
|
+
| `defineConfig(pluginConfigs)` | `defineConfig({ plugins })` |
|
|
178
|
+
| `defineConfig(pluginConfigs, options)` | `defineConfig({ plugins, options })` |
|
|
179
|
+
|
|
167
180
|
## Миграция с v63
|
|
168
181
|
|
|
169
182
|
v64 - major-релиз: коллекции в опциях проверок теперь дополняют дефолты, а не
|
|
@@ -176,7 +189,7 @@ v64 - major-релиз: коллекции в опциях проверок те
|
|
|
176
189
|
| `plugins.bem({ overrides: [...] })` заменял дефолтные | overrides дополняются, пользовательские применяются после дефолтных |
|
|
177
190
|
|
|
178
191
|
Отключить конкретное дефолтное правило можно через `rules: { 'rule': null }`.
|
|
179
|
-
Общие настройки, которые должны перебивать всё, передавайте
|
|
192
|
+
Общие настройки, которые должны перебивать всё, передавайте в `options` внутри
|
|
180
193
|
`defineConfig`.
|
|
181
194
|
|
|
182
195
|
## Миграция с v61
|
package/index.d.ts
CHANGED
|
@@ -45,12 +45,13 @@ declare const plugins: Plugins;
|
|
|
45
45
|
* `options`. `extends`, `ignoreFiles`, `overrides` и `plugins` конкатенируются
|
|
46
46
|
* (дубли `plugins` убираются), `rules` - shallow merge.
|
|
47
47
|
*
|
|
48
|
-
* @param
|
|
49
|
-
* @param options - Базовые опции Stylelint, наивысший приоритет
|
|
48
|
+
* @param config - Настройки конфигурации
|
|
49
|
+
* @param config.options - Базовые опции Stylelint, наивысший приоритет
|
|
50
|
+
* @param config.plugins - Конфиги плагинов (например, `[plugins.scss()]`)
|
|
50
51
|
*/
|
|
51
|
-
declare function defineConfig(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
): Config;
|
|
52
|
+
declare function defineConfig(config?: {
|
|
53
|
+
options?: Config;
|
|
54
|
+
plugins?: Config[];
|
|
55
|
+
}): Config;
|
|
55
56
|
|
|
56
57
|
export { defineConfig, plugins };
|
package/index.js
CHANGED
|
@@ -145,14 +145,15 @@ const BASE_RULES = {
|
|
|
145
145
|
* `options`. Коллекции (`extends`, `ignoreFiles`, `overrides`, `plugins`)
|
|
146
146
|
* конкатенируются (дубли `plugins` убираются), `rules` - shallow merge.
|
|
147
147
|
*
|
|
148
|
-
* @param {
|
|
148
|
+
* @param {object} [config] - Настройки конфигурации
|
|
149
|
+
* @param {import('stylelint').Config} [config.options] - Базовые опции
|
|
150
|
+
* Stylelint, наивысший приоритет
|
|
151
|
+
* @param {import('stylelint').Config[]} [config.plugins] - Конфиги плагинов
|
|
149
152
|
* (например, `[plugins.scss(), plugins.vue()]`)
|
|
150
|
-
* @param {import('stylelint').Config} [options] - Базовые опции Stylelint,
|
|
151
|
-
* наивысший приоритет
|
|
152
153
|
*
|
|
153
154
|
* @returns {import('stylelint').Config}
|
|
154
155
|
*/
|
|
155
|
-
const defineConfig = (
|
|
156
|
+
const defineConfig = ({ options = {}, plugins = [] } = {}) => {
|
|
156
157
|
const baseConfig = {
|
|
157
158
|
extends: ['stylelint-config-standard'],
|
|
158
159
|
ignoreFiles: [
|
|
@@ -168,7 +169,7 @@ const defineConfig = (pluginConfigs = [], options = {}) => {
|
|
|
168
169
|
rules: BASE_RULES,
|
|
169
170
|
};
|
|
170
171
|
|
|
171
|
-
return mergeConfigs(baseConfig, ...
|
|
172
|
+
return mergeConfigs(baseConfig, ...plugins, options);
|
|
172
173
|
};
|
|
173
174
|
|
|
174
175
|
export { defineConfig, plugins };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alexlit/config-stylelint",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "66.0.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Stylelint config",
|
|
6
6
|
"keywords": [
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"stylelint-no-unresolved-module": "^2.6.0",
|
|
59
59
|
"stylelint-no-unsupported-browser-features": "^8.1.2",
|
|
60
60
|
"stylelint-order": "^8.1.3",
|
|
61
|
-
"stylelint-plugin-logical-css": "^2.1.
|
|
61
|
+
"stylelint-plugin-logical-css": "^2.1.1",
|
|
62
62
|
"stylelint-prettier": "^5.1.0",
|
|
63
63
|
"stylelint-scss": "^7.5.0",
|
|
64
64
|
"stylelint-selector-no-empty": "^1.0.9",
|