@xiaohe01/stylelint-config 2.3.3 → 3.0.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.d.cts CHANGED
@@ -1,54 +1,58 @@
1
- import { Config } from 'stylelint';
1
+ import { Config } from "stylelint";
2
2
 
3
- type ConfigOverride = Omit<Config, "overrides"> & {
4
- files: string | string[];
5
- name?: string;
6
- };
3
+ //#region src/types.d.ts
7
4
  type ConfigRules = Config["rules"];
8
5
  interface OptionsOverrides {
9
- overrides?: ConfigRules;
6
+ overrides?: ConfigRules;
10
7
  }
11
8
  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;
9
+ /**
10
+ * Core rules. Can't be disabled.
11
+ */
12
+ core?: OptionsOverrides;
13
+ /**
14
+ * CSS rules.
15
+ */
16
+ css?: OptionsOverrides;
17
+ /**
18
+ * Enable Scss support.
19
+ *
20
+ * @default auto-detect based on the dependencies
21
+ */
22
+ scss?: boolean | OptionsOverrides;
23
+ /**
24
+ * Enable HTML support.
25
+ *
26
+ * @default true
27
+ */
28
+ html?: boolean | OptionsOverrides;
29
+ /**
30
+ * Enable Vue support.
31
+ *
32
+ * @default auto-detect based on the dependencies
33
+ */
34
+ vue?: boolean | OptionsOverrides;
35
+ /**
36
+ * Enable uni-app support.
37
+ *
38
+ * @default auto-detect based on the dependencies
39
+ */
40
+ uni?: boolean;
44
41
  }
45
-
46
- declare function defineConfig(options?: OptionsConfig & Omit<Config, "overrides">, ...userOverrides: ConfigOverride[]): Config;
47
-
42
+ type Options = OptionsConfig & Omit<Config, "overrides">;
43
+ type ConfigOverride = Omit<Config, "overrides"> & {
44
+ files: string | string[];
45
+ name?: string;
46
+ };
47
+ //#endregion
48
+ //#region src/factory.d.ts
49
+ declare function defineConfig(options?: Options, ...userOverrides: ConfigOverride[]): Config;
50
+ //#endregion
51
+ //#region src/globs.d.ts
48
52
  declare const GLOB_CSS: string[];
49
53
  declare const GLOB_SCSS: string[];
50
54
  declare const GLOB_HTML: string[];
51
55
  declare const GLOB_VUE: string[];
52
56
  declare const GLOB_ALL: string[];
53
-
54
- export { GLOB_ALL, GLOB_CSS, GLOB_HTML, GLOB_SCSS, GLOB_VUE, defineConfig };
57
+ //#endregion
58
+ export { GLOB_ALL, GLOB_CSS, GLOB_HTML, GLOB_SCSS, GLOB_VUE, defineConfig as default, defineConfig };
package/dist/index.d.ts CHANGED
@@ -1,54 +1,58 @@
1
- import { Config } from 'stylelint';
1
+ import { Config } from "stylelint";
2
2
 
3
- type ConfigOverride = Omit<Config, "overrides"> & {
4
- files: string | string[];
5
- name?: string;
6
- };
3
+ //#region src/types.d.ts
7
4
  type ConfigRules = Config["rules"];
8
5
  interface OptionsOverrides {
9
- overrides?: ConfigRules;
6
+ overrides?: ConfigRules;
10
7
  }
11
8
  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;
9
+ /**
10
+ * Core rules. Can't be disabled.
11
+ */
12
+ core?: OptionsOverrides;
13
+ /**
14
+ * CSS rules.
15
+ */
16
+ css?: OptionsOverrides;
17
+ /**
18
+ * Enable Scss support.
19
+ *
20
+ * @default auto-detect based on the dependencies
21
+ */
22
+ scss?: boolean | OptionsOverrides;
23
+ /**
24
+ * Enable HTML support.
25
+ *
26
+ * @default true
27
+ */
28
+ html?: boolean | OptionsOverrides;
29
+ /**
30
+ * Enable Vue support.
31
+ *
32
+ * @default auto-detect based on the dependencies
33
+ */
34
+ vue?: boolean | OptionsOverrides;
35
+ /**
36
+ * Enable uni-app support.
37
+ *
38
+ * @default auto-detect based on the dependencies
39
+ */
40
+ uni?: boolean;
44
41
  }
