@xiaohe01/stylelint-config 0.0.1
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 +21 -0
- package/README.md +95 -0
- package/dist/index.cjs +153 -0
- package/dist/index.d.cts +31 -0
- package/dist/index.d.mts +31 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.mjs +147 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-PRESENT xiaohe0601 <https://github.com/xiaohe0601>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>xiaohe-stylelint-config</h1>
|
|
3
|
+
<span>๐ค Stylelint config preset for xiaohe</span>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
<br>
|
|
7
|
+
|
|
8
|
+
[![github stars][github-stars-src]][github-stars-href]
|
|
9
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
10
|
+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
11
|
+
[![bundle][bundle-src]][bundle-href]
|
|
12
|
+
[![JSDocs][jsdocs-src]][jsdocs-href]
|
|
13
|
+
[![License][license-src]][license-href]
|
|
14
|
+
|
|
15
|
+
Xiaohe / [github@xiaohe0601](https://github.com/xiaohe0601) / [gitee@xiaohe0601](https://gitee.com/xiaohe0601)
|
|
16
|
+
|
|
17
|
+
### ๐ Installation
|
|
18
|
+
|
|
19
|
+
#### PNPM
|
|
20
|
+
|
|
21
|
+
``` shell
|
|
22
|
+
pnpm add -D stylelint @xiaohe01/stylelint-config
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
#### YARN
|
|
26
|
+
|
|
27
|
+
``` shell
|
|
28
|
+
yarn add --dev stylelint @xiaohe01/stylelint-config
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
#### NPM
|
|
32
|
+
|
|
33
|
+
``` shell
|
|
34
|
+
npm install -D stylelint @xiaohe01/stylelint-config
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### ๐น Usage
|
|
38
|
+
|
|
39
|
+
Create `stylelint.config.js` in your project root
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
import defineConfig from "@xiaohe01/stylelint-config";
|
|
43
|
+
|
|
44
|
+
export default defineConfig();
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Add script for `package.json`, for example
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"scripts": {
|
|
52
|
+
"stylelint": "stylelint **/*.{css,scss,vue,html}",
|
|
53
|
+
"stylelint:fix": "stylelint **/*.{css,scss,vue,html} --fix"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
For more information, please refer to [stylelint](https://stylelint.io).
|
|
59
|
+
|
|
60
|
+
### ๐ถ Discussion & Communication
|
|
61
|
+
|
|
62
|
+
- โ๏ผFor questions or bug feedback, you can submit an [issues](https://github.com/xiaohe0601/xiaohe-stylelint-config/issues)
|
|
63
|
+
and PRs are welcome~
|
|
64
|
+
- ๐ซ๏ผ[xiaohe0601@outlook.com](mailto:xiaohe0601@outlook.com)
|
|
65
|
+
- ๐ง๏ผNot yet available
|
|
66
|
+
|
|
67
|
+
### ๐ License
|
|
68
|
+
|
|
69
|
+
- MIT [LICENSE](./LICENSE)
|
|
70
|
+
|
|
71
|
+
<!-- Badges -->
|
|
72
|
+
|
|
73
|
+
[github-stars-src]: https://img.shields.io/github/stars/xiaohe0601/xiaohe-stylelint-config?style=flat&colorA=080f12&colorB=1fa669&logo=GitHub
|
|
74
|
+
|
|
75
|
+
[github-stars-href]: https://github.com/xiaohe0601/xiaohe-stylelint-config
|
|
76
|
+
|
|
77
|
+
[npm-version-src]: https://img.shields.io/npm/v/@xiaohe01/stylelint-config?style=flat&colorA=080f12&colorB=1fa669
|
|
78
|
+
|
|
79
|
+
[npm-version-href]: https://npmjs.com/package/@xiaohe01/stylelint-config
|
|
80
|
+
|
|
81
|
+
[npm-downloads-src]: https://img.shields.io/npm/dm/@xiaohe01/stylelint-config?style=flat&colorA=080f12&colorB=1fa669
|
|
82
|
+
|
|
83
|
+
[npm-downloads-href]: https://npmjs.com/package/@xiaohe01/stylelint-config
|
|
84
|
+
|
|
85
|
+
[bundle-src]: https://img.shields.io/bundlephobia/minzip/@xiaohe01/stylelint-config?style=flat&colorA=080f12&colorB=1fa669&label=minzip
|
|
86
|
+
|
|
87
|
+
[bundle-href]: https://bundlephobia.com/result?p=@xiaohe01/stylelint-config
|
|
88
|
+
|
|
89
|
+
[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669
|
|
90
|
+
|
|
91
|
+
[jsdocs-href]: https://www.jsdocs.io/package/@xiaohe01/stylelint-config
|
|
92
|
+
|
|
93
|
+
[license-src]: https://img.shields.io/github/license/xiaohe0601/xiaohe-stylelint-config.svg?style=flat&colorA=080f12&colorB=1fa669
|
|
94
|
+
|
|
95
|
+
[license-href]: https://github.com/xiaohe0601/xiaohe-stylelint-config/blob/main/LICENSE
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const lodashEs = require('lodash-es');
|
|
4
|
+
const localPkg = require('local-pkg');
|
|
5
|
+
|
|
6
|
+
const SCSS_PACKAGES = [
|
|
7
|
+
"sass",
|
|
8
|
+
"sass-embedded",
|
|
9
|
+
"node-sass"
|
|
10
|
+
];
|
|
11
|
+
const VUE_PACKAGES = [
|
|
12
|
+
"vue",
|
|
13
|
+
"nuxt",
|
|
14
|
+
"vitepress",
|
|
15
|
+
"@slidev/cli"
|
|
16
|
+
];
|
|
17
|
+
const UNIAPP_PACKAGE = "@dcloudio/uni-app";
|
|
18
|
+
|
|
19
|
+
function isPkgExists(pkg) {
|
|
20
|
+
return lodashEs.castArray(pkg).some((it) => localPkg.isPackageExists(it));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function buildExtends(options) {
|
|
24
|
+
if (!lodashEs.isEmpty(options.overrideExtends)) {
|
|
25
|
+
return lodashEs.castArray(options.overrideExtends);
|
|
26
|
+
}
|
|
27
|
+
const {
|
|
28
|
+
scss: enableScss,
|
|
29
|
+
vue: enableVue
|
|
30
|
+
} = options.presets;
|
|
31
|
+
const extendz = [
|
|
32
|
+
"stylelint-config-standard",
|
|
33
|
+
"stylelint-config-recommended",
|
|
34
|
+
"stylelint-config-html",
|
|
35
|
+
"stylelint-config-recess-order"
|
|
36
|
+
];
|
|
37
|
+
if (enableScss) {
|
|
38
|
+
extendz.push("stylelint-config-standard-scss");
|
|
39
|
+
}
|
|
40
|
+
if (enableVue) {
|
|
41
|
+
extendz.push("stylelint-config-recommended-vue");
|
|
42
|
+
}
|
|
43
|
+
if (!lodashEs.isEmpty(options.extends)) {
|
|
44
|
+
extendz.push(...lodashEs.castArray(options.extends));
|
|
45
|
+
}
|
|
46
|
+
return extendz;
|
|
47
|
+
}
|
|
48
|
+
function buildPlugins(options) {
|
|
49
|
+
if (!lodashEs.isEmpty(options.overridePlugins)) {
|
|
50
|
+
return lodashEs.castArray(options.overridePlugins);
|
|
51
|
+
}
|
|
52
|
+
const plugins = [
|
|
53
|
+
"stylelint-order"
|
|
54
|
+
];
|
|
55
|
+
if (!lodashEs.isEmpty(options.plugins)) {
|
|
56
|
+
plugins.push(...lodashEs.castArray(options.plugins));
|
|
57
|
+
}
|
|
58
|
+
return plugins;
|
|
59
|
+
}
|
|
60
|
+
function buildRules(options) {
|
|
61
|
+
const {
|
|
62
|
+
scss: enableScss,
|
|
63
|
+
vue: enableVue,
|
|
64
|
+
uniapp: enableUniApp
|
|
65
|
+
} = options.presets;
|
|
66
|
+
const disables = {
|
|
67
|
+
"unit-no-unknown": null,
|
|
68
|
+
"no-empty-source": null,
|
|
69
|
+
"at-rule-no-unknown": null,
|
|
70
|
+
"value-keyword-case": null,
|
|
71
|
+
"selector-not-notation": null,
|
|
72
|
+
"no-duplicate-selectors": null,
|
|
73
|
+
"font-family-name-quotes": null,
|
|
74
|
+
"no-descending-specificity": null,
|
|
75
|
+
"custom-property-empty-line-before": null,
|
|
76
|
+
"font-family-no-missing-generic-family-keyword": null
|
|
77
|
+
};
|
|
78
|
+
if (enableScss) {
|
|
79
|
+
lodashEs.merge(disables, {
|
|
80
|
+
"scss/at-extend-no-missing-placeholder": null
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const rules = {
|
|
84
|
+
...disables,
|
|
85
|
+
"color-hex-length": ["long", {
|
|
86
|
+
message: "Hexadecimal colors need to use the long format style (#ffffff)"
|
|
87
|
+
}],
|
|
88
|
+
"length-zero-no-unit": [true, {
|
|
89
|
+
ignoreFunctions: ["/^--/", "var", "calc"]
|
|
90
|
+
}],
|
|
91
|
+
"alpha-value-notation": "number",
|
|
92
|
+
"selector-class-pattern": ["^([#a-z][$#{}a-z0-9]*)((-{1,2}|_{2})[$#{}a-z0-9]+)*$", {
|
|
93
|
+
message: "Class naming should follow the BEM style (block-element[__element][--modifier])"
|
|
94
|
+
}],
|
|
95
|
+
"color-function-notation": "legacy",
|
|
96
|
+
"declaration-block-no-redundant-longhand-properties": [true, {
|
|
97
|
+
ignoreShorthands: ["inset"]
|
|
98
|
+
}]
|
|
99
|
+
};
|
|
100
|
+
if (enableScss) {
|
|
101
|
+
lodashEs.merge(rules, {
|
|
102
|
+
"scss/load-partial-extension": "always"
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
if (enableVue) {
|
|
106
|
+
lodashEs.merge(rules, {
|
|
107
|
+
"selector-pseudo-class-no-unknown": [true, {
|
|
108
|
+
ignorePseudoClasses: ["deep"]
|
|
109
|
+
}]
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
if (enableUniApp) {
|
|
113
|
+
lodashEs.merge(rules, {
|
|
114
|
+
"selector-type-no-unknown": [true, {
|
|
115
|
+
ignoreTypes: ["page", "rich-text", "scroll-view"]
|
|
116
|
+
}]
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
if (!lodashEs.isEmpty(options.rules)) {
|
|
120
|
+
lodashEs.merge(rules, options.rules);
|
|
121
|
+
}
|
|
122
|
+
return rules;
|
|
123
|
+
}
|
|
124
|
+
function defineConfig(options = {}) {
|
|
125
|
+
const presets = lodashEs.merge({
|
|
126
|
+
scss: isPkgExists(SCSS_PACKAGES),
|
|
127
|
+
vue: isPkgExists(VUE_PACKAGES),
|
|
128
|
+
uniapp: isPkgExists(UNIAPP_PACKAGE)
|
|
129
|
+
}, options.presets);
|
|
130
|
+
const finalOptions = {
|
|
131
|
+
...options,
|
|
132
|
+
presets
|
|
133
|
+
};
|
|
134
|
+
return {
|
|
135
|
+
allowEmptyInput: true,
|
|
136
|
+
cache: true,
|
|
137
|
+
defaultSeverity: "error",
|
|
138
|
+
extends: buildExtends(finalOptions),
|
|
139
|
+
plugins: buildPlugins(finalOptions),
|
|
140
|
+
rules: buildRules(finalOptions),
|
|
141
|
+
...lodashEs.omit(options, [
|
|
142
|
+
"extends",
|
|
143
|
+
"plugins",
|
|
144
|
+
"rules"
|
|
145
|
+
])
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
exports.SCSS_PACKAGES = SCSS_PACKAGES;
|
|
150
|
+
exports.UNIAPP_PACKAGE = UNIAPP_PACKAGE;
|
|
151
|
+
exports.VUE_PACKAGES = VUE_PACKAGES;
|
|
152
|
+
exports.defineConfig = defineConfig;
|
|
153
|
+
exports.isPkgExists = isPkgExists;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Plugin, ConfigRuleSettings, Config } from 'stylelint';
|
|
2
|
+
|
|
3
|
+
declare const SCSS_PACKAGES: string[];
|
|
4
|
+
declare const VUE_PACKAGES: string[];
|
|
5
|
+
declare const UNIAPP_PACKAGE = "@dcloudio/uni-app";
|
|
6
|
+
|
|
7
|
+
type Arrayable<T> = T | T[];
|
|
8
|
+
type ConfigExtend = string;
|
|
9
|
+
type ConfigExtends = ConfigExtend[];
|
|
10
|
+
type ConfigPlugin = string | Plugin;
|
|
11
|
+
type ConfigPlugins = ConfigPlugin[];
|
|
12
|
+
type ConfigRule = ConfigRuleSettings<any, object>;
|
|
13
|
+
interface ConfigRules {
|
|
14
|
+
[key: string]: ConfigRule;
|
|
15
|
+
}
|
|
16
|
+
interface ConfigPresets {
|
|
17
|
+
scss?: boolean;
|
|
18
|
+
vue?: boolean;
|
|
19
|
+
uniapp?: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface ConfigOptions extends Config {
|
|
22
|
+
presets?: ConfigPresets;
|
|
23
|
+
overrideExtends?: Config["extends"];
|
|
24
|
+
overridePlugins?: Config["plugins"];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare function defineConfig(options?: ConfigOptions): Config;
|
|
28
|
+
|
|
29
|
+
declare function isPkgExists(pkg: Arrayable<string>): boolean;
|
|
30
|
+
|
|
31
|
+
export { type Arrayable, type ConfigExtend, type ConfigExtends, type ConfigOptions, type ConfigPlugin, type ConfigPlugins, type ConfigPresets, type ConfigRule, type ConfigRules, SCSS_PACKAGES, UNIAPP_PACKAGE, VUE_PACKAGES, defineConfig, isPkgExists };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Plugin, ConfigRuleSettings, Config } from 'stylelint';
|
|
2
|
+
|
|
3
|
+
declare const SCSS_PACKAGES: string[];
|
|
4
|
+
declare const VUE_PACKAGES: string[];
|
|
5
|
+
declare const UNIAPP_PACKAGE = "@dcloudio/uni-app";
|
|
6
|
+
|
|
7
|
+
type Arrayable<T> = T | T[];
|
|
8
|
+
type ConfigExtend = string;
|
|
9
|
+
type ConfigExtends = ConfigExtend[];
|
|
10
|
+
type ConfigPlugin = string | Plugin;
|
|
11
|
+
type ConfigPlugins = ConfigPlugin[];
|
|
12
|
+
type ConfigRule = ConfigRuleSettings<any, object>;
|
|
13
|
+
interface ConfigRules {
|
|
14
|
+
[key: string]: ConfigRule;
|
|
15
|
+
}
|
|
16
|
+
interface ConfigPresets {
|
|
17
|
+
scss?: boolean;
|
|
18
|
+
vue?: boolean;
|
|
19
|
+
uniapp?: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface ConfigOptions extends Config {
|
|
22
|
+
presets?: ConfigPresets;
|
|
23
|
+
overrideExtends?: Config["extends"];
|
|
24
|
+
overridePlugins?: Config["plugins"];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare function defineConfig(options?: ConfigOptions): Config;
|
|
28
|
+
|
|
29
|
+
declare function isPkgExists(pkg: Arrayable<string>): boolean;
|
|
30
|
+
|
|
31
|
+
export { type Arrayable, type ConfigExtend, type ConfigExtends, type ConfigOptions, type ConfigPlugin, type ConfigPlugins, type ConfigPresets, type ConfigRule, type ConfigRules, SCSS_PACKAGES, UNIAPP_PACKAGE, VUE_PACKAGES, defineConfig, isPkgExists };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Plugin, ConfigRuleSettings, Config } from 'stylelint';
|
|
2
|
+
|
|
3
|
+
declare const SCSS_PACKAGES: string[];
|
|
4
|
+
declare const VUE_PACKAGES: string[];
|
|
5
|
+
declare const UNIAPP_PACKAGE = "@dcloudio/uni-app";
|
|
6
|
+
|
|
7
|
+
type Arrayable<T> = T | T[];
|
|
8
|
+
type ConfigExtend = string;
|
|
9
|
+
type ConfigExtends = ConfigExtend[];
|
|
10
|
+
type ConfigPlugin = string | Plugin;
|
|
11
|
+
type ConfigPlugins = ConfigPlugin[];
|
|
12
|
+
type ConfigRule = ConfigRuleSettings<any, object>;
|
|
13
|
+
interface ConfigRules {
|
|
14
|
+
[key: string]: ConfigRule;
|
|
15
|
+
}
|
|
16
|
+
interface ConfigPresets {
|
|
17
|
+
scss?: boolean;
|
|
18
|
+
vue?: boolean;
|
|
19
|
+
uniapp?: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface ConfigOptions extends Config {
|
|
22
|
+
presets?: ConfigPresets;
|
|
23
|
+
overrideExtends?: Config["extends"];
|
|
24
|
+
overridePlugins?: Config["plugins"];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare function defineConfig(options?: ConfigOptions): Config;
|
|
28
|
+
|
|
29
|
+
declare function isPkgExists(pkg: Arrayable<string>): boolean;
|
|
30
|
+
|
|
31
|
+
export { type Arrayable, type ConfigExtend, type ConfigExtends, type ConfigOptions, type ConfigPlugin, type ConfigPlugins, type ConfigPresets, type ConfigRule, type ConfigRules, SCSS_PACKAGES, UNIAPP_PACKAGE, VUE_PACKAGES, defineConfig, isPkgExists };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { castArray, merge, omit, isEmpty } from 'lodash-es';
|
|
2
|
+
import { isPackageExists } from 'local-pkg';
|
|
3
|
+
|
|
4
|
+
const SCSS_PACKAGES = [
|
|
5
|
+
"sass",
|
|
6
|
+
"sass-embedded",
|
|
7
|
+
"node-sass"
|
|
8
|
+
];
|
|
9
|
+
const VUE_PACKAGES = [
|
|
10
|
+
"vue",
|
|
11
|
+
"nuxt",
|
|
12
|
+
"vitepress",
|
|
13
|
+
"@slidev/cli"
|
|
14
|
+
];
|
|
15
|
+
const UNIAPP_PACKAGE = "@dcloudio/uni-app";
|
|
16
|
+
|
|
17
|
+
function isPkgExists(pkg) {
|
|
18
|
+
return castArray(pkg).some((it) => isPackageExists(it));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function buildExtends(options) {
|
|
22
|
+
if (!isEmpty(options.overrideExtends)) {
|
|
23
|
+
return castArray(options.overrideExtends);
|
|
24
|
+
}
|
|
25
|
+
const {
|
|
26
|
+
scss: enableScss,
|
|
27
|
+
vue: enableVue
|
|
28
|
+
} = options.presets;
|
|
29
|
+
const extendz = [
|
|
30
|
+
"stylelint-config-standard",
|
|
31
|
+
"stylelint-config-recommended",
|
|
32
|
+
"stylelint-config-html",
|
|
33
|
+
"stylelint-config-recess-order"
|
|
34
|
+
];
|
|
35
|
+
if (enableScss) {
|
|
36
|
+
extendz.push("stylelint-config-standard-scss");
|
|
37
|
+
}
|
|
38
|
+
if (enableVue) {
|
|
39
|
+
extendz.push("stylelint-config-recommended-vue");
|
|
40
|
+
}
|
|
41
|
+
if (!isEmpty(options.extends)) {
|
|
42
|
+
extendz.push(...castArray(options.extends));
|
|
43
|
+
}
|
|
44
|
+
return extendz;
|
|
45
|
+
}
|
|
46
|
+
function buildPlugins(options) {
|
|
47
|
+
if (!isEmpty(options.overridePlugins)) {
|
|
48
|
+
return castArray(options.overridePlugins);
|
|
49
|
+
}
|
|
50
|
+
const plugins = [
|
|
51
|
+
"stylelint-order"
|
|
52
|
+
];
|
|
53
|
+
if (!isEmpty(options.plugins)) {
|
|
54
|
+
plugins.push(...castArray(options.plugins));
|
|
55
|
+
}
|
|
56
|
+
return plugins;
|
|
57
|
+
}
|
|
58
|
+
function buildRules(options) {
|
|
59
|
+
const {
|
|
60
|
+
scss: enableScss,
|
|
61
|
+
vue: enableVue,
|
|
62
|
+
uniapp: enableUniApp
|
|
63
|
+
} = options.presets;
|
|
64
|
+
const disables = {
|
|
65
|
+
"unit-no-unknown": null,
|
|
66
|
+
"no-empty-source": null,
|
|
67
|
+
"at-rule-no-unknown": null,
|
|
68
|
+
"value-keyword-case": null,
|
|
69
|
+
"selector-not-notation": null,
|
|
70
|
+
"no-duplicate-selectors": null,
|
|
71
|
+
"font-family-name-quotes": null,
|
|
72
|
+
"no-descending-specificity": null,
|
|
73
|
+
"custom-property-empty-line-before": null,
|
|
74
|
+
"font-family-no-missing-generic-family-keyword": null
|
|
75
|
+
};
|
|
76
|
+
if (enableScss) {
|
|
77
|
+
merge(disables, {
|
|
78
|
+
"scss/at-extend-no-missing-placeholder": null
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
const rules = {
|
|
82
|
+
...disables,
|
|
83
|
+
"color-hex-length": ["long", {
|
|
84
|
+
message: "Hexadecimal colors need to use the long format style (#ffffff)"
|
|
85
|
+
}],
|
|
86
|
+
"length-zero-no-unit": [true, {
|
|
87
|
+
ignoreFunctions: ["/^--/", "var", "calc"]
|
|
88
|
+
}],
|
|
89
|
+
"alpha-value-notation": "number",
|
|
90
|
+
"selector-class-pattern": ["^([#a-z][$#{}a-z0-9]*)((-{1,2}|_{2})[$#{}a-z0-9]+)*$", {
|
|
91
|
+
message: "Class naming should follow the BEM style (block-element[__element][--modifier])"
|
|
92
|
+
}],
|
|
93
|
+
"color-function-notation": "legacy",
|
|
94
|
+
"declaration-block-no-redundant-longhand-properties": [true, {
|
|
95
|
+
ignoreShorthands: ["inset"]
|
|
96
|
+
}]
|
|
97
|
+
};
|
|
98
|
+
if (enableScss) {
|
|
99
|
+
merge(rules, {
|
|
100
|
+
"scss/load-partial-extension": "always"
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
if (enableVue) {
|
|
104
|
+
merge(rules, {
|
|
105
|
+
"selector-pseudo-class-no-unknown": [true, {
|
|
106
|
+
ignorePseudoClasses: ["deep"]
|
|
107
|
+
}]
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
if (enableUniApp) {
|
|
111
|
+
merge(rules, {
|
|
112
|
+
"selector-type-no-unknown": [true, {
|
|
113
|
+
ignoreTypes: ["page", "rich-text", "scroll-view"]
|
|
114
|
+
}]
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
if (!isEmpty(options.rules)) {
|
|
118
|
+
merge(rules, options.rules);
|
|
119
|
+
}
|
|
120
|
+
return rules;
|
|
121
|
+
}
|
|
122
|
+
function defineConfig(options = {}) {
|
|
123
|
+
const presets = merge({
|
|
124
|
+
scss: isPkgExists(SCSS_PACKAGES),
|
|
125
|
+
vue: isPkgExists(VUE_PACKAGES),
|
|
126
|
+
uniapp: isPkgExists(UNIAPP_PACKAGE)
|
|
127
|
+
}, options.presets);
|
|
128
|
+
const finalOptions = {
|
|
129
|
+
...options,
|
|
130
|
+
presets
|
|
131
|
+
};
|
|
132
|
+
return {
|
|
133
|
+
allowEmptyInput: true,
|
|
134
|
+
cache: true,
|
|
135
|
+
defaultSeverity: "error",
|
|
136
|
+
extends: buildExtends(finalOptions),
|
|
137
|
+
plugins: buildPlugins(finalOptions),
|
|
138
|
+
rules: buildRules(finalOptions),
|
|
139
|
+
...omit(options, [
|
|
140
|
+
"extends",
|
|
141
|
+
"plugins",
|
|
142
|
+
"rules"
|
|
143
|
+
])
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export { SCSS_PACKAGES, UNIAPP_PACKAGE, VUE_PACKAGES, defineConfig, isPkgExists };
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xiaohe01/stylelint-config",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"description": "๐ค Stylelint config preset for xiaohe",
|
|
6
|
+
"author": "xiaohe0601 <xiaohe0601@outlook.com>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"homepage": "https://github.com/xiaohe0601/xiaohe-stylelint-config#readme",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/xiaohe0601/xiaohe-stylelint-config.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": "https://github.com/xiaohe0601/xiaohe-stylelint-config/issues",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"stylelint-config"
|
|
16
|
+
],
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.mjs",
|
|
22
|
+
"require": "./dist/index.cjs"
|
|
23
|
+
},
|
|
24
|
+
"./*": "./*"
|
|
25
|
+
},
|
|
26
|
+
"main": "./dist/index.mjs",
|
|
27
|
+
"module": "./dist/index.mjs",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"typesVersions": {
|
|
30
|
+
"*": {
|
|
31
|
+
"*": [
|
|
32
|
+
"./dist/*",
|
|
33
|
+
"./dist/index.d.ts"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist"
|
|
39
|
+
],
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"local-pkg": "^0.5.0",
|
|
42
|
+
"lodash-es": "^4.17.21",
|
|
43
|
+
"stylelint-config-html": "^1.1.0",
|
|
44
|
+
"stylelint-config-recess-order": "^5.1.1",
|
|
45
|
+
"stylelint-config-recommended": "^14.0.1",
|
|
46
|
+
"stylelint-config-recommended-vue": "^1.5.0",
|
|
47
|
+
"stylelint-config-standard": "^36.0.1",
|
|
48
|
+
"stylelint-config-standard-scss": "^13.1.0",
|
|
49
|
+
"stylelint-order": "^6.0.4"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@types/lodash-es": "^4.17.12",
|
|
53
|
+
"stylelint": "^16.9.0"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "unbuild"
|
|
57
|
+
}
|
|
58
|
+
}
|