@xiaohe01/stylelint-config 2.0.0 → 2.1.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 +3 -0
- package/dist/index.cjs +127 -108
- package/dist/index.d.cts +42 -10
- package/dist/index.d.mts +42 -10
- package/dist/index.d.ts +42 -10
- package/dist/index.mjs +122 -108
- package/package.json +3 -5
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,115 +1,115 @@
|
|
|
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
|
+
files: GLOB_ALL,
|
|
20
|
+
extends: [
|
|
21
|
+
"stylelint-config-recommended",
|
|
22
|
+
"stylelint-config-recess-order"
|
|
45
23
|
],
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
24
|
+
rules: {
|
|
25
|
+
"alpha-value-notation": "number",
|
|
26
|
+
"color-function-notation": "legacy",
|
|
27
|
+
"color-hex-length": "long",
|
|
28
|
+
"declaration-block-no-redundant-longhand-properties": [
|
|
29
|
+
true,
|
|
30
|
+
{
|
|
31
|
+
ignoreShorthands: [
|
|
32
|
+
"inset"
|
|
33
|
+
]
|
|
52
34
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
35
|
+
],
|
|
36
|
+
"declaration-property-value-no-unknown": null,
|
|
37
|
+
"font-family-no-missing-generic-family-keyword": null,
|
|
38
|
+
"length-zero-no-unit": [
|
|
39
|
+
true,
|
|
40
|
+
{
|
|
41
|
+
ignore: ["custom-properties"],
|
|
42
|
+
ignoreFunctions: ["/^--/", "var"]
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"no-empty-source": null,
|
|
46
|
+
"selector-class-pattern": [
|
|
47
|
+
"^([#a-z][$#{}a-z0-9]*)((-{1,2}|_{2})[$#{}a-z0-9]+)*$",
|
|
48
|
+
{
|
|
49
|
+
message(selector) {
|
|
50
|
+
return `Expected class selector "${selector}" to be the BEM style (block-element[__element][--modifier]).`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"selector-not-notation": "simple",
|
|
55
|
+
"selector-type-no-unknown": null,
|
|
56
|
+
...options.overrides
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
];
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
function css(
|
|
64
|
-
return
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
62
|
+
function css(options = {}) {
|
|
63
|
+
return [
|
|
64
|
+
{
|
|
65
|
+
files: GLOB_CSS,
|
|
66
|
+
rules: {
|
|
67
|
+
...options.overrides
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
];
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
function html(
|
|
74
|
-
return
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
73
|
+
function html(options = {}) {
|
|
74
|
+
return [
|
|
75
|
+
{
|
|
76
|
+
files: GLOB_HTML,
|
|
77
|
+
extends: [
|
|
78
|
+
"stylelint-config-html/html"
|
|
79
|
+
],
|
|
80
|
+
rules: {
|
|
81
|
+
...options.overrides
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
];
|
|
82
85
|
}
|
|
83
86
|
|
|
84
|
-
function scss(
|
|
85
|
-
return
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
},
|
|
97
|
-
...lodashEs.omit(config, ["rules"])
|
|
98
|
-
};
|
|
87
|
+
function scss(options = {}) {
|
|
88
|
+
return [
|
|
89
|
+
{
|
|
90
|
+
files: GLOB_SCSS,
|
|
91
|
+
extends: [
|
|
92
|
+
"stylelint-config-recommended-scss"
|
|
93
|
+
],
|
|
94
|
+
rules: {
|
|
95
|
+
...options.overrides
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
];
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
function vue(
|
|
102
|
-
return
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
101
|
+
function vue(options = {}) {
|
|
102
|
+
return [
|
|
103
|
+
{
|
|
104
|
+
files: GLOB_VUE,
|
|
105
|
+
extends: [
|
|
106
|
+
"stylelint-config-recommended-vue"
|
|
107
|
+
],
|
|
108
|
+
rules: {
|
|
109
|
+
...options.overrides
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
];
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
const SCSS_PACKAGES = [
|
|
@@ -124,40 +124,59 @@ const VUE_PACKAGES = [
|
|
|
124
124
|
"@slidev/cli"
|
|
125
125
|
];
|
|
126
126
|
|
|
127
|
+
function castArray(value) {
|
|
128
|
+
return Array.isArray(value) ? value : [value];
|
|
129
|
+
}
|
|
127
130
|
function isPkgExists(pkg) {
|
|
128
|
-
return
|
|
131
|
+
return castArray(pkg).some((it) => localPkg.isPackageExists(it));
|
|
129
132
|
}
|
|
130
133
|
|
|
131
|
-
function
|
|
132
|
-
return typeof config === "boolean" ? {} : config || {};
|
|
133
|
-
}
|
|
134
|
-
function defineConfig(config = {}) {
|
|
134
|
+
function defineConfig(options = {}, ...userOverrides) {
|
|
135
135
|
const {
|
|
136
|
+
css: enableCss = true,
|
|
137
|
+
html: enableHtml = true,
|
|
136
138
|
scss: enableScss = isPkgExists(SCSS_PACKAGES),
|
|
137
139
|
vue: enableVue = isPkgExists(VUE_PACKAGES)
|
|
138
|
-
} =
|
|
140
|
+
} = options;
|
|
139
141
|
const overrides = [
|
|
140
|
-
|
|
141
|
-
css(config.css),
|
|
142
|
-
html(config.html)
|
|
142
|
+
...core(normalizeOptions(options.core))
|
|
143
143
|
];
|
|
144
|
+
if (enableCss) {
|
|
145
|
+
overrides.push(
|
|
146
|
+
...css(normalizeOptions(options.css))
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
if (enableHtml) {
|
|
150
|
+
overrides.push(
|
|
151
|
+
...html(normalizeOptions(options.html))
|
|
152
|
+
);
|
|
153
|
+
}
|
|
144
154
|
if (enableScss) {
|
|
145
155
|
overrides.push(
|
|
146
|
-
scss(
|
|
156
|
+
...scss(normalizeOptions(options.scss))
|
|
147
157
|
);
|
|
148
158
|
}
|
|
149
159
|
if (enableVue) {
|
|
150
160
|
overrides.push(
|
|
151
|
-
vue(
|
|
161
|
+
...vue(normalizeOptions(options.vue))
|
|
152
162
|
);
|
|
153
163
|
}
|
|
154
|
-
|
|
155
|
-
overrides.push(...config.overrides);
|
|
156
|
-
}
|
|
164
|
+
overrides.push(...userOverrides);
|
|
157
165
|
return {
|
|
166
|
+
defaultSeverity: "error",
|
|
167
|
+
allowEmptyInput: true,
|
|
158
168
|
overrides,
|
|
159
|
-
rules: {}
|
|
169
|
+
rules: {},
|
|
170
|
+
...options
|
|
160
171
|
};
|
|
161
172
|
}
|
|
173
|
+
function normalizeOptions(options) {
|
|
174
|
+
return typeof options === "boolean" ? {} : options || {};
|
|
175
|
+
}
|
|
162
176
|
|
|
177
|
+
exports.GLOB_ALL = GLOB_ALL;
|
|
178
|
+
exports.GLOB_CSS = GLOB_CSS;
|
|
179
|
+
exports.GLOB_HTML = GLOB_HTML;
|
|
180
|
+
exports.GLOB_SCSS = GLOB_SCSS;
|
|
181
|
+
exports.GLOB_VUE = GLOB_VUE;
|
|
163
182
|
exports.defineConfig = defineConfig;
|
package/dist/index.d.cts
CHANGED
|
@@ -5,19 +5,51 @@ type ConfigOverride = Omit<Config, "overrides"> & {
|
|
|
5
5
|
files: string | string[];
|
|
6
6
|
name?: string;
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
common?: UserConfigOverride;
|
|
11
|
-
css?: UserConfigOverride;
|
|
12
|
-
html?: UserConfigOverride;
|
|
13
|
-
scss?: boolean | UserConfigOverride;
|
|
14
|
-
vue?: boolean | UserConfigOverride;
|
|
15
|
-
overrides?: ConfigOverride[];
|
|
8
|
+
interface OptionsOverrides {
|
|
9
|
+
overrides?: Config["rules"];
|
|
16
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;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
17
44
|
|
|
18
45
|
|
|
19
46
|
|
|
47
|
+
declare function defineConfig(options?: OptionsConfig & Omit<Config, "overrides">, ...userOverrides: ConfigOverride[]): Config;
|
|
20
48
|
|
|
21
|
-
declare
|
|
49
|
+
declare const GLOB_CSS: string[];
|
|
50
|
+
declare const GLOB_SCSS: string[];
|
|
51
|
+
declare const GLOB_HTML: string[];
|
|
52
|
+
declare const GLOB_VUE: string[];
|
|
53
|
+
declare const GLOB_ALL: string[];
|
|
22
54
|
|
|
23
|
-
export { defineConfig };
|
|
55
|
+
export { GLOB_ALL, GLOB_CSS, GLOB_HTML, GLOB_SCSS, GLOB_VUE, defineConfig };
|
package/dist/index.d.mts
CHANGED
|
@@ -5,19 +5,51 @@ type ConfigOverride = Omit<Config, "overrides"> & {
|
|
|
5
5
|
files: string | string[];
|
|
6
6
|
name?: string;
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
common?: UserConfigOverride;
|
|
11
|
-
css?: UserConfigOverride;
|
|
12
|
-
html?: UserConfigOverride;
|
|
13
|
-
scss?: boolean | UserConfigOverride;
|
|
14
|
-
vue?: boolean | UserConfigOverride;
|
|
15
|
-
overrides?: ConfigOverride[];
|
|
8
|
+
interface OptionsOverrides {
|
|
9
|
+
overrides?: Config["rules"];
|
|
16
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;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
17
44
|
|
|
18
45
|
|
|
19
46
|
|
|
47
|
+
declare function defineConfig(options?: OptionsConfig & Omit<Config, "overrides">, ...userOverrides: ConfigOverride[]): Config;
|
|
20
48
|
|
|
21
|
-
declare
|
|
49
|
+
declare const GLOB_CSS: string[];
|
|
50
|
+
declare const GLOB_SCSS: string[];
|
|
51
|
+
declare const GLOB_HTML: string[];
|
|
52
|
+
declare const GLOB_VUE: string[];
|
|
53
|
+
declare const GLOB_ALL: string[];
|
|
22
54
|
|
|
23
|
-
export { defineConfig };
|
|
55
|
+
export { GLOB_ALL, GLOB_CSS, GLOB_HTML, GLOB_SCSS, GLOB_VUE, defineConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,19 +5,51 @@ type ConfigOverride = Omit<Config, "overrides"> & {
|
|
|
5
5
|
files: string | string[];
|
|
6
6
|
name?: string;
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
common?: UserConfigOverride;
|
|
11
|
-
css?: UserConfigOverride;
|
|
12
|
-
html?: UserConfigOverride;
|
|
13
|
-
scss?: boolean | UserConfigOverride;
|
|
14
|
-
vue?: boolean | UserConfigOverride;
|
|
15
|
-
overrides?: ConfigOverride[];
|
|
8
|
+
interface OptionsOverrides {
|
|
9
|
+
overrides?: Config["rules"];
|
|
16
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;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
17
44
|
|
|
18
45
|
|
|
19
46
|
|
|
47
|
+
declare function defineConfig(options?: OptionsConfig & Omit<Config, "overrides">, ...userOverrides: ConfigOverride[]): Config;
|
|
20
48
|
|
|
21
|
-
declare
|
|
49
|
+
declare const GLOB_CSS: string[];
|
|
50
|
+
declare const GLOB_SCSS: string[];
|
|
51
|
+
declare const GLOB_HTML: string[];
|
|
52
|
+
declare const GLOB_VUE: string[];
|
|
53
|
+
declare const GLOB_ALL: string[];
|
|
22
54
|
|
|
23
|
-
export { defineConfig };
|
|
55
|
+
export { GLOB_ALL, GLOB_CSS, GLOB_HTML, GLOB_SCSS, GLOB_VUE, defineConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -1,113 +1,113 @@
|
|
|
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
|
+
files: GLOB_ALL,
|
|
18
|
+
extends: [
|
|
19
|
+
"stylelint-config-recommended",
|
|
20
|
+
"stylelint-config-recess-order"
|
|
43
21
|
],
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
22
|
+
rules: {
|
|
23
|
+
"alpha-value-notation": "number",
|
|
24
|
+
"color-function-notation": "legacy",
|
|
25
|
+
"color-hex-length": "long",
|
|
26
|
+
"declaration-block-no-redundant-longhand-properties": [
|
|
27
|
+
true,
|
|
28
|
+
{
|
|
29
|
+
ignoreShorthands: [
|
|
30
|
+
"inset"
|
|
31
|
+
]
|
|
50
32
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
33
|
+
],
|
|
34
|
+
"declaration-property-value-no-unknown": null,
|
|
35
|
+
"font-family-no-missing-generic-family-keyword": null,
|
|
36
|
+
"length-zero-no-unit": [
|
|
37
|
+
true,
|
|
38
|
+
{
|
|
39
|
+
ignore: ["custom-properties"],
|
|
40
|
+
ignoreFunctions: ["/^--/", "var"]
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"no-empty-source": null,
|
|
44
|
+
"selector-class-pattern": [
|
|
45
|
+
"^([#a-z][$#{}a-z0-9]*)((-{1,2}|_{2})[$#{}a-z0-9]+)*$",
|
|
46
|
+
{
|
|
47
|
+
message(selector) {
|
|
48
|
+
return `Expected class selector "${selector}" to be the BEM style (block-element[__element][--modifier]).`;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
"selector-not-notation": "simple",
|
|
53
|
+
"selector-type-no-unknown": null,
|
|
54
|
+
...options.overrides
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
];
|
|
59
58
|
}
|
|
60
59
|
|
|
61
|
-
function css(
|
|
62
|
-
return
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
function css(options = {}) {
|
|
61
|
+
return [
|
|
62
|
+
{
|
|
63
|
+
files: GLOB_CSS,
|
|
64
|
+
rules: {
|
|
65
|
+
...options.overrides
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
];
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
function html(
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
71
|
+
function html(options = {}) {
|
|
72
|
+
return [
|
|
73
|
+
{
|
|
74
|
+
files: GLOB_HTML,
|
|
75
|
+
extends: [
|
|
76
|
+
"stylelint-config-html/html"
|
|
77
|
+
],
|
|
78
|
+
rules: {
|
|
79
|
+
...options.overrides
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
];
|
|
80
83
|
}
|
|
81
84
|
|
|
82
|
-
function scss(
|
|
83
|
-
return
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
},
|
|
95
|
-
...omit(config, ["rules"])
|
|
96
|
-
};
|
|
85
|
+
function scss(options = {}) {
|
|
86
|
+
return [
|
|
87
|
+
{
|
|
88
|
+
files: GLOB_SCSS,
|
|
89
|
+
extends: [
|
|
90
|
+
"stylelint-config-recommended-scss"
|
|
91
|
+
],
|
|
92
|
+
rules: {
|
|
93
|
+
...options.overrides
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
];
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
function vue(
|
|
100
|
-
return
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
99
|
+
function vue(options = {}) {
|
|
100
|
+
return [
|
|
101
|
+
{
|
|
102
|
+
files: GLOB_VUE,
|
|
103
|
+
extends: [
|
|
104
|
+
"stylelint-config-recommended-vue"
|
|
105
|
+
],
|
|
106
|
+
rules: {
|
|
107
|
+
...options.overrides
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
];
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
const SCSS_PACKAGES = [
|
|
@@ -122,40 +122,54 @@ const VUE_PACKAGES = [
|
|
|
122
122
|
"@slidev/cli"
|
|
123
123
|
];
|
|
124
124
|
|
|
125
|
+
function castArray(value) {
|
|
126
|
+
return Array.isArray(value) ? value : [value];
|
|
127
|
+
}
|
|
125
128
|
function isPkgExists(pkg) {
|
|
126
129
|
return castArray(pkg).some((it) => isPackageExists(it));
|
|
127
130
|
}
|
|
128
131
|
|
|
129
|
-
function
|
|
130
|
-
return typeof config === "boolean" ? {} : config || {};
|
|
131
|
-
}
|
|
132
|
-
function defineConfig(config = {}) {
|
|
132
|
+
function defineConfig(options = {}, ...userOverrides) {
|
|
133
133
|
const {
|
|
134
|
+
css: enableCss = true,
|
|
135
|
+
html: enableHtml = true,
|
|
134
136
|
scss: enableScss = isPkgExists(SCSS_PACKAGES),
|
|
135
137
|
vue: enableVue = isPkgExists(VUE_PACKAGES)
|
|
136
|
-
} =
|
|
138
|
+
} = options;
|
|
137
139
|
const overrides = [
|
|
138
|
-
|
|
139
|
-
css(config.css),
|
|
140
|
-
html(config.html)
|
|
140
|
+
...core(normalizeOptions(options.core))
|
|
141
141
|
];
|
|
142
|
+
if (enableCss) {
|
|
143
|
+
overrides.push(
|
|
144
|
+
...css(normalizeOptions(options.css))
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
if (enableHtml) {
|
|
148
|
+
overrides.push(
|
|
149
|
+
...html(normalizeOptions(options.html))
|
|
150
|
+
);
|
|
151
|
+
}
|
|
142
152
|
if (enableScss) {
|
|
143
153
|
overrides.push(
|
|
144
|
-
scss(
|
|
154
|
+
...scss(normalizeOptions(options.scss))
|
|
145
155
|
);
|
|
146
156
|
}
|
|
147
157
|
if (enableVue) {
|
|
148
158
|
overrides.push(
|
|
149
|
-
vue(
|
|
159
|
+
...vue(normalizeOptions(options.vue))
|
|
150
160
|
);
|
|
151
161
|
}
|
|
152
|
-
|
|
153
|
-
overrides.push(...config.overrides);
|
|
154
|
-
}
|
|
162
|
+
overrides.push(...userOverrides);
|
|
155
163
|
return {
|
|
164
|
+
defaultSeverity: "error",
|
|
165
|
+
allowEmptyInput: true,
|
|
156
166
|
overrides,
|
|
157
|
-
rules: {}
|
|
167
|
+
rules: {},
|
|
168
|
+
...options
|
|
158
169
|
};
|
|
159
170
|
}
|
|
171
|
+
function normalizeOptions(options) {
|
|
172
|
+
return typeof options === "boolean" ? {} : options || {};
|
|
173
|
+
}
|
|
160
174
|
|
|
161
|
-
export { defineConfig };
|
|
175
|
+
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.1.0",
|
|
5
5
|
"description": "🤚 Stylelint config preset for xiaohe",
|
|
6
6
|
"author": "xiaohe0601 <xiaohe0601@outlook.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -39,19 +39,17 @@
|
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"local-pkg": "^1.1.1",
|
|
42
|
-
"lodash-es": "^4.17.21",
|
|
43
42
|
"postcss-html": "^1.8.0",
|
|
44
43
|
"postcss-scss": "^4.0.9",
|
|
44
|
+
"stylelint-config-html": "^1.1.0",
|
|
45
45
|
"stylelint-config-recess-order": "^6.0.0",
|
|
46
46
|
"stylelint-config-recommended": "^15.0.0",
|
|
47
|
+
"stylelint-config-recommended-scss": "^14.1.0",
|
|
47
48
|
"stylelint-config-recommended-vue": "^1.6.0",
|
|
48
|
-
"stylelint-config-standard": "^37.0.0",
|
|
49
|
-
"stylelint-config-standard-scss": "^14.0.0",
|
|
50
49
|
"stylelint-order": "^6.0.4",
|
|
51
50
|
"stylelint-scss": "^6.11.1"
|
|
52
51
|
},
|
|
53
52
|
"devDependencies": {
|
|
54
|
-
"@types/lodash-es": "^4.17.12",
|
|
55
53
|
"stylelint": "^16.16.0"
|
|
56
54
|
},
|
|
57
55
|
"scripts": {
|