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