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