@xiaohe01/stylelint-config 2.3.2 → 2.4.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/dist/index.mjs DELETED
@@ -1,348 +0,0 @@
1
- import { isPackageExists } from 'local-pkg';
2
-
3
- const GLOB_CSS = ["*.css", "**/*.css"];
4
- const GLOB_SCSS = ["*.scss", "**/*.scss"];
5
- const GLOB_HTML = ["*.html", "**/*.html"];
6
- const GLOB_VUE = ["*.vue", "**/*.vue"];
7
- const GLOB_ALL = [
8
- ...GLOB_CSS,
9
- ...GLOB_SCSS,
10
- ...GLOB_HTML,
11
- ...GLOB_VUE
12
- ];
13
-
14
- function core(options = {}) {
15
- const {
16
- vue = false
17
- } = options;
18
- return [
19
- {
20
- name: "xiaohe/core/rules",
21
- files: GLOB_ALL,
22
- extends: [
23
- "stylelint-config-recess-order"
24
- ],
25
- rules: {
26
- "alpha-value-notation": "number",
27
- "annotation-no-unknown": true,
28
- "at-rule-descriptor-no-unknown": true,
29
- "at-rule-descriptor-value-no-unknown": true,
30
- "at-rule-no-deprecated": true,
31
- "at-rule-no-unknown": true,
32
- "at-rule-prelude-no-invalid": [
33
- true,
34
- {
35
- ignoreAtRules: [
36
- "media"
37
- ]
38
- }
39
- ],
40
- "block-no-empty": true,
41
- "color-function-notation": "legacy",
42
- "color-hex-length": "long",
43
- "comment-no-empty": true,
44
- "custom-property-no-missing-var-function": true,
45
- "declaration-block-no-duplicate-custom-properties": true,
46
- "declaration-block-no-duplicate-properties": [
47
- true,
48
- {
49
- ignore: [
50
- "consecutive-duplicates-with-different-syntaxes"
51
- ]
52
- }
53
- ],
54
- "declaration-block-no-redundant-longhand-properties": [
55
- true,
56
- {
57
- ignoreShorthands: [
58
- "inset"
59
- ]
60
- }
61
- ],
62
- "declaration-block-no-shorthand-property-overrides": true,
63
- "declaration-property-value-keyword-no-deprecated": true,
64
- "font-family-no-duplicate-names": true,
65
- "function-calc-no-unspaced-operator": true,
66
- "keyframe-block-no-duplicate-selectors": true,
67
- "keyframe-declaration-no-important": true,
68
- "length-zero-no-unit": [
69
- true,
70
- {
71
- ignore: [
72
- "custom-properties"
73
- ],
74
- ignoreFunctions: [
75
- "/^--/",
76
- "var"
77
- ]
78
- }
79
- ],
80
- "media-feature-name-no-unknown": true,
81
- "media-feature-name-value-no-unknown": true,
82
- "media-query-no-invalid": true,
83
- "named-grid-areas-no-invalid": true,
84
- "no-descending-specificity": true,
85
- "no-duplicate-at-import-rules": true,
86
- "no-duplicate-selectors": true,
87
- "no-invalid-double-slash-comments": true,
88
- "no-invalid-position-at-import-rule": true,
89
- "no-irregular-whitespace": true,
90
- "property-no-unknown": true,
91
- "selector-anb-no-unmatchable": true,
92
- "selector-class-pattern": [
93
- "^([#a-z][$#{}a-z0-9]*)((-{1,2}|_{2})[$#{}a-z0-9]+)*$",
94
- {
95
- message(selector) {
96
- return `Expected class selector "${selector}" to be the BEM style (block-element[__element][--modifier]).`;
97
- }
98
- }
99
- ],
100
- "selector-not-notation": "simple",
101
- "selector-pseudo-class-no-unknown": true,
102
- "selector-pseudo-element-no-unknown": true,
103
- "string-no-newline": [
104
- true,
105
- {
106
- ignore: [
107
- "at-rule-preludes",
108
- "declaration-values"
109
- ]
110
- }
111
- ],
112
- ...vue ? {
113
- "selector-pseudo-class-no-unknown": [
114
- true,
115
- {
116
- ignorePseudoClasses: [
117
- "deep",
118
- "global",
119
- "slotted"
120
- ]
121
- }
122
- ],
123
- "selector-pseudo-element-no-unknown": [
124
- true,
125
- {
126
- ignorePseudoElements: [
127
- "v-deep",
128
- "v-global",
129
- "v-slotted"
130
- ]
131
- }
132
- ]
133
- } : {},
134
- ...options.overrides
135
- }
136
- }
137
- ];
138
- }
139
-
140
- function css(options = {}) {
141
- return [
142
- {
143
- name: "xiaohe/css/rules",
144
- files: GLOB_CSS,
145
- rules: {
146
- ...options.overrides
147
- }
148
- }
149
- ];
150
- }
151
-
152
- function html(options = {}) {
153
- return [
154
- {
155
- name: "xiaohe/html/rules",
156
- files: GLOB_HTML,
157
- rules: {
158
- ...options.overrides
159
- }
160
- }
161
- ];
162
- }
163
-
164
- function scss(options = {}) {
165
- const {
166
- vue = false,
167
- uniapp = false
168
- } = options;
169
- return [
170
- {
171
- name: "xiaohe/scss/rules",
172
- files: [
173
- ...GLOB_SCSS,
174
- ...vue ? GLOB_VUE : []
175
- ],
176
- rules: {
177
- "annotation-no-unknown": null,
178
- "at-rule-no-unknown": null,
179
- "comment-no-empty": null,
180
- "function-no-unknown": null,
181
- "media-query-no-invalid": null,
182
- "no-invalid-position-at-import-rule": [
183
- true,
184
- {
185
- ignoreAtRules: [
186
- "use",
187
- "forward"
188
- ]
189
- }
190
- ],
191
- "scss/at-extend-no-missing-placeholder": true,
192
- "scss/at-if-no-null": true,
193
- "scss/at-rule-no-unknown": true,
194
- "scss/comment-no-empty": true,
195
- "scss/declaration-nested-properties-no-divided-groups": true,
196
- "scss/dollar-variable-no-missing-interpolation": true,
197
- "scss/function-quote-no-quoted-strings-inside": true,
198
- "scss/function-unquote-no-unquoted-strings-inside": true,
199
- "scss/load-no-partial-leading-underscore": true,
200
- "scss/load-partial-extension": "never",
201
- "scss/no-duplicate-mixins": true,
202
- "scss/no-global-function-names": true,
203
- "scss/operator-no-newline-after": true,
204
- "scss/operator-no-newline-before": true,
205
- "scss/operator-no-unspaced": true,
206
- ...uniapp ? {
207
- "scss/load-partial-extension": "always"
208
- } : {},
209
- ...options.overrides
210
- }
211
- }
212
- ];
213
- }
214
-
215
- function setup(options = {}) {
216
- const {
217
- scss = false,
218
- html = false,
219
- vue = false
220
- } = options;
221
- const overrides = [];
222
- if (html) {
223
- overrides.push({
224
- name: "xiaohe/html/setup",
225
- files: GLOB_HTML,
226
- customSyntax: "postcss-html"
227
- });
228
- }
229
- if (vue) {
230
- overrides.push({
231
- name: "xiaohe/vue/setup",
232
- files: GLOB_VUE,
233
- customSyntax: "postcss-html",
234
- plugins: [
235
- ...scss ? [
236
- "stylelint-scss"
237
- ] : []
238
- ]
239
- });
240
- }
241
- if (scss) {
242
- overrides.push({
243
- name: "xiaohe/scss/setup",
244
- files: GLOB_SCSS,
245
- customSyntax: "postcss-scss",
246
- plugins: [
247
- "stylelint-scss"
248
- ]
249
- });
250
- }
251
- return overrides;
252
- }
253
-
254
- function vue(options = {}) {
255
- return [
256
- {
257
- name: "xiaohe/vue/rules",
258
- files: GLOB_VUE,
259
- rules: {
260
- ...options.overrides
261
- }
262
- }
263
- ];
264
- }
265
-
266
- const SCSS_PACKAGES = [
267
- "sass",
268
- "sass-embedded",
269
- "node-sass"
270
- ];
271
- const VUE_PACKAGES = [
272
- "vue",
273
- "nuxt",
274
- "vitepress",
275
- "@slidev/cli"
276
- ];
277
- const UNIAPP_PACKAGES = [
278
- "@dcloudio/uni-app"
279
- ];
280
-
281
- function castArray(value) {
282
- return Array.isArray(value) ? value : [value];
283
- }
284
- function isPkgExists(pkg) {
285
- return castArray(pkg).some((it) => isPackageExists(it));
286
- }
287
-
288
- function defineConfig(options = {}, ...userOverrides) {
289
- const {
290
- scss: enableScss = isPkgExists(SCSS_PACKAGES),
291
- html: enableHtml = true,
292
- vue: enableVue = isPkgExists(VUE_PACKAGES),
293
- uniapp: enableUniApp = isPkgExists(UNIAPP_PACKAGES)
294
- } = options;
295
- const overrides = [
296
- ...setup({
297
- scss: !!enableScss,
298
- html: !!enableHtml,
299
- vue: !!enableVue
300
- }),
301
- ...core({
302
- overrides: getOverrides(options.core),
303
- vue: !!enableVue
304
- }),
305
- ...css({
306
- overrides: getOverrides(options.css)
307
- })
308
- ];
309
- if (enableScss) {
310
- overrides.push(
311
- ...scss({
312
- overrides: getOverrides(options.scss),
313
- vue: !!enableVue,
314
- uniapp: enableUniApp
315
- })
316
- );
317
- }
318
- if (enableHtml) {
319
- overrides.push(
320
- ...html({
321
- overrides: getOverrides(options.html)
322
- })
323
- );
324
- }
325
- if (enableVue) {
326
- overrides.push(
327
- ...vue({
328
- overrides: getOverrides(options.vue)
329
- })
330
- );
331
- }
332
- overrides.push(...userOverrides);
333
- return {
334
- defaultSeverity: "error",
335
- allowEmptyInput: true,
336
- overrides,
337
- rules: {},
338
- ...options
339
- };
340
- }
341
- function getOverrides(options) {
342
- if (options == null || typeof options === "boolean") {
343
- return {};
344
- }
345
- return options.overrides || {};
346
- }
347
-
348
- export { GLOB_ALL, GLOB_CSS, GLOB_HTML, GLOB_SCSS, GLOB_VUE, defineConfig };