45
-
46
- declare function defineConfig(options?: OptionsConfig & Omit<Config, "overrides">, ...userOverrides: ConfigOverride[]): Config;
47
-
42
+ type Options = OptionsConfig & Omit<Config, "overrides">;
43
+ type ConfigOverride = Omit<Config, "overrides"> & {
44
+ files: string | string[];
45
+ name?: string;
46
+ };
47
+ //#endregion
48
+ //#region src/factory.d.ts
49
+ declare function defineConfig(options?: Options, ...userOverrides: ConfigOverride[]): Config;
50
+ //#endregion
51
+ //#region src/globs.d.ts
48
52
  declare const GLOB_CSS: string[];
49
53
  declare const GLOB_SCSS: string[];
50
54
  declare const GLOB_HTML: string[];
51
55
  declare const GLOB_VUE: string[];
52
56
  declare const GLOB_ALL: string[];
53
-
54
- export { GLOB_ALL, GLOB_CSS, GLOB_HTML, GLOB_SCSS, GLOB_VUE, defineConfig };
57
+ //#endregion
58
+ export { GLOB_ALL, GLOB_CSS, GLOB_HTML, GLOB_SCSS, GLOB_VUE, defineConfig as default, defineConfig };
package/dist/index.js ADDED
@@ -0,0 +1,237 @@
1
+ import { isPackageExists } from "local-pkg";
2
+
3
+ //#region ../shared/src/constants.ts
4
+ const SCSS_PACKAGES = [
5
+ "sass",
6
+ "sass-embedded",
7
+ "node-sass"
8
+ ];
9
+ const UNI_PACKAGES = ["@dcloudio/uni-app"];
10
+ const VUE_PACKAGES = [
11
+ "vue",
12
+ "nuxt",
13
+ "vitepress",
14
+ "@slidev/cli"
15
+ ];
16
+
17
+ //#endregion
18
+ //#region ../shared/src/helpers.ts
19
+ function castArray(value) {
20
+ return Array.isArray(value) ? value : [value];
21
+ }
22
+ function isPkgExists(pkg) {
23
+ return castArray(pkg).some((it) => isPackageExists(it));
24
+ }
25
+
26
+ //#endregion
27
+ //#region src/globs.ts
28
+ const GLOB_CSS = ["*.css", "**/*.css"];
29
+ const GLOB_SCSS = ["*.scss", "**/*.scss"];
30
+ const GLOB_HTML = ["*.html", "**/*.html"];
31
+ const GLOB_VUE = ["*.vue", "**/*.vue"];
32
+ const GLOB_ALL = [
33
+ ...GLOB_CSS,
34
+ ...GLOB_SCSS,
35
+ ...GLOB_HTML,
36
+ ...GLOB_VUE
37
+ ];
38
+
39
+ //#endregion
40
+ //#region src/configs/core.ts
41
+ function core(options = {}) {
42
+ const { vue: vue$1 = false } = options;
43
+ return [{
44
+ name: "xiaohe/core/rules",
45
+ files: GLOB_ALL,
46
+ extends: ["stylelint-config-recess-order"],
47
+ rules: {
48
+ "alpha-value-notation": "number",
49
+ "annotation-no-unknown": true,
50
+ "at-rule-descriptor-no-unknown": true,
51
+ "at-rule-descriptor-value-no-unknown": true,
52
+ "at-rule-no-deprecated": true,
53
+ "at-rule-no-unknown": true,
54
+ "at-rule-prelude-no-invalid": [true, { ignoreAtRules: ["media"] }],
55
+ "block-no-empty": true,
56
+ "color-function-notation": "legacy",
57
+ "color-hex-length": "long",
58
+ "comment-no-empty": true,
59
+ "custom-property-no-missing-var-function": true,
60
+ "declaration-block-no-duplicate-custom-properties": true,
61
+ "declaration-block-no-duplicate-properties": [true, { ignore: ["consecutive-duplicates-with-different-syntaxes"] }],
62
+ "declaration-block-no-redundant-longhand-properties": [true, { ignoreShorthands: ["inset"] }],
63
+ "declaration-block-no-shorthand-property-overrides": true,
64
+ "declaration-property-value-keyword-no-deprecated": true,
65
+ "font-family-no-duplicate-names": true,
66
+ "function-calc-no-unspaced-operator": true,
67
+ "keyframe-block-no-duplicate-selectors": true,
68
+ "keyframe-declaration-no-important": true,
69
+ "length-zero-no-unit": [true, {
70
+ ignore: ["custom-properties"],
71
+ ignoreFunctions: ["/^--/", "var"]
72
+ }],
73
+ "media-feature-name-no-unknown": true,
74
+ "media-feature-name-value-no-unknown": true,
75
+ "media-query-no-invalid": true,
76
+ "named-grid-areas-no-invalid": true,
77
+ "no-descending-specificity": true,
78
+ "no-duplicate-at-import-rules": true,
79
+ "no-duplicate-selectors": true,
80
+ "no-invalid-double-slash-comments": true,
81
+ "no-invalid-position-at-import-rule": true,
82
+ "no-irregular-whitespace": true,
83
+ "property-no-unknown": true,
84
+ "selector-anb-no-unmatchable": true,
85
+ "selector-class-pattern": ["^([#a-z][$#{}a-z0-9]*)((-{1,2}|_{2})[$#{}a-z0-9]+)*$", { message(selector) {
86
+ return `Expected class selector "${selector}" to be the BEM style (block-element[__element][--modifier]).`;
87
+ } }],
88
+ "selector-not-notation": "simple",
89
+ "selector-pseudo-class-no-unknown": true,
90
+ "selector-pseudo-element-no-unknown": true,
91
+ "string-no-newline": [true, { ignore: ["at-rule-preludes", "declaration-values"] }],
92
+ ...vue$1 ? {
93
+ "selector-pseudo-class-no-unknown": [true, { ignorePseudoClasses: [
94
+ "deep",
95
+ "global",
96
+ "slotted"
97
+ ] }],
98
+ "selector-pseudo-element-no-unknown": [true, { ignorePseudoElements: [
99
+ "v-deep",
100
+ "v-global",
101
+ "v-slotted"
102
+ ] }]
103
+ } : {},
104
+ ...options.overrides
105
+ }
106
+ }];
107
+ }
108
+
109
+ //#endregion
110
+ //#region src/configs/css.ts
111
+ function css(options = {}) {
112
+ return [{
113
+ name: "xiaohe/css/rules",
114
+ files: GLOB_CSS,
115
+ rules: { ...options.overrides }
116
+ }];
117
+ }
118
+
119
+ //#endregion
120
+ //#region src/configs/html.ts
121
+ function html(options = {}) {
122
+ return [{
123
+ name: "xiaohe/html/rules",
124
+ files: GLOB_HTML,
125
+ rules: { ...options.overrides }
126
+ }];
127
+ }
128
+
129
+ //#endregion
130
+ //#region src/configs/scss.ts
131
+ function scss(options = {}) {
132
+ const { vue: vue$1 = false, uni = false } = options;
133
+ return [{
134
+ name: "xiaohe/scss/rules",
135
+ files: [...GLOB_SCSS, ...vue$1 ? GLOB_VUE : []],
136
+ rules: {
137
+ "annotation-no-unknown": null,
138
+ "at-rule-no-unknown": null,
139
+ "comment-no-empty": null,
140
+ "function-no-unknown": null,
141
+ "media-query-no-invalid": null,
142
+ "no-invalid-position-at-import-rule": [true, { ignoreAtRules: ["use", "forward"] }],
143
+ "scss/at-extend-no-missing-placeholder": true,
144
+ "scss/at-if-no-null": true,
145
+ "scss/at-rule-no-unknown": true,
146
+ "scss/comment-no-empty": true,
147
+ "scss/declaration-nested-properties-no-divided-groups": true,
148
+ "scss/dollar-variable-no-missing-interpolation": true,
149
+ "scss/function-quote-no-quoted-strings-inside": true,
150
+ "scss/function-unquote-no-unquoted-strings-inside": true,
151
+ "scss/load-no-partial-leading-underscore": true,
152
+ "scss/load-partial-extension": "never",
153
+ "scss/no-duplicate-mixins": true,
154
+ "scss/no-global-function-names": true,
155
+ "scss/operator-no-newline-after": true,
156
+ "scss/operator-no-newline-before": true,
157
+ "scss/operator-no-unspaced": true,
158
+ ...uni ? { "scss/load-partial-extension": "always" } : {},
159
+ ...options.overrides
160
+ }
161
+ }];
162
+ }
163
+
164
+ //#endregion
165
+ //#region src/configs/setup.ts
166
+ function setup(options = {}) {
167
+ const { scss: scss$1 = false, html: html$1 = false, vue: vue$1 = false } = options;
168
+ const overrides = [];
169
+ if (html$1) overrides.push({
170
+ name: "xiaohe/html/setup",
171
+ files: GLOB_HTML,
172
+ customSyntax: "postcss-html"
173
+ });
174
+ if (vue$1) overrides.push({
175
+ name: "xiaohe/vue/setup",
176
+ files: GLOB_VUE,
177
+ customSyntax: "postcss-html",
178
+ plugins: [...scss$1 ? ["stylelint-scss"] : []]
179
+ });
180
+ if (scss$1) overrides.push({
181
+ name: "xiaohe/scss/setup",
182
+ files: GLOB_SCSS,
183
+ customSyntax: "postcss-scss",
184
+ plugins: ["stylelint-scss"]
185
+ });
186
+ return overrides;
187
+ }
188
+
189
+ //#endregion
190
+ //#region src/configs/vue.ts
191
+ function vue(options = {}) {
192
+ return [{
193
+ name: "xiaohe/vue/rules",
194
+ files: GLOB_VUE,
195
+ rules: { ...options.overrides }
196
+ }];
197
+ }
198
+
199
+ //#endregion
200
+ //#region src/factory.ts
201
+ function defineConfig(options = {}, ...userOverrides) {
202
+ const { scss: enableScss = isPkgExists(SCSS_PACKAGES), html: enableHtml = true, vue: enableVue = isPkgExists(VUE_PACKAGES), uni: enableUni = isPkgExists(UNI_PACKAGES) } = options;
203
+ const overrides = [
204
+ ...setup({
205
+ scss: !!enableScss,
206
+ html: !!enableHtml,
207
+ vue: !!enableVue
208
+ }),
209
+ ...core({
210
+ overrides: getOverrides(options.core),
211
+ vue: !!enableVue
212
+ }),
213
+ ...css({ overrides: getOverrides(options.css) })
214
+ ];
215
+ if (enableScss) overrides.push(...scss({
216
+ overrides: getOverrides(options.scss),
217
+ vue: !!enableVue,
218
+ uni: enableUni
219
+ }));
220
+ if (enableHtml) overrides.push(...html({ overrides: getOverrides(options.html) }));
221
+ if (enableVue) overrides.push(...vue({ overrides: getOverrides(options.vue) }));
222
+ overrides.push(...userOverrides);
223
+ return {
224
+ defaultSeverity: "error",
225
+ allowEmptyInput: true,
226
+ overrides,
227
+ rules: {},
228
+ ...options
229
+ };
230
+ }
231
+ function getOverrides(options) {
232
+ if (options == null || typeof options === "boolean") return {};
233
+ return options.overrides || {};
234
+ }
235
+
236
+ //#endregion
237
+ export { GLOB_ALL, GLOB_CSS, GLOB_HTML, GLOB_SCSS, GLOB_VUE, defineConfig as default, defineConfig };
package/package.json CHANGED
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "@xiaohe01/stylelint-config",
3
3
  "type": "module",
