@xiaohe01/stylelint-config 0.0.1 → 0.0.3
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 -3
- package/dist/index.cjs +23 -6
- package/dist/index.d.cts +4 -1
- package/dist/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.mjs +24 -8
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ npm install -D stylelint @xiaohe01/stylelint-config
|
|
|
39
39
|
Create `stylelint.config.js` in your project root
|
|
40
40
|
|
|
41
41
|
```js
|
|
42
|
-
import defineConfig from "@xiaohe01/stylelint-config";
|
|
42
|
+
import { defineConfig } from "@xiaohe01/stylelint-config";
|
|
43
43
|
|
|
44
44
|
export default defineConfig();
|
|
45
45
|
```
|
|
@@ -49,8 +49,8 @@ Add script for `package.json`, for example
|
|
|
49
49
|
```json
|
|
50
50
|
{
|
|
51
51
|
"scripts": {
|
|
52
|
-
"stylelint": "stylelint **/*.{css,scss,vue
|
|
53
|
-
"stylelint:fix": "stylelint **/*.{css,scss,vue
|
|
52
|
+
"stylelint": "stylelint **/*.{css,scss,html,vue}",
|
|
53
|
+
"stylelint:fix": "stylelint **/*.{css,scss,html,vue} --fix"
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -83,14 +83,14 @@ function buildRules(options) {
|
|
|
83
83
|
const rules = {
|
|
84
84
|
...disables,
|
|
85
85
|
"color-hex-length": ["long", {
|
|
86
|
-
message: "
|
|
86
|
+
message: "Hex color value should be used the long format style (#ffffff). (color-hex-length)"
|
|
87
87
|
}],
|
|
88
88
|
"length-zero-no-unit": [true, {
|
|
89
89
|
ignoreFunctions: ["/^--/", "var", "calc"]
|
|
90
90
|
}],
|
|
91
91
|
"alpha-value-notation": "number",
|
|
92
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])"
|
|
93
|
+
message: "Class naming should follow the BEM style (block-element[__element][--modifier]). (selector-class-pattern)"
|
|
94
94
|
}],
|
|
95
95
|
"color-function-notation": "legacy",
|
|
96
96
|
"declaration-block-no-redundant-longhand-properties": [true, {
|
|
@@ -111,9 +111,7 @@ function buildRules(options) {
|
|
|
111
111
|
}
|
|
112
112
|
if (enableUniApp) {
|
|
113
113
|
lodashEs.merge(rules, {
|
|
114
|
-
"selector-type-no-unknown":
|
|
115
|
-
ignoreTypes: ["page", "rich-text", "scroll-view"]
|
|
116
|
-
}]
|
|
114
|
+
"selector-type-no-unknown": null
|
|
117
115
|
});
|
|
118
116
|
}
|
|
119
117
|
if (!lodashEs.isEmpty(options.rules)) {
|
|
@@ -121,6 +119,22 @@ function buildRules(options) {
|
|
|
121
119
|
}
|
|
122
120
|
return rules;
|
|
123
121
|
}
|
|
122
|
+
function buildOverrides(options) {
|
|
123
|
+
if (!lodashEs.isEmpty(options.overrideOverrides)) {
|
|
124
|
+
return options.overrideOverrides;
|
|
125
|
+
}
|
|
126
|
+
const overrides = [{
|
|
127
|
+
files: ["*.html", "*.vue"],
|
|
128
|
+
customSyntax: "postcss-html"
|
|
129
|
+
}, {
|
|
130
|
+
files: ["*.scss"],
|
|
131
|
+
customSyntax: "postcss-scss"
|
|
132
|
+
}];
|
|
133
|
+
if (!lodashEs.isEmpty(options.overrides)) {
|
|
134
|
+
overrides.push(...lodashEs.castArray(options.overrides));
|
|
135
|
+
}
|
|
136
|
+
return overrides;
|
|
137
|
+
}
|
|
124
138
|
function defineConfig(options = {}) {
|
|
125
139
|
const presets = lodashEs.merge({
|
|
126
140
|
scss: isPkgExists(SCSS_PACKAGES),
|
|
@@ -138,10 +152,12 @@ function defineConfig(options = {}) {
|
|
|
138
152
|
extends: buildExtends(finalOptions),
|
|
139
153
|
plugins: buildPlugins(finalOptions),
|
|
140
154
|
rules: buildRules(finalOptions),
|
|
155
|
+
overrides: buildOverrides(finalOptions),
|
|
141
156
|
...lodashEs.omit(options, [
|
|
142
157
|
"extends",
|
|
143
158
|
"plugins",
|
|
144
|
-
"rules"
|
|
159
|
+
"rules",
|
|
160
|
+
"overrides"
|
|
145
161
|
])
|
|
146
162
|
};
|
|
147
163
|
}
|
|
@@ -149,5 +165,6 @@ function defineConfig(options = {}) {
|
|
|
149
165
|
exports.SCSS_PACKAGES = SCSS_PACKAGES;
|
|
150
166
|
exports.UNIAPP_PACKAGE = UNIAPP_PACKAGE;
|
|
151
167
|
exports.VUE_PACKAGES = VUE_PACKAGES;
|
|
168
|
+
exports.buildOverrides = buildOverrides;
|
|
152
169
|
exports.defineConfig = defineConfig;
|
|
153
170
|
exports.isPkgExists = isPkgExists;
|
package/dist/index.d.cts
CHANGED
|
@@ -13,6 +13,7 @@ type ConfigRule = ConfigRuleSettings<any, object>;
|
|
|
13
13
|
interface ConfigRules {
|
|
14
14
|
[key: string]: ConfigRule;
|
|
15
15
|
}
|
|
16
|
+
type ConfigOverrides = Config["overrides"];
|
|
16
17
|
interface ConfigPresets {
|
|
17
18
|
scss?: boolean;
|
|
18
19
|
vue?: boolean;
|
|
@@ -22,10 +23,12 @@ interface ConfigOptions extends Config {
|
|
|
22
23
|
presets?: ConfigPresets;
|
|
23
24
|
overrideExtends?: Config["extends"];
|
|
24
25
|
overridePlugins?: Config["plugins"];
|
|
26
|
+
overrideOverrides?: Config["overrides"];
|
|
25
27
|
}
|
|
26
28
|
|
|
29
|
+
declare function buildOverrides(options: ConfigOptions): ConfigOverrides;
|
|
27
30
|
declare function defineConfig(options?: ConfigOptions): Config;
|
|
28
31
|
|
|
29
32
|
declare function isPkgExists(pkg: Arrayable<string>): boolean;
|
|
30
33
|
|
|
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 };
|
|
34
|
+
export { type Arrayable, type ConfigExtend, type ConfigExtends, type ConfigOptions, type ConfigOverrides, type ConfigPlugin, type ConfigPlugins, type ConfigPresets, type ConfigRule, type ConfigRules, SCSS_PACKAGES, UNIAPP_PACKAGE, VUE_PACKAGES, buildOverrides, defineConfig, isPkgExists };
|
package/dist/index.d.mts
CHANGED
|
@@ -13,6 +13,7 @@ type ConfigRule = ConfigRuleSettings<any, object>;
|
|
|
13
13
|
interface ConfigRules {
|
|
14
14
|
[key: string]: ConfigRule;
|
|
15
15
|
}
|
|
16
|
+
type ConfigOverrides = Config["overrides"];
|
|
16
17
|
interface ConfigPresets {
|
|
17
18
|
scss?: boolean;
|
|
18
19
|
vue?: boolean;
|
|
@@ -22,10 +23,12 @@ interface ConfigOptions extends Config {
|
|
|
22
23
|
presets?: ConfigPresets;
|
|
23
24
|
overrideExtends?: Config["extends"];
|
|
24
25
|
overridePlugins?: Config["plugins"];
|
|
26
|
+
overrideOverrides?: Config["overrides"];
|
|
25
27
|
}
|
|
26
28
|
|
|
29
|
+
declare function buildOverrides(options: ConfigOptions): ConfigOverrides;
|
|
27
30
|
declare function defineConfig(options?: ConfigOptions): Config;
|
|
28
31
|
|
|
29
32
|
declare function isPkgExists(pkg: Arrayable<string>): boolean;
|
|
30
33
|
|
|
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 };
|
|
34
|
+
export { type Arrayable, type ConfigExtend, type ConfigExtends, type ConfigOptions, type ConfigOverrides, type ConfigPlugin, type ConfigPlugins, type ConfigPresets, type ConfigRule, type ConfigRules, SCSS_PACKAGES, UNIAPP_PACKAGE, VUE_PACKAGES, buildOverrides, defineConfig, isPkgExists };
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ type ConfigRule = ConfigRuleSettings<any, object>;
|
|
|
13
13
|
interface ConfigRules {
|
|
14
14
|
[key: string]: ConfigRule;
|
|
15
15
|
}
|
|
16
|
+
type ConfigOverrides = Config["overrides"];
|
|
16
17
|
interface ConfigPresets {
|
|
17
18
|
scss?: boolean;
|
|
18
19
|
vue?: boolean;
|
|
@@ -22,10 +23,12 @@ interface ConfigOptions extends Config {
|
|
|
22
23
|
presets?: ConfigPresets;
|
|
23
24
|
overrideExtends?: Config["extends"];
|
|
24
25
|
overridePlugins?: Config["plugins"];
|
|
26
|
+
overrideOverrides?: Config["overrides"];
|
|
25
27
|
}
|
|
26
28
|
|
|
29
|
+
declare function buildOverrides(options: ConfigOptions): ConfigOverrides;
|
|
27
30
|
declare function defineConfig(options?: ConfigOptions): Config;
|
|
28
31
|
|
|
29
32
|
declare function isPkgExists(pkg: Arrayable<string>): boolean;
|
|
30
33
|
|
|
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 };
|
|
34
|
+
export { type Arrayable, type ConfigExtend, type ConfigExtends, type ConfigOptions, type ConfigOverrides, type ConfigPlugin, type ConfigPlugins, type ConfigPresets, type ConfigRule, type ConfigRules, SCSS_PACKAGES, UNIAPP_PACKAGE, VUE_PACKAGES, buildOverrides, defineConfig, isPkgExists };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { castArray, merge, omit
|
|
1
|
+
import { castArray, isEmpty, merge, omit } from 'lodash-es';
|
|
2
2
|
import { isPackageExists } from 'local-pkg';
|
|
3
3
|
|
|
4
4
|
const SCSS_PACKAGES = [
|
|
@@ -81,14 +81,14 @@ function buildRules(options) {
|
|
|
81
81
|
const rules = {
|
|
82
82
|
...disables,
|
|
83
83
|
"color-hex-length": ["long", {
|
|
84
|
-
message: "
|
|
84
|
+
message: "Hex color value should be used the long format style (#ffffff). (color-hex-length)"
|
|
85
85
|
}],
|
|
86
86
|
"length-zero-no-unit": [true, {
|
|
87
87
|
ignoreFunctions: ["/^--/", "var", "calc"]
|
|
88
88
|
}],
|
|
89
89
|
"alpha-value-notation": "number",
|
|
90
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])"
|
|
91
|
+
message: "Class naming should follow the BEM style (block-element[__element][--modifier]). (selector-class-pattern)"
|
|
92
92
|
}],
|
|
93
93
|
"color-function-notation": "legacy",
|
|
94
94
|
"declaration-block-no-redundant-longhand-properties": [true, {
|
|
@@ -109,9 +109,7 @@ function buildRules(options) {
|
|
|
109
109
|
}
|
|
110
110
|
if (enableUniApp) {
|
|
111
111
|
merge(rules, {
|
|
112
|
-
"selector-type-no-unknown":
|
|
113
|
-
ignoreTypes: ["page", "rich-text", "scroll-view"]
|
|
114
|
-
}]
|
|
112
|
+
"selector-type-no-unknown": null
|
|
115
113
|
});
|
|
116
114
|
}
|
|
117
115
|
if (!isEmpty(options.rules)) {
|
|
@@ -119,6 +117,22 @@ function buildRules(options) {
|
|
|
119
117
|
}
|
|
120
118
|
return rules;
|
|
121
119
|
}
|
|
120
|
+
function buildOverrides(options) {
|
|
121
|
+
if (!isEmpty(options.overrideOverrides)) {
|
|
122
|
+
return options.overrideOverrides;
|
|
123
|
+
}
|
|
124
|
+
const overrides = [{
|
|
125
|
+
files: ["*.html", "*.vue"],
|
|
126
|
+
customSyntax: "postcss-html"
|
|
127
|
+
}, {
|
|
128
|
+
files: ["*.scss"],
|
|
129
|
+
customSyntax: "postcss-scss"
|
|
130
|
+
}];
|
|
131
|
+
if (!isEmpty(options.overrides)) {
|
|
132
|
+
overrides.push(...castArray(options.overrides));
|
|
133
|
+
}
|
|
134
|
+
return overrides;
|
|
135
|
+
}
|
|
122
136
|
function defineConfig(options = {}) {
|
|
123
137
|
const presets = merge({
|
|
124
138
|
scss: isPkgExists(SCSS_PACKAGES),
|
|
@@ -136,12 +150,14 @@ function defineConfig(options = {}) {
|
|
|
136
150
|
extends: buildExtends(finalOptions),
|
|
137
151
|
plugins: buildPlugins(finalOptions),
|
|
138
152
|
rules: buildRules(finalOptions),
|
|
153
|
+
overrides: buildOverrides(finalOptions),
|
|
139
154
|
...omit(options, [
|
|
140
155
|
"extends",
|
|
141
156
|
"plugins",
|
|
142
|
-
"rules"
|
|
157
|
+
"rules",
|
|
158
|
+
"overrides"
|
|
143
159
|
])
|
|
144
160
|
};
|
|
145
161
|
}
|
|
146
162
|
|
|
147
|
-
export { SCSS_PACKAGES, UNIAPP_PACKAGE, VUE_PACKAGES, defineConfig, isPkgExists };
|
|
163
|
+
export { SCSS_PACKAGES, UNIAPP_PACKAGE, VUE_PACKAGES, buildOverrides, defineConfig, isPkgExists };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xiaohe01/stylelint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.3",
|
|
5
5
|
"description": "🤚 Stylelint config preset for xiaohe",
|
|
6
6
|
"author": "xiaohe0601 <xiaohe0601@outlook.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -38,19 +38,21 @@
|
|
|
38
38
|
"dist"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"local-pkg": "^0.5.
|
|
41
|
+
"local-pkg": "^0.5.1",
|
|
42
42
|
"lodash-es": "^4.17.21",
|
|
43
|
+
"postcss-html": "^1.7.0",
|
|
44
|
+
"postcss-scss": "^4.0.9",
|
|
43
45
|
"stylelint-config-html": "^1.1.0",
|
|
44
46
|
"stylelint-config-recess-order": "^5.1.1",
|
|
45
47
|
"stylelint-config-recommended": "^14.0.1",
|
|
46
48
|
"stylelint-config-recommended-vue": "^1.5.0",
|
|
47
49
|
"stylelint-config-standard": "^36.0.1",
|
|
48
|
-
"stylelint-config-standard-scss": "^
|
|
50
|
+
"stylelint-config-standard-scss": "^14.0.0",
|
|
49
51
|
"stylelint-order": "^6.0.4"
|
|
50
52
|
},
|
|
51
53
|
"devDependencies": {
|
|
52
54
|
"@types/lodash-es": "^4.17.12",
|
|
53
|
-
"stylelint": "^16.
|
|
55
|
+
"stylelint": "^16.11.0"
|
|
54
56
|
},
|
|
55
57
|
"scripts": {
|
|
56
58
|
"build": "unbuild"
|