@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/LICENSE +1 -1
- package/README.md +13 -15
- package/dist/index.cjs +207 -318
- package/dist/index.d.cts +47 -43
- package/dist/index.d.ts +47 -43
- package/dist/index.js +237 -0
- package/package.json +16 -20
- package/dist/index.d.mts +0 -54
- package/dist/index.mjs +0 -348
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2025-PRESENT xiaohe0601 <https://github.com/xiaohe0601>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<h1>
|
|
3
|
-
<span>🤚 Stylelint config preset
|
|
2
|
+
<h1>Xiaohe Stylelint Config</h1>
|
|
3
|
+
<span>🤚 Xiaohe's Stylelint config preset (inspired by antfu/eslint-config)</span>
|
|
4
4
|
</div>
|
|
5
5
|
|
|
6
6
|
<br>
|
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
[![JSDocs][jsdocs-src]][jsdocs-href]
|
|
12
12
|
[![License][license-src]][license-href]
|
|
13
13
|
|
|
14
|
-
xiaohe0601 / [github@xiaohe0601](https://github.com/xiaohe0601) / [gitee@xiaohe0601](https://gitee.com/xiaohe0601)
|
|
15
|
-
|
|
16
14
|
### 🚁 Installation
|
|
17
15
|
|
|
18
16
|
```shell
|
|
@@ -27,11 +25,11 @@ npm install -D stylelint @xiaohe01/stylelint-config
|
|
|
27
25
|
```
|
|
28
26
|
|
|
29
27
|
> [!WARNING]
|
|
30
|
-
> Stylelint
|
|
28
|
+
> Require Stylelint >= 16.13.0.
|
|
31
29
|
|
|
32
30
|
### 🛹 Usage
|
|
33
31
|
|
|
34
|
-
Create `stylelint.config.mjs` in your project root
|
|
32
|
+
Create `stylelint.config.mjs` in your project root:
|
|
35
33
|
|
|
36
34
|
```js
|
|
37
35
|
import { defineConfig } from "@xiaohe01/stylelint-config";
|
|
@@ -39,7 +37,7 @@ import { defineConfig } from "@xiaohe01/stylelint-config";
|
|
|
39
37
|
export default defineConfig();
|
|
40
38
|
```
|
|
41
39
|
|
|
42
|
-
Add script for `package.json`, for example
|
|
40
|
+
Add script for `package.json`, for example:
|
|
43
41
|
|
|
44
42
|
```json
|
|
45
43
|
{
|
|
@@ -54,15 +52,15 @@ For more information, please refer to [stylelint](https://stylelint.io).
|
|
|
54
52
|
|
|
55
53
|
### 🏆 License
|
|
56
54
|
|
|
57
|
-
|
|
55
|
+
MIT [LICENSE](../../LICENSE)
|
|
58
56
|
|
|
59
|
-
[github-stars-src]: https://img.shields.io/github/stars/xiaohe0601/xiaohe-
|
|
60
|
-
[github-stars-href]: https://github.com/xiaohe0601/xiaohe-
|
|
61
|
-
[npm-version-src]: https://img.shields.io/npm/v/@xiaohe01/stylelint-config?style=flat&
|
|
57
|
+
[github-stars-src]: https://img.shields.io/github/stars/xiaohe0601/xiaohe-config?style=flat&color=1fa669&labelColor=18181b&logo=github
|
|
58
|
+
[github-stars-href]: https://github.com/xiaohe0601/xiaohe-config
|
|
59
|
+
[npm-version-src]: https://img.shields.io/npm/v/@xiaohe01/stylelint-config?style=flat&color=1fa669&labelColor=18181b&logo=npm
|
|
62
60
|
[npm-version-href]: https://npmjs.com/package/@xiaohe01/stylelint-config
|
|
63
|
-
[npm-downloads-src]: https://img.shields.io/npm/dm/@xiaohe01/stylelint-config?style=flat&
|
|
61
|
+
[npm-downloads-src]: https://img.shields.io/npm/dm/@xiaohe01/stylelint-config?style=flat&color=1fa669&labelColor=18181b
|
|
64
62
|
[npm-downloads-href]: https://npmjs.com/package/@xiaohe01/stylelint-config
|
|
65
|
-
[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-
|
|
63
|
+
[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-1fa669?style=flat&labelColor=18181b
|
|
66
64
|
[jsdocs-href]: https://www.jsdocs.io/package/@xiaohe01/stylelint-config
|
|
67
|
-
[license-src]: https://img.shields.io/github/license/xiaohe0601/xiaohe-
|
|
68
|
-
[license-href]: https://github.com/xiaohe0601/xiaohe-
|
|
65
|
+
[license-src]: https://img.shields.io/github/license/xiaohe0601/xiaohe-config.svg?style=flat&color=1fa669&labelColor=18181b
|
|
66
|
+
[license-href]: https://github.com/xiaohe0601/xiaohe-config/blob/main/LICENSE
|
package/dist/index.cjs
CHANGED
|
@@ -1,355 +1,244 @@
|
|
|
1
|
-
'
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
let local_pkg = require("local-pkg");
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
//#region ../shared/src/constants.ts
|
|
5
|
+
const SCSS_PACKAGES = [
|
|
6
|
+
"sass",
|
|
7
|
+
"sass-embedded",
|
|
8
|
+
"node-sass"
|
|
9
|
+
];
|
|
10
|
+
const UNI_PACKAGES = ["@dcloudio/uni-app"];
|
|
11
|
+
const VUE_PACKAGES = [
|
|
12
|
+
"vue",
|
|
13
|
+
"nuxt",
|
|
14
|
+
"vitepress",
|
|
15
|
+
"@slidev/cli"
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region ../shared/src/helpers.ts
|
|
20
|
+
function castArray(value) {
|
|
21
|
+
return Array.isArray(value) ? value : [value];
|
|
22
|
+
}
|
|
23
|
+
function isPkgExists(pkg) {
|
|
24
|
+
return castArray(pkg).some((it) => (0, local_pkg.isPackageExists)(it));
|
|
25
|
+
}
|
|
4
26
|
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/globs.ts
|
|
5
29
|
const GLOB_CSS = ["*.css", "**/*.css"];
|
|
6
30
|
const GLOB_SCSS = ["*.scss", "**/*.scss"];
|
|
7
31
|
const GLOB_HTML = ["*.html", "**/*.html"];
|
|
8
32
|
const GLOB_VUE = ["*.vue", "**/*.vue"];
|
|
9
33
|
const GLOB_ALL = [
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
34
|
+
...GLOB_CSS,
|
|
35
|
+
...GLOB_SCSS,
|
|
36
|
+
...GLOB_HTML,
|
|
37
|
+
...GLOB_VUE
|
|
14
38
|
];
|
|
15
39
|
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/configs/core.ts
|
|
16
42
|
function core(options = {}) {
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
];
|
|
43
|
+
const { vue: vue$1 = false } = options;
|
|
44
|
+
return [{
|
|
45
|
+
name: "xiaohe/core/rules",
|
|
46
|
+
files: GLOB_ALL,
|
|
47
|
+
extends: ["stylelint-config-recess-order"],
|
|
48
|
+
rules: {
|
|
49
|
+
"alpha-value-notation": "number",
|
|
50
|
+
"annotation-no-unknown": true,
|
|
51
|
+
"at-rule-descriptor-no-unknown": true,
|
|
52
|
+
"at-rule-descriptor-value-no-unknown": true,
|
|
53
|
+
"at-rule-no-deprecated": true,
|
|
54
|
+
"at-rule-no-unknown": true,
|
|
55
|
+
"at-rule-prelude-no-invalid": [true, { ignoreAtRules: ["media"] }],
|
|
56
|
+
"block-no-empty": true,
|
|
57
|
+
"color-function-notation": "legacy",
|
|
58
|
+
"color-hex-length": "long",
|
|
59
|
+
"comment-no-empty": true,
|
|
60
|
+
"custom-property-no-missing-var-function": true,
|
|
61
|
+
"declaration-block-no-duplicate-custom-properties": true,
|
|
62
|
+
"declaration-block-no-duplicate-properties": [true, { ignore: ["consecutive-duplicates-with-different-syntaxes"] }],
|
|
63
|
+
"declaration-block-no-redundant-longhand-properties": [true, { ignoreShorthands: ["inset"] }],
|
|
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": [true, {
|
|
71
|
+
ignore: ["custom-properties"],
|
|
72
|
+
ignoreFunctions: ["/^--/", "var"]
|
|
73
|
+
}],
|
|
74
|
+
"media-feature-name-no-unknown": true,
|
|
75
|
+
"media-feature-name-value-no-unknown": true,
|
|
76
|
+
"media-query-no-invalid": true,
|
|
77
|
+
"named-grid-areas-no-invalid": true,
|
|
78
|
+
"no-descending-specificity": true,
|
|
79
|
+
"no-duplicate-at-import-rules": true,
|
|
80
|
+
"no-duplicate-selectors": true,
|
|
81
|
+
"no-invalid-double-slash-comments": true,
|
|
82
|
+
"no-invalid-position-at-import-rule": true,
|
|
83
|
+
"no-irregular-whitespace": true,
|
|
84
|
+
"property-no-unknown": true,
|
|
85
|
+
"selector-anb-no-unmatchable": true,
|
|
86
|
+
"selector-class-pattern": ["^([#a-z][$#{}a-z0-9]*)((-{1,2}|_{2})[$#{}a-z0-9]+)*$", { message(selector) {
|
|
87
|
+
return `Expected class selector "${selector}" to be the BEM style (block-element[__element][--modifier]).`;
|
|
88
|
+
} }],
|
|
89
|
+
"selector-not-notation": "simple",
|
|
90
|
+
"selector-pseudo-class-no-unknown": true,
|
|
91
|
+
"selector-pseudo-element-no-unknown": true,
|
|
92
|
+
"string-no-newline": [true, { ignore: ["at-rule-preludes", "declaration-values"] }],
|
|
93
|
+
...vue$1 ? {
|
|
94
|
+
"selector-pseudo-class-no-unknown": [true, { ignorePseudoClasses: [
|
|
95
|
+
"deep",
|
|
96
|
+
"global",
|
|
97
|
+
"slotted"
|
|
98
|
+
] }],
|
|
99
|
+
"selector-pseudo-element-no-unknown": [true, { ignorePseudoElements: [
|
|
100
|
+
"v-deep",
|
|
101
|
+
"v-global",
|
|
102
|
+
"v-slotted"
|
|
103
|
+
] }]
|
|
104
|
+
} : {},
|
|
105
|
+
...options.overrides
|
|
106
|
+
}
|
|
107
|
+
}];
|
|
140
108
|
}
|
|
141
109
|
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/configs/css.ts
|
|
142
112
|
function css(options = {}) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
...options.overrides
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
];
|
|
113
|
+
return [{
|
|
114
|
+
name: "xiaohe/css/rules",
|
|
115
|
+
files: GLOB_CSS,
|
|
116
|
+
rules: { ...options.overrides }
|
|
117
|
+
}];
|
|
152
118
|
}
|
|
153
119
|
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/configs/html.ts
|
|
154
122
|
function html(options = {}) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
...options.overrides
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
];
|
|
123
|
+
return [{
|
|
124
|
+
name: "xiaohe/html/rules",
|
|
125
|
+
files: GLOB_HTML,
|
|
126
|
+
rules: { ...options.overrides }
|
|
127
|
+
}];
|
|
164
128
|
}
|
|
165
129
|
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region src/configs/scss.ts
|
|
166
132
|
function scss(options = {}) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
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
|
-
];
|
|
133
|
+
const { vue: vue$1 = false, uni = false } = options;
|
|
134
|
+
return [{
|
|
135
|
+
name: "xiaohe/scss/rules",
|
|
136
|
+
files: [...GLOB_SCSS, ...vue$1 ? GLOB_VUE : []],
|
|
137
|
+
rules: {
|
|
138
|
+
"annotation-no-unknown": null,
|
|
139
|
+
"at-rule-no-unknown": null,
|
|
140
|
+
"comment-no-empty": null,
|
|
141
|
+
"function-no-unknown": null,
|
|
142
|
+
"media-query-no-invalid": null,
|
|
143
|
+
"no-invalid-position-at-import-rule": [true, { ignoreAtRules: ["use", "forward"] }],
|
|
144
|
+
"scss/at-extend-no-missing-placeholder": true,
|
|
145
|
+
"scss/at-if-no-null": true,
|
|
146
|
+
"scss/at-rule-no-unknown": true,
|
|
147
|
+
"scss/comment-no-empty": true,
|
|
148
|
+
"scss/declaration-nested-properties-no-divided-groups": true,
|
|
149
|
+
"scss/dollar-variable-no-missing-interpolation": true,
|
|
150
|
+
"scss/function-quote-no-quoted-strings-inside": true,
|
|
151
|
+
"scss/function-unquote-no-unquoted-strings-inside": true,
|
|
152
|
+
"scss/load-no-partial-leading-underscore": true,
|
|
153
|
+
"scss/load-partial-extension": "never",
|
|
154
|
+
"scss/no-duplicate-mixins": true,
|
|
155
|
+
"scss/no-global-function-names": true,
|
|
156
|
+
"scss/operator-no-newline-after": true,
|
|
157
|
+
"scss/operator-no-newline-before": true,
|
|
158
|
+
"scss/operator-no-unspaced": true,
|
|
159
|
+
...uni ? { "scss/load-partial-extension": "always" } : {},
|
|
160
|
+
...options.overrides
|
|
161
|
+
}
|
|
162
|
+
}];
|
|
215
163
|
}
|
|
216
164
|
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/configs/setup.ts
|
|
217
167
|
function setup(options = {}) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
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;
|
|
168
|
+
const { scss: scss$1 = false, html: html$1 = false, vue: vue$1 = false } = options;
|
|
169
|
+
const overrides = [];
|
|
170
|
+
if (html$1) overrides.push({
|
|
171
|
+
name: "xiaohe/html/setup",
|
|
172
|
+
files: GLOB_HTML,
|
|
173
|
+
customSyntax: "postcss-html"
|
|
174
|
+
});
|
|
175
|
+
if (vue$1) overrides.push({
|
|
176
|
+
name: "xiaohe/vue/setup",
|
|
177
|
+
files: GLOB_VUE,
|
|
178
|
+
customSyntax: "postcss-html",
|
|
179
|
+
plugins: [...scss$1 ? ["stylelint-scss"] : []]
|
|
180
|
+
});
|
|
181
|
+
if (scss$1) overrides.push({
|
|
182
|
+
name: "xiaohe/scss/setup",
|
|
183
|
+
files: GLOB_SCSS,
|
|
184
|
+
customSyntax: "postcss-scss",
|
|
185
|
+
plugins: ["stylelint-scss"]
|
|
186
|
+
});
|
|
187
|
+
return overrides;
|
|
254
188
|
}
|
|
255
189
|
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region src/configs/vue.ts
|
|
256
192
|
function vue(options = {}) {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
...options.overrides
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
];
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
const SCSS_PACKAGES = [
|
|
269
|
-
"sass",
|
|
270
|
-
"sass-embedded",
|
|
271
|
-
"node-sass"
|
|
272
|
-
];
|
|
273
|
-
const VUE_PACKAGES = [
|
|
274
|
-
"vue",
|
|
275
|
-
"nuxt",
|
|
276
|
-
"vitepress",
|
|
277
|
-
"@slidev/cli"
|
|
278
|
-
];
|
|
279
|
-
const UNIAPP_PACKAGES = [
|
|
280
|
-
"@dcloudio/uni-app"
|
|
281
|
-
];
|
|
282
|
-
|
|
283
|
-
function castArray(value) {
|
|
284
|
-
return Array.isArray(value) ? value : [value];
|
|
285
|
-
}
|
|
286
|
-
function isPkgExists(pkg) {
|
|
287
|
-
return castArray(pkg).some((it) => localPkg.isPackageExists(it));
|
|
193
|
+
return [{
|
|
194
|
+
name: "xiaohe/vue/rules",
|
|
195
|
+
files: GLOB_VUE,
|
|
196
|
+
rules: { ...options.overrides }
|
|
197
|
+
}];
|
|
288
198
|
}
|
|
289
199
|
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region src/factory.ts
|
|
290
202
|
function defineConfig(options = {}, ...userOverrides) {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
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
|
-
};
|
|
203
|
+
const { scss: enableScss = isPkgExists(SCSS_PACKAGES), html: enableHtml = true, vue: enableVue = isPkgExists(VUE_PACKAGES), uni: enableUni = isPkgExists(UNI_PACKAGES) } = options;
|
|
204
|
+
const overrides = [
|
|
205
|
+
...setup({
|
|
206
|
+
scss: !!enableScss,
|
|
207
|
+
html: !!enableHtml,
|
|
208
|
+
vue: !!enableVue
|
|
209
|
+
}),
|
|
210
|
+
...core({
|
|
211
|
+
overrides: getOverrides(options.core),
|
|
212
|
+
vue: !!enableVue
|
|
213
|
+
}),
|
|
214
|
+
...css({ overrides: getOverrides(options.css) })
|
|
215
|
+
];
|
|
216
|
+
if (enableScss) overrides.push(...scss({
|
|
217
|
+
overrides: getOverrides(options.scss),
|
|
218
|
+
vue: !!enableVue,
|
|
219
|
+
uni: enableUni
|
|
220
|
+
}));
|
|
221
|
+
if (enableHtml) overrides.push(...html({ overrides: getOverrides(options.html) }));
|
|
222
|
+
if (enableVue) overrides.push(...vue({ overrides: getOverrides(options.vue) }));
|
|
223
|
+
overrides.push(...userOverrides);
|
|
224
|
+
return {
|
|
225
|
+
defaultSeverity: "error",
|
|
226
|
+
allowEmptyInput: true,
|
|
227
|
+
overrides,
|
|
228
|
+
rules: {},
|
|
229
|
+
...options
|
|
230
|
+
};
|
|
342
231
|
}
|
|
343
232
|
function getOverrides(options) {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
}
|
|
347
|
-
return options.overrides || {};
|
|
233
|
+
if (options == null || typeof options === "boolean") return {};
|
|
234
|
+
return options.overrides || {};
|
|
348
235
|
}
|
|
349
236
|
|
|
237
|
+
//#endregion
|
|
350
238
|
exports.GLOB_ALL = GLOB_ALL;
|
|
351
239
|
exports.GLOB_CSS = GLOB_CSS;
|
|
352
240
|
exports.GLOB_HTML = GLOB_HTML;
|
|
353
241
|
exports.GLOB_SCSS = GLOB_SCSS;
|
|
354
242
|
exports.GLOB_VUE = GLOB_VUE;
|
|
355
|
-
exports.
|
|
243
|
+
exports.default = defineConfig;
|
|
244
|
+
exports.defineConfig = defineConfig;
|