4
- "version": "2.3.3",
5
- "description": "🤚 Stylelint config preset for xiaohe",
4
+ "version": "3.0.0",
5
+ "description": "🤚 Xiaohe's Stylelint config preset",
6
6
  "author": "xiaohe0601 <xiaohe0601@outlook.com>",
7
7
  "license": "MIT",
8
- "homepage": "https://github.com/xiaohe0601/xiaohe-stylelint-config#readme",
8
+ "homepage": "https://github.com/xiaohe0601/xiaohe-config/tree/main/packages/stylelint-config",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "git+https://github.com/xiaohe0601/xiaohe-stylelint-config.git"
11
+ "url": "git+https://github.com/xiaohe0601/xiaohe-config.git",
12
+ "directory": "packages/stylelint-config"
12
13
  },
13
- "bugs": "https://github.com/xiaohe0601/xiaohe-stylelint-config/issues",
14
+ "bugs": "https://github.com/xiaohe0601/xiaohe-config/issues",
14
15
  "keywords": [
15
16
  "stylelint-config"
16
17
  ],
@@ -18,22 +19,14 @@
18
19
  "exports": {
19
20
  ".": {
20
21
  "types": "./dist/index.d.ts",
21
- "import": "./dist/index.mjs",
22
+ "import": "./dist/index.js",
22
23
  "require": "./dist/index.cjs"
23
24
  },
24
25
  "./*": "./*"
25
26
  },
