@xiaohe01/stylelint-config 2.0.0 → 2.2.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 +4 -1
- package/dist/index.cjs +277 -105
- package/dist/index.d.cts +41 -14
- package/dist/index.d.mts +41 -14
- package/dist/index.d.ts +41 -14
- package/dist/index.mjs +272 -105
- package/package.json +4 -7
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<h1>xiaohe-stylelint-config</h1>
|
|
3
|
-
<span>🤚 Stylelint config preset for xiaohe</span>
|
|
3
|
+
<span>🤚 Stylelint config preset for xiaohe (inspired by antfu/eslint-config)</span>
|
|
4
4
|
</div>
|
|
5
5
|
|
|
6
6
|
<br>
|
|
@@ -26,6 +26,9 @@ yarn add --dev stylelint @xiaohe01/stylelint-config
|
|
|
26
26
|
npm install -D stylelint @xiaohe01/stylelint-config
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
+
> [!WARNING]
|
|
30
|
+
> Stylelint `16.13.0+` is now required
|
|
31
|
+
|
|
29
32
|
### 🛹 Usage
|
|
30
33
|
|
|
31
34
|
Create `stylelint.config.mjs` in your project root
|
package/dist/index.cjs
CHANGED
|
@@ -1,115 +1,254 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const localPkg = require('local-pkg');
|
|
4
|
-
const lodashEs = require('lodash-es');
|
|
5
4
|
|
|
6
5
|
const GLOB_CSS = ["*.css", "**/*.css"];
|
|
7
6
|
const GLOB_SCSS = ["*.scss", "**/*.scss"];
|
|
8
7
|
const GLOB_HTML = ["*.html", "**/*.html"];
|
|
9
8
|
const GLOB_VUE = ["*.vue", "**/*.vue"];
|
|
9
|
+
const GLOB_ALL = [
|
|
10
|
+
...GLOB_CSS,
|
|
11
|
+
...GLOB_SCSS,
|
|
12
|
+
...GLOB_HTML,
|
|
13
|
+
...GLOB_VUE
|
|
14
|
+
];
|
|
10
15
|
|
|
11
|
-
function
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
...GLOB_HTML,
|
|
19
|
-
...GLOB_VUE
|
|
20
|
-
],
|
|
21
|
-
extends: [
|
|
22
|
-
"stylelint-config-standard",
|
|
23
|
-
"stylelint-config-recess-order"
|
|
24
|
-
],
|
|
25
|
-
rules: {
|
|
26
|
-
"alpha-value-notation": "number",
|
|
27
|
-
"color-function-notation": "legacy",
|
|
28
|
-
"color-hex-length": "long",
|
|
29
|
-
"declaration-block-no-redundant-longhand-properties": [
|
|
30
|
-
true,
|
|
31
|
-
{
|
|
32
|
-
ignoreShorthands: [
|
|
33
|
-
"inset"
|
|
34
|
-
]
|
|
35
|
-
}
|
|
36
|
-
],
|
|
37
|
-
"declaration-property-value-no-unknown": null,
|
|
38
|
-
"font-family-no-missing-generic-family-keyword": null,
|
|
39
|
-
"length-zero-no-unit": [
|
|
40
|
-
true,
|
|
41
|
-
{
|
|
42
|
-
ignore: ["custom-properties"],
|
|
43
|
-
ignoreFunctions: ["/^--/", "var"]
|
|
44
|
-
}
|
|
16
|
+
function core(options = {}) {
|
|
17
|
+
return [
|
|
18
|
+
{
|
|
19
|
+
name: "xiaohe/core/rules",
|
|
20
|
+
files: GLOB_ALL,
|
|
21
|
+
extends: [
|
|
22
|
+
"stylelint-config-recess-order"
|
|
45
23
|
],
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
24
|
+
rules: {
|
|
25
|
+
"alpha-value-notation": "number",
|
|
26
|
+
"annotation-no-unknown": true,
|
|
27
|
+
"at-rule-descriptor-no-unknown": true,
|
|
28
|
+
"at-rule-descriptor-value-no-unknown": true,
|
|
29
|
+
"at-rule-no-deprecated": true,
|
|
30
|
+
"at-rule-no-unknown": true,
|
|
31
|
+
"at-rule-prelude-no-invalid": [
|
|
32
|
+
true,
|
|
33
|
+
{
|
|
34
|
+
ignoreAtRules: [
|
|
35
|
+
"media"
|
|
36
|
+
]
|
|
52
37
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
38
|
+
],
|
|
39
|
+
"block-no-empty": true,
|
|
40
|
+
"color-function-notation": "legacy",
|
|
41
|
+
"color-hex-length": "long",
|
|
42
|
+
"comment-no-empty": true,
|
|
43
|
+
"custom-property-no-missing-var-function": true,
|
|
44
|
+
"declaration-block-no-duplicate-custom-properties": true,
|
|
45
|
+
"declaration-block-no-duplicate-properties": [
|
|
46
|
+
true,
|
|
47
|
+
{
|
|
48
|
+
ignore: [
|
|
49
|
+
"consecutive-duplicates-with-different-syntaxes"
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"declaration-block-no-redundant-longhand-properties": [
|
|
54
|
+
true,
|
|
55
|
+
{
|
|
56
|
+
ignoreShorthands: [
|
|
57
|
+
"inset"
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"declaration-block-no-shorthand-property-overrides": true,
|
|
62
|
+
"declaration-property-value-keyword-no-deprecated": true,
|
|
63
|
+
"font-family-no-duplicate-names": true,
|
|
64
|
+
"function-calc-no-unspaced-operator": true,
|
|
65
|
+
"keyframe-block-no-duplicate-selectors": true,
|
|
66
|
+
"keyframe-declaration-no-important": true,
|
|
67
|
+
"length-zero-no-unit": [
|
|
68
|
+
true,
|
|
69
|
+
{
|
|
70
|
+
ignore: [
|
|
71
|
+
"custom-properties"
|
|
72
|
+
],
|
|
73
|
+
ignoreFunctions: [
|
|
74
|
+
"/^--/",
|
|
75
|
+
"var"
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
"media-feature-name-no-unknown": true,
|
|
80
|
+
"media-feature-name-value-no-unknown": true,
|
|
81
|
+
"media-query-no-invalid": true,
|
|
82
|
+
"named-grid-areas-no-invalid": true,
|
|
83
|
+
"no-descending-specificity": true,
|
|
84
|
+
"no-duplicate-at-import-rules": true,
|
|
85
|
+
"no-duplicate-selectors": true,
|
|
86
|
+
"no-invalid-double-slash-comments": true,
|
|
87
|
+
"no-invalid-position-at-import-rule": true,
|
|
88
|
+
"no-irregular-whitespace": true,
|
|
89
|
+
"property-no-unknown": true,
|
|
90
|
+
"selector-anb-no-unmatchable": true,
|
|
91
|
+
"selector-class-pattern": [
|
|
92
|
+
"^([#a-z][$#{}a-z0-9]*)((-{1,2}|_{2})[$#{}a-z0-9]+)*$",
|
|
93
|
+
{
|
|
94
|
+
message(selector) {
|
|
95
|
+
return `Expected class selector "${selector}" to be the BEM style (block-element[__element][--modifier]).`;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
"selector-not-notation": "simple",
|
|
100
|
+
"selector-pseudo-class-no-unknown": true,
|
|
101
|
+
"selector-pseudo-element-no-unknown": true,
|
|
102
|
+
"string-no-newline": [
|
|
103
|
+
true,
|
|
104
|
+
{
|
|
105
|
+
ignore: [
|
|
106
|
+
"at-rule-preludes",
|
|
107
|
+
"declaration-values"
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
...options.overrides
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
];
|
|
61
115
|
}
|
|
62
116
|
|
|
63
|
-
function css(
|
|
64
|
-
return
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
117
|
+
function css(options = {}) {
|
|
118
|
+
return [
|
|
119
|
+
{
|
|
120
|
+
name: "xiaohe/css/rules",
|
|
121
|
+
files: GLOB_CSS,
|
|
122
|
+
rules: {
|
|
123
|
+
...options.overrides
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
];
|
|
71
127
|
}
|
|
72
128
|
|
|
73
|
-
function html(
|
|
74
|
-
return
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
129
|
+
function html(options = {}) {
|
|
130
|
+
return [
|
|
131
|
+
{
|
|
132
|
+
name: "xiaohe/html/setup",
|
|
133
|
+
files: GLOB_HTML,
|
|
134
|
+
customSyntax: "postcss-html"
|
|
79
135
|
},
|
|
80
|
-
|
|
81
|
-
|
|
136
|
+
{
|
|
137
|
+
name: "xiaohe/html/rules",
|
|
138
|
+
files: GLOB_HTML,
|
|
139
|
+
rules: {
|
|
140
|
+
...options.overrides
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
];
|
|
82
144
|
}
|
|
83
145
|
|
|
84
|
-
function scss(
|
|
85
|
-
return
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
"
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
],
|
|
94
|
-
rules: {
|
|
95
|
-
...config.rules
|
|
146
|
+
function scss(options = {}) {
|
|
147
|
+
return [
|
|
148
|
+
{
|
|
149
|
+
name: "xiaohe/scss/setup",
|
|
150
|
+
files: GLOB_SCSS,
|
|
151
|
+
customSyntax: "postcss-scss",
|
|
152
|
+
plugins: [
|
|
153
|
+
"stylelint-scss"
|
|
154
|
+
]
|
|
96
155
|
},
|
|
97
|
-
|
|
98
|
-
|
|
156
|
+
{
|
|
157
|
+
name: "xiaohe/scss/rules",
|
|
158
|
+
files: GLOB_SCSS,
|
|
159
|
+
rules: {
|
|
160
|
+
"annotation-no-unknown": null,
|
|
161
|
+
"at-rule-no-unknown": null,
|
|
162
|
+
"comment-no-empty": null,
|
|
163
|
+
"function-no-unknown": null,
|
|
164
|
+
"media-query-no-invalid": null,
|
|
165
|
+
"no-invalid-position-at-import-rule": [
|
|
166
|
+
true,
|
|
167
|
+
{
|
|
168
|
+
ignoreAtRules: [
|
|
169
|
+
"use",
|
|
170
|
+
"forward"
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
],
|
|
174
|
+
"scss/at-extend-no-missing-placeholder": true,
|
|
175
|
+
"scss/at-if-no-null": true,
|
|
176
|
+
"scss/at-rule-no-unknown": true,
|
|
177
|
+
"scss/comment-no-empty": true,
|
|
178
|
+
"scss/declaration-nested-properties-no-divided-groups": true,
|
|
179
|
+
"scss/dollar-variable-no-missing-interpolation": true,
|
|
180
|
+
"scss/function-quote-no-quoted-strings-inside": true,
|
|
181
|
+
"scss/function-unquote-no-unquoted-strings-inside": true,
|
|
182
|
+
"scss/load-no-partial-leading-underscore": true,
|
|
183
|
+
"scss/load-partial-extension": "never",
|
|
184
|
+
"scss/no-duplicate-mixins": true,
|
|
185
|
+
"scss/no-global-function-names": true,
|
|
186
|
+
"scss/operator-no-newline-after": true,
|
|
187
|
+
"scss/operator-no-newline-before": true,
|
|
188
|
+
"scss/operator-no-unspaced": true,
|
|
189
|
+
...options.overrides
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
];
|
|
99
193
|
}
|
|
100
194
|
|
|
101
|
-
function vue(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
195
|
+
function vue(options = {}) {
|
|
196
|
+
const {
|
|
197
|
+
scss = false
|
|
198
|
+
} = options;
|
|
199
|
+
return [
|
|
200
|
+
{
|
|
201
|
+
name: "xiaohe/vue/setup",
|
|
202
|
+
files: GLOB_VUE,
|
|
203
|
+
customSyntax: "postcss-html"
|
|
110
204
|
},
|
|
111
|
-
|
|
112
|
-
|
|
205
|
+
{
|
|
206
|
+
name: "xiaohe/vue/rules",
|
|
207
|
+
files: GLOB_VUE,
|
|
208
|
+
rules: {
|
|
209
|
+
"declaration-property-value-no-unknown": [
|
|
210
|
+
true,
|
|
211
|
+
{
|
|
212
|
+
ignoreProperties: {
|
|
213
|
+
"/.*/": "/v-bind\\(.+\\)/"
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
],
|
|
217
|
+
"function-no-unknown": [
|
|
218
|
+
true,
|
|
219
|
+
{
|
|
220
|
+
ignoreFunctions: [
|
|
221
|
+
"v-bind"
|
|
222
|
+
]
|
|
223
|
+
}
|
|
224
|
+
],
|
|
225
|
+
"selector-pseudo-class-no-unknown": [
|
|
226
|
+
true,
|
|
227
|
+
{
|
|
228
|
+
ignorePseudoClasses: [
|
|
229
|
+
"deep",
|
|
230
|
+
"global",
|
|
231
|
+
"slotted"
|
|
232
|
+
]
|
|
233
|
+
}
|
|
234
|
+
],
|
|
235
|
+
"selector-pseudo-element-no-unknown": [
|
|
236
|
+
true,
|
|
237
|
+
{
|
|
238
|
+
ignorePseudoElements: [
|
|
239
|
+
"v-deep",
|
|
240
|
+
"v-global",
|
|
241
|
+
"v-slotted"
|
|
242
|
+
]
|
|
243
|
+
}
|
|
244
|
+
],
|
|
245
|
+
...scss ? {
|
|
246
|
+
"function-no-unknown": null
|
|
247
|
+
} : {},
|
|
248
|
+
...options.overrides
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
];
|
|
113
252
|
}
|
|
114
253
|
|
|
115
254
|
const SCSS_PACKAGES = [
|
|
@@ -124,40 +263,73 @@ const VUE_PACKAGES = [
|
|
|
124
263
|
"@slidev/cli"
|
|
125
264
|
];
|
|
126
265
|
|
|
266
|
+
function castArray(value) {
|
|
267
|
+
return Array.isArray(value) ? value : [value];
|
|
268
|
+
}
|
|
127
269
|
function isPkgExists(pkg) {
|
|
128
|
-
return
|
|
270
|
+
return castArray(pkg).some((it) => localPkg.isPackageExists(it));
|
|
129
271
|
}
|
|
130
272
|
|
|
131
|
-
function
|
|
132
|
-
return typeof config === "boolean" ? {} : config || {};
|
|
133
|
-
}
|
|
134
|
-
function defineConfig(config = {}) {
|
|
273
|
+
function defineConfig(options = {}, ...userOverrides) {
|
|
135
274
|
const {
|
|
275
|
+
css: enableCss = true,
|
|
276
|
+
html: enableHtml = true,
|
|
136
277
|
scss: enableScss = isPkgExists(SCSS_PACKAGES),
|
|
137
278
|
vue: enableVue = isPkgExists(VUE_PACKAGES)
|
|
138
|
-
} =
|
|
279
|
+
} = options;
|
|
139
280
|
const overrides = [
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
281
|
+
...core({
|
|
282
|
+
overrides: getOverrides(options.core)
|
|
283
|
+
})
|
|
143
284
|
];
|
|
285
|
+
if (enableCss) {
|
|
286
|
+
overrides.push(
|
|
287
|
+
...css({
|
|
288
|
+
overrides: getOverrides(options.css)
|
|
289
|
+
})
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
if (enableHtml) {
|
|
293
|
+
overrides.push(
|
|
294
|
+
...html({
|
|
295
|
+
overrides: getOverrides(options.html)
|
|
296
|
+
})
|
|
297
|
+
);
|
|
298
|
+
}
|
|
144
299
|
if (enableScss) {
|
|
145
300
|
overrides.push(
|
|
146
|
-
scss(
|
|
301
|
+
...scss({
|
|
302
|
+
overrides: getOverrides(options.scss)
|
|
303
|
+
})
|
|
147
304
|
);
|
|
148
305
|
}
|
|
149
306
|
if (enableVue) {
|
|
150
307
|
overrides.push(
|
|
151
|
-
vue(
|
|
308
|
+
...vue({
|
|
309
|
+
overrides: getOverrides(options.vue),
|
|
310
|
+
scss: !!enableScss
|
|
311
|
+
})
|
|
152
312
|
);
|
|
153
313
|
}
|
|
154
|
-
|
|
155
|
-
overrides.push(...config.overrides);
|
|
156
|
-
}
|
|
314
|
+
overrides.push(...userOverrides);
|
|
157
315
|
return {
|
|
316
|
+
defaultSeverity: "error",
|
|
317
|
+
allowEmptyInput: true,
|
|
158
318
|
overrides,
|
|
159
|
-
rules: {}
|
|
319
|
+
rules: {},
|
|
320
|
+
...options
|
|
160
321
|
};
|
|
161
322
|
}
|
|
323
|
+
function getOverrides(options) {
|
|
324
|
+
if (options == null || typeof options === "boolean") {
|
|
325
|
+
return {};
|
|
326
|
+
}
|
|
327
|
+
return options.overrides || {};
|
|
328
|
+
}
|
|
162
329
|
|
|
330
|
+
exports.GLOB_ALL = GLOB_ALL;
|
|
331
|
+
exports.GLOB_CSS = GLOB_CSS;
|
|
332
|
+
exports.GLOB_HTML = GLOB_HTML;
|
|
333
|
+
exports.GLOB_SCSS = GLOB_SCSS;
|
|
334
|
+
exports.GLOB_VUE = GLOB_VUE;
|
|
163
335
|
exports.defineConfig = defineConfig;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,23 +1,50 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { Config } from 'stylelint';
|
|
3
2
|
|
|
4
3
|
type ConfigOverride = Omit<Config, "overrides"> & {
|
|
5
4
|
files: string | string[];
|
|
6
5
|
name?: string;
|
|
7
6
|
};
|
|
8
|
-
type
|
|
9
|
-
interface
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
type ConfigRules = Config["rules"];
|
|
8
|
+
interface OptionsOverrides {
|
|
9
|
+
overrides?: ConfigRules;
|
|
10
|
+
}
|
|
11
|
+
interface OptionsConfig {
|
|
12
|
+
/**
|
|
13
|
+
* Core rules. Can't be disabled.
|
|
14
|
+
*/
|
|
15
|
+
core?: OptionsOverrides;
|
|
16
|
+
/**
|
|
17
|
+
* Enable CSS support.
|
|
18
|
+
*
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
21
|
+
css?: boolean | OptionsOverrides;
|
|
22
|
+
/**
|
|
23
|
+
* Enable HTML support.
|
|
24
|
+
*
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
html?: boolean | OptionsOverrides;
|
|
28
|
+
/**
|
|
29
|
+
* Enable Scss support.
|
|
30
|
+
*
|
|
31
|
+
* @default auto-detect based on the dependencies
|
|
32
|
+
*/
|
|
33
|
+
scss?: boolean | OptionsOverrides;
|
|
34
|
+
/**
|
|
35
|
+
* Enable Vue support.
|
|
36
|
+
*
|
|
37
|
+
* @default auto-detect based on the dependencies
|
|
38
|
+
*/
|
|
39
|
+
vue?: boolean | OptionsOverrides;
|
|
16
40
|
}
|
|
17
41
|
|
|
42
|
+
declare function defineConfig(options?: OptionsConfig & Omit<Config, "overrides">, ...userOverrides: ConfigOverride[]): Config;
|
|
18
43
|
|
|
44
|
+
declare const GLOB_CSS: string[];
|
|
45
|
+
declare const GLOB_SCSS: string[];
|
|
46
|
+
declare const GLOB_HTML: string[];
|
|
47
|
+
declare const GLOB_VUE: string[];
|
|
48
|
+
declare const GLOB_ALL: string[];
|
|
19
49
|
|
|
20
|
-
|
|
21
|
-
declare function defineConfig(config?: UserConfig): Config;
|
|
22
|
-
|
|
23
|
-
export { defineConfig };
|
|
50
|
+
export { GLOB_ALL, GLOB_CSS, GLOB_HTML, GLOB_SCSS, GLOB_VUE, defineConfig };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,23 +1,50 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { Config } from 'stylelint';
|
|
3
2
|
|
|
4
3
|
type ConfigOverride = Omit<Config, "overrides"> & {
|
|
5
4
|
files: string | string[];
|
|
6
5
|
name?: string;
|
|
7
6
|
};
|
|
8
|
-
type
|
|
9
|
-
interface
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
type ConfigRules = Config["rules"];
|
|
8
|
+
interface OptionsOverrides {
|
|
9
|
+
overrides?: ConfigRules;
|
|
10
|
+
}
|
|
11
|
+
interface OptionsConfig {
|
|
12
|
+
/**
|
|
13
|
+
* Core rules. Can't be disabled.
|
|
14
|
+
*/
|
|
15
|
+
core?: OptionsOverrides;
|
|
16
|
+
/**
|
|
17
|
+
* Enable CSS support.
|
|
18
|
+
*
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
21
|
+
css?: boolean | OptionsOverrides;
|
|
22
|
+
/**
|
|
23
|
+
* Enable HTML support.
|
|
24
|
+
*
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
html?: boolean | OptionsOverrides;
|
|
28
|
+
/**
|
|
29
|
+
* Enable Scss support.
|
|
30
|
+
*
|
|
31
|
+
* @default auto-detect based on the dependencies
|
|
32
|
+
*/
|
|
33
|
+
scss?: boolean | OptionsOverrides;
|
|
34
|
+
/**
|
|
35
|
+
* Enable Vue support.
|
|
36
|
+
*
|
|
37
|
+
* @default auto-detect based on the dependencies
|
|
38
|
+
*/
|
|
39
|
+
vue?: boolean | OptionsOverrides;
|
|
16
40
|
}
|
|
17
41
|
|
|
42
|
+
declare function defineConfig(options?: OptionsConfig & Omit<Config, "overrides">, ...userOverrides: ConfigOverride[]): Config;
|
|
18
43
|
|
|
44
|
+
declare const GLOB_CSS: string[];
|
|
45
|
+
declare const GLOB_SCSS: string[];
|
|
46
|
+
declare const GLOB_HTML: string[];
|
|
47
|
+
declare const GLOB_VUE: string[];
|
|
48
|
+
declare const GLOB_ALL: string[];
|
|
19
49
|
|
|
20
|
-
|
|
21
|
-
declare function defineConfig(config?: UserConfig): Config;
|
|
22
|
-
|
|
23
|
-
export { defineConfig };
|
|
50
|
+
export { GLOB_ALL, GLOB_CSS, GLOB_HTML, GLOB_SCSS, GLOB_VUE, defineConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,23 +1,50 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { Config } from 'stylelint';
|
|
3
2
|
|
|
4
3
|
type ConfigOverride = Omit<Config, "overrides"> & {
|
|
5
4
|
files: string | string[];
|
|
6
5
|
name?: string;
|
|
7
6
|
};
|
|
8
|
-
type
|
|
9
|
-
interface
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
type ConfigRules = Config["rules"];
|
|
8
|
+
interface OptionsOverrides {
|
|
9
|
+
overrides?: ConfigRules;
|
|
10
|
+
}
|
|
11
|
+
interface OptionsConfig {
|
|
12
|
+
/**
|
|
13
|
+
* Core rules. Can't be disabled.
|
|
14
|
+
*/
|
|
15
|
+
core?: OptionsOverrides;
|
|
16
|
+
/**
|
|
17
|
+
* Enable CSS support.
|
|
18
|
+
*
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
21
|
+
css?: boolean | OptionsOverrides;
|
|
22
|
+
/**
|
|
23
|
+
* Enable HTML support.
|
|
24
|
+
*
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
html?: boolean | OptionsOverrides;
|
|
28
|
+
/**
|
|
29
|
+
* Enable Scss support.
|
|
30
|
+
*
|
|
31
|
+
* @default auto-detect based on the dependencies
|
|
32
|
+
*/
|
|
33
|
+
scss?: boolean | OptionsOverrides;
|
|
34
|
+
/**
|
|
35
|
+
* Enable Vue support.
|
|
36
|
+
*
|
|
37
|
+
* @default auto-detect based on the dependencies
|
|
38
|
+
*/
|
|
39
|
+
vue?: boolean | OptionsOverrides;
|
|
16
40
|
}
|
|
17
41
|
|
|
42
|
+
declare function defineConfig(options?: OptionsConfig & Omit<Config, "overrides">, ...userOverrides: ConfigOverride[]): Config;
|
|
18
43
|
|
|
44
|
+
declare const GLOB_CSS: string[];
|
|
45
|
+
declare const GLOB_SCSS: string[];
|
|
46
|
+
declare const GLOB_HTML: string[];
|
|
47
|
+
declare const GLOB_VUE: string[];
|
|
48
|
+
declare const GLOB_ALL: string[];
|
|
19
49
|
|
|
20
|
-
|
|
21
|
-
declare function defineConfig(config?: UserConfig): Config;
|
|
22
|
-
|
|
23
|
-
export { defineConfig };
|
|
50
|
+
export { GLOB_ALL, GLOB_CSS, GLOB_HTML, GLOB_SCSS, GLOB_VUE, defineConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -1,113 +1,252 @@
|
|
|
1
1
|
import { isPackageExists } from 'local-pkg';
|
|
2
|
-
import { omit, castArray } from 'lodash-es';
|
|
3
2
|
|
|
4
3
|
const GLOB_CSS = ["*.css", "**/*.css"];
|
|
5
4
|
const GLOB_SCSS = ["*.scss", "**/*.scss"];
|
|
6
5
|
const GLOB_HTML = ["*.html", "**/*.html"];
|
|
7
6
|
const GLOB_VUE = ["*.vue", "**/*.vue"];
|
|
7
|
+
const GLOB_ALL = [
|
|
8
|
+
...GLOB_CSS,
|
|
9
|
+
...GLOB_SCSS,
|
|
10
|
+
...GLOB_HTML,
|
|
11
|
+
...GLOB_VUE
|
|
12
|
+
];
|
|
8
13
|
|
|
9
|
-
function
|
|
10
|
-
return
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
...GLOB_HTML,
|
|
17
|
-
...GLOB_VUE
|
|
18
|
-
],
|
|
19
|
-
extends: [
|
|
20
|
-
"stylelint-config-standard",
|
|
21
|
-
"stylelint-config-recess-order"
|
|
22
|
-
],
|
|
23
|
-
rules: {
|
|
24
|
-
"alpha-value-notation": "number",
|
|
25
|
-
"color-function-notation": "legacy",
|
|
26
|
-
"color-hex-length": "long",
|
|
27
|
-
"declaration-block-no-redundant-longhand-properties": [
|
|
28
|
-
true,
|
|
29
|
-
{
|
|
30
|
-
ignoreShorthands: [
|
|
31
|
-
"inset"
|
|
32
|
-
]
|
|
33
|
-
}
|
|
34
|
-
],
|
|
35
|
-
"declaration-property-value-no-unknown": null,
|
|
36
|
-
"font-family-no-missing-generic-family-keyword": null,
|
|
37
|
-
"length-zero-no-unit": [
|
|
38
|
-
true,
|
|
39
|
-
{
|
|
40
|
-
ignore: ["custom-properties"],
|
|
41
|
-
ignoreFunctions: ["/^--/", "var"]
|
|
42
|
-
}
|
|
14
|
+
function core(options = {}) {
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
name: "xiaohe/core/rules",
|
|
18
|
+
files: GLOB_ALL,
|
|
19
|
+
extends: [
|
|
20
|
+
"stylelint-config-recess-order"
|
|
43
21
|
],
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
22
|
+
rules: {
|
|
23
|
+
"alpha-value-notation": "number",
|
|
24
|
+
"annotation-no-unknown": true,
|
|
25
|
+
"at-rule-descriptor-no-unknown": true,
|
|
26
|
+
"at-rule-descriptor-value-no-unknown": true,
|
|
27
|
+
"at-rule-no-deprecated": true,
|
|
28
|
+
"at-rule-no-unknown": true,
|
|
29
|
+
"at-rule-prelude-no-invalid": [
|
|
30
|
+
true,
|
|
31
|
+
{
|
|
32
|
+
ignoreAtRules: [
|
|
33
|
+
"media"
|
|
34
|
+
]
|
|
50
35
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
36
|
+
],
|
|
37
|
+
"block-no-empty": true,
|
|
38
|
+
"color-function-notation": "legacy",
|
|
39
|
+
"color-hex-length": "long",
|
|
40
|
+
"comment-no-empty": true,
|
|
41
|
+
"custom-property-no-missing-var-function": true,
|
|
42
|
+
"declaration-block-no-duplicate-custom-properties": true,
|
|
43
|
+
"declaration-block-no-duplicate-properties": [
|
|
44
|
+
true,
|
|
45
|
+
{
|
|
46
|
+
ignore: [
|
|
47
|
+
"consecutive-duplicates-with-different-syntaxes"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"declaration-block-no-redundant-longhand-properties": [
|
|
52
|
+
true,
|
|
53
|
+
{
|
|
54
|
+
ignoreShorthands: [
|
|
55
|
+
"inset"
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"declaration-block-no-shorthand-property-overrides": true,
|
|
60
|
+
"declaration-property-value-keyword-no-deprecated": true,
|
|
61
|
+
"font-family-no-duplicate-names": true,
|
|
62
|
+
"function-calc-no-unspaced-operator": true,
|
|
63
|
+
"keyframe-block-no-duplicate-selectors": true,
|
|
64
|
+
"keyframe-declaration-no-important": true,
|
|
65
|
+
"length-zero-no-unit": [
|
|
66
|
+
true,
|
|
67
|
+
{
|
|
68
|
+
ignore: [
|
|
69
|
+
"custom-properties"
|
|
70
|
+
],
|
|
71
|
+
ignoreFunctions: [
|
|
72
|
+
"/^--/",
|
|
73
|
+
"var"
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
"media-feature-name-no-unknown": true,
|
|
78
|
+
"media-feature-name-value-no-unknown": true,
|
|
79
|
+
"media-query-no-invalid": true,
|
|
80
|
+
"named-grid-areas-no-invalid": true,
|
|
81
|
+
"no-descending-specificity": true,
|
|
82
|
+
"no-duplicate-at-import-rules": true,
|
|
83
|
+
"no-duplicate-selectors": true,
|
|
84
|
+
"no-invalid-double-slash-comments": true,
|
|
85
|
+
"no-invalid-position-at-import-rule": true,
|
|
86
|
+
"no-irregular-whitespace": true,
|
|
87
|
+
"property-no-unknown": true,
|
|
88
|
+
"selector-anb-no-unmatchable": true,
|
|
89
|
+
"selector-class-pattern": [
|
|
90
|
+
"^([#a-z][$#{}a-z0-9]*)((-{1,2}|_{2})[$#{}a-z0-9]+)*$",
|
|
91
|
+
{
|
|
92
|
+
message(selector) {
|
|
93
|
+
return `Expected class selector "${selector}" to be the BEM style (block-element[__element][--modifier]).`;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
"selector-not-notation": "simple",
|
|
98
|
+
"selector-pseudo-class-no-unknown": true,
|
|
99
|
+
"selector-pseudo-element-no-unknown": true,
|
|
100
|
+
"string-no-newline": [
|
|
101
|
+
true,
|
|
102
|
+
{
|
|
103
|
+
ignore: [
|
|
104
|
+
"at-rule-preludes",
|
|
105
|
+
"declaration-values"
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
...options.overrides
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
];
|
|
59
113
|
}
|
|
60
114
|
|
|
61
|
-
function css(
|
|
62
|
-
return
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
115
|
+
function css(options = {}) {
|
|
116
|
+
return [
|
|
117
|
+
{
|
|
118
|
+
name: "xiaohe/css/rules",
|
|
119
|
+
files: GLOB_CSS,
|
|
120
|
+
rules: {
|
|
121
|
+
...options.overrides
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
];
|
|
69
125
|
}
|
|
70
126
|
|
|
71
|
-
function html(
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
127
|
+
function html(options = {}) {
|
|
128
|
+
return [
|
|
129
|
+
{
|
|
130
|
+
name: "xiaohe/html/setup",
|
|
131
|
+
files: GLOB_HTML,
|
|
132
|
+
customSyntax: "postcss-html"
|
|
77
133
|
},
|
|
78
|
-
|
|
79
|
-
|
|
134
|
+
{
|
|
135
|
+
name: "xiaohe/html/rules",
|
|
136
|
+
files: GLOB_HTML,
|
|
137
|
+
rules: {
|
|
138
|
+
...options.overrides
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
];
|
|
80
142
|
}
|
|
81
143
|
|
|
82
|
-
function scss(
|
|
83
|
-
return
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
"
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
],
|
|
92
|
-
rules: {
|
|
93
|
-
...config.rules
|
|
144
|
+
function scss(options = {}) {
|
|
145
|
+
return [
|
|
146
|
+
{
|
|
147
|
+
name: "xiaohe/scss/setup",
|
|
148
|
+
files: GLOB_SCSS,
|
|
149
|
+
customSyntax: "postcss-scss",
|
|
150
|
+
plugins: [
|
|
151
|
+
"stylelint-scss"
|
|
152
|
+
]
|
|
94
153
|
},
|
|
95
|
-
|
|
96
|
-
|
|
154
|
+
{
|
|
155
|
+
name: "xiaohe/scss/rules",
|
|
156
|
+
files: GLOB_SCSS,
|
|
157
|
+
rules: {
|
|
158
|
+
"annotation-no-unknown": null,
|
|
159
|
+
"at-rule-no-unknown": null,
|
|
160
|
+
"comment-no-empty": null,
|
|
161
|
+
"function-no-unknown": null,
|
|
162
|
+
"media-query-no-invalid": null,
|
|
163
|
+
"no-invalid-position-at-import-rule": [
|
|
164
|
+
true,
|
|
165
|
+
{
|
|
166
|
+
ignoreAtRules: [
|
|
167
|
+
"use",
|
|
168
|
+
"forward"
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
],
|
|
172
|
+
"scss/at-extend-no-missing-placeholder": true,
|
|
173
|
+
"scss/at-if-no-null": true,
|
|
174
|
+
"scss/at-rule-no-unknown": true,
|
|
175
|
+
"scss/comment-no-empty": true,
|
|
176
|
+
"scss/declaration-nested-properties-no-divided-groups": true,
|
|
177
|
+
"scss/dollar-variable-no-missing-interpolation": true,
|
|
178
|
+
"scss/function-quote-no-quoted-strings-inside": true,
|
|
179
|
+
"scss/function-unquote-no-unquoted-strings-inside": true,
|
|
180
|
+
"scss/load-no-partial-leading-underscore": true,
|
|
181
|
+
"scss/load-partial-extension": "never",
|
|
182
|
+
"scss/no-duplicate-mixins": true,
|
|
183
|
+
"scss/no-global-function-names": true,
|
|
184
|
+
"scss/operator-no-newline-after": true,
|
|
185
|
+
"scss/operator-no-newline-before": true,
|
|
186
|
+
"scss/operator-no-unspaced": true,
|
|
187
|
+
...options.overrides
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
];
|
|
97
191
|
}
|
|
98
192
|
|
|
99
|
-
function vue(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
193
|
+
function vue(options = {}) {
|
|
194
|
+
const {
|
|
195
|
+
scss = false
|
|
196
|
+
} = options;
|
|
197
|
+
return [
|
|
198
|
+
{
|
|
199
|
+
name: "xiaohe/vue/setup",
|
|
200
|
+
files: GLOB_VUE,
|
|
201
|
+
customSyntax: "postcss-html"
|
|
108
202
|
},
|
|
109
|
-
|
|
110
|
-
|
|
203
|
+
{
|
|
204
|
+
name: "xiaohe/vue/rules",
|
|
205
|
+
files: GLOB_VUE,
|
|
206
|
+
rules: {
|
|
207
|
+
"declaration-property-value-no-unknown": [
|
|
208
|
+
true,
|
|
209
|
+
{
|
|
210
|
+
ignoreProperties: {
|
|
211
|
+
"/.*/": "/v-bind\\(.+\\)/"
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
],
|
|
215
|
+
"function-no-unknown": [
|
|
216
|
+
true,
|
|
217
|
+
{
|
|
218
|
+
ignoreFunctions: [
|
|
219
|
+
"v-bind"
|
|
220
|
+
]
|
|
221
|
+
}
|
|
222
|
+
],
|
|
223
|
+
"selector-pseudo-class-no-unknown": [
|
|
224
|
+
true,
|
|
225
|
+
{
|
|
226
|
+
ignorePseudoClasses: [
|
|
227
|
+
"deep",
|
|
228
|
+
"global",
|
|
229
|
+
"slotted"
|
|
230
|
+
]
|
|
231
|
+
}
|
|
232
|
+
],
|
|
233
|
+
"selector-pseudo-element-no-unknown": [
|
|
234
|
+
true,
|
|
235
|
+
{
|
|
236
|
+
ignorePseudoElements: [
|
|
237
|
+
"v-deep",
|
|
238
|
+
"v-global",
|
|
239
|
+
"v-slotted"
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
],
|
|
243
|
+
...scss ? {
|
|
244
|
+
"function-no-unknown": null
|
|
245
|
+
} : {},
|
|
246
|
+
...options.overrides
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
];
|
|
111
250
|
}
|
|
112
251
|
|
|
113
252
|
const SCSS_PACKAGES = [
|
|
@@ -122,40 +261,68 @@ const VUE_PACKAGES = [
|
|
|
122
261
|
"@slidev/cli"
|
|
123
262
|
];
|
|
124
263
|
|
|
264
|
+
function castArray(value) {
|
|
265
|
+
return Array.isArray(value) ? value : [value];
|
|
266
|
+
}
|
|
125
267
|
function isPkgExists(pkg) {
|
|
126
268
|
return castArray(pkg).some((it) => isPackageExists(it));
|
|
127
269
|
}
|
|
128
270
|
|
|
129
|
-
function
|
|
130
|
-
return typeof config === "boolean" ? {} : config || {};
|
|
131
|
-
}
|
|
132
|
-
function defineConfig(config = {}) {
|
|
271
|
+
function defineConfig(options = {}, ...userOverrides) {
|
|
133
272
|
const {
|
|
273
|
+
css: enableCss = true,
|
|
274
|
+
html: enableHtml = true,
|
|
134
275
|
scss: enableScss = isPkgExists(SCSS_PACKAGES),
|
|
135
276
|
vue: enableVue = isPkgExists(VUE_PACKAGES)
|
|
136
|
-
} =
|
|
277
|
+
} = options;
|
|
137
278
|
const overrides = [
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
279
|
+
...core({
|
|
280
|
+
overrides: getOverrides(options.core)
|
|
281
|
+
})
|
|
141
282
|
];
|
|
283
|
+
if (enableCss) {
|
|
284
|
+
overrides.push(
|
|
285
|
+
...css({
|
|
286
|
+
overrides: getOverrides(options.css)
|
|
287
|
+
})
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
if (enableHtml) {
|
|
291
|
+
overrides.push(
|
|
292
|
+
...html({
|
|
293
|
+
overrides: getOverrides(options.html)
|
|
294
|
+
})
|
|
295
|
+
);
|
|
296
|
+
}
|
|
142
297
|
if (enableScss) {
|
|
143
298
|
overrides.push(
|
|
144
|
-
scss(
|
|
299
|
+
...scss({
|
|
300
|
+
overrides: getOverrides(options.scss)
|
|
301
|
+
})
|
|
145
302
|
);
|
|
146
303
|
}
|
|
147
304
|
if (enableVue) {
|
|
148
305
|
overrides.push(
|
|
149
|
-
vue(
|
|
306
|
+
...vue({
|
|
307
|
+
overrides: getOverrides(options.vue),
|
|
308
|
+
scss: !!enableScss
|
|
309
|
+
})
|
|
150
310
|
);
|
|
151
311
|
}
|
|
152
|
-
|
|
153
|
-
overrides.push(...config.overrides);
|
|
154
|
-
}
|
|
312
|
+
overrides.push(...userOverrides);
|
|
155
313
|
return {
|
|
314
|
+
defaultSeverity: "error",
|
|
315
|
+
allowEmptyInput: true,
|
|
156
316
|
overrides,
|
|
157
|
-
rules: {}
|
|
317
|
+
rules: {},
|
|
318
|
+
...options
|
|
158
319
|
};
|
|
159
320
|
}
|
|
321
|
+
function getOverrides(options) {
|
|
322
|
+
if (options == null || typeof options === "boolean") {
|
|
323
|
+
return {};
|
|
324
|
+
}
|
|
325
|
+
return options.overrides || {};
|
|
326
|
+
}
|
|
160
327
|
|
|
161
|
-
export { defineConfig };
|
|
328
|
+
export { GLOB_ALL, GLOB_CSS, GLOB_HTML, GLOB_SCSS, GLOB_VUE, defineConfig };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xiaohe01/stylelint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.2.0",
|
|
5
5
|
"description": "🤚 Stylelint config preset for xiaohe",
|
|
6
6
|
"author": "xiaohe0601 <xiaohe0601@outlook.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -37,21 +37,18 @@
|
|
|
37
37
|
"files": [
|
|
38
38
|
"dist"
|
|
39
39
|
],
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"stylelint": ">=16.13.0"
|
|
42
|
+
},
|
|
40
43
|
"dependencies": {
|
|
41
44
|
"local-pkg": "^1.1.1",
|
|
42
|
-
"lodash-es": "^4.17.21",
|
|
43
45
|
"postcss-html": "^1.8.0",
|
|
44
46
|
"postcss-scss": "^4.0.9",
|
|
45
47
|
"stylelint-config-recess-order": "^6.0.0",
|
|
46
|
-
"stylelint-config-recommended": "^15.0.0",
|
|
47
|
-
"stylelint-config-recommended-vue": "^1.6.0",
|
|
48
|
-
"stylelint-config-standard": "^37.0.0",
|
|
49
|
-
"stylelint-config-standard-scss": "^14.0.0",
|
|
50
48
|
"stylelint-order": "^6.0.4",
|
|
51
49
|
"stylelint-scss": "^6.11.1"
|
|
52
50
|
},
|
|
53
51
|
"devDependencies": {
|
|
54
|
-
"@types/lodash-es": "^4.17.12",
|
|
55
52
|
"stylelint": "^16.16.0"
|
|
56
53
|
},
|
|
57
54
|
"scripts": {
|