26
- "main": "./dist/index.mjs",
27
- "module": "./dist/index.mjs",
27
+ "main": "./dist/index.js",
28
+ "module": "./dist/index.js",
28
29
  "types": "./dist/index.d.ts",
29
- "typesVersions": {
30
- "*": {
31
- "*": [
32
- "./dist/*",
33
- "./dist/index.d.ts"
34
- ]
35
- }
36
- },
37
30
  "files": [
38
31
  "dist"
39
32
  ],
@@ -41,17 +34,20 @@
41
34
  "stylelint": ">=16.13.0"
42
35
  },
43
36
  "dependencies": {
44
- "local-pkg": "^1.1.1",
37
+ "local-pkg": "^1.1.2",
45
38
  "postcss-html": "^1.8.0",
46
39
  "postcss-scss": "^4.0.9",
47
- "stylelint-config-recess-order": "^7.1.0",
40
+ "stylelint-config-recess-order": "^7.4.0",
48
41
  "stylelint-order": "^7.0.0",
49
42
  "stylelint-scss": "^6.12.1"
50
43
  },
51
44
  "devDependencies": {
52
- "stylelint": "^16.21.0"
45
+ "stylelint": "^16.25.0",
46
+ "@xiaohe-config/shared": "^0.0.0"
53
47
  },
54
48
  "scripts": {
55
- "build": "unbuild"
49
+ "dev": "tsdown --watch",
50
+ "build": "tsdown",
51
+ "release": "bumpp"
56
52
  }
57
53
  }
package/dist/index.d.mts DELETED
@@ -1,54 +0,0 @@
1
- import { Config } from 'stylelint';
2
-
3
- type ConfigOverride = Omit<Config, "overrides"> & {
4
- files: string | string[];
5
- name?: string;
6
- };
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
- * 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;
44
- }
45
-
46
- declare function defineConfig(options?: OptionsConfig & Omit<Config, "overrides">, ...userOverrides: ConfigOverride[]): Config;
47
-
48
- declare const GLOB_CSS: string[];
49
- declare const GLOB_SCSS: string[];
50
- declare const GLOB_HTML: string[];
51
- declare const GLOB_VUE: string[];
52
- declare const GLOB_ALL: string[];
53
-
54
- export { GLOB_ALL, GLOB_CSS, GLOB_HTML, GLOB_SCSS, GLOB_VUE, defineConfig };