@icebreakers/stylelint-config 2.0.3 → 2.0.5
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 +22 -1
- package/README.zh.md +22 -1
- package/dist/cli.d.ts +1 -2
- package/dist/cli.js +27 -33
- package/dist/index.d.ts +57 -36
- package/dist/index.js +133 -184
- package/package.json +15 -4
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
`@icebreakers/stylelint-config` bundles a Stylelint preset for Vue + SCSS stacks and ships a CLI helper that bootstraps editor settings. It layers sensible defaults (unit allowlists, UnoCSS/Tailwind at-rule ignores) on top of the upstream recommended configs, while still letting you toggle specific bundles or append extra rules.
|
|
7
|
+
`@icebreakers/stylelint-config` bundles a Stylelint preset for Vue + SCSS stacks and ships a CLI helper that bootstraps editor settings. It layers sensible defaults (unit allowlists, UnoCSS/Tailwind at-rule ignores, and a built-in Tailwind utility selector ban) on top of the upstream recommended configs, while still letting you toggle specific bundles or append extra rules.
|
|
8
8
|
|
|
9
9
|
## Requirements
|
|
10
10
|
|
|
@@ -82,8 +82,29 @@ Defaults include:
|
|
|
82
82
|
- Allowing BEM/OOCSS class selectors (e.g. `block__element--modifier`, `object--state`)
|
|
83
83
|
- Allowing the `rpx` unit for mini-program compatibility
|
|
84
84
|
- Ignoring Tailwind/UnoCSS style at-rules (`apply`, `screen`, etc.)
|
|
85
|
+
- Disallowing authored Tailwind utility selectors such as `.flex` or `.hover\:bg-red-500`
|
|
85
86
|
- Ignoring the `page` selector used by various platforms
|
|
86
87
|
|
|
88
|
+
## Tailwind Utility Selector Guard
|
|
89
|
+
|
|
90
|
+
This preset enables `stylelint-plugin-tailwindcss` by default with:
|
|
91
|
+
|
|
92
|
+
```txt
|
|
93
|
+
tailwindcss/no-atomic-class
|
|
94
|
+
tailwindcss/no-invalid-apply
|
|
95
|
+
tailwindcss/no-apply
|
|
96
|
+
tailwindcss/no-arbitrary-value
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
These rules:
|
|
100
|
+
|
|
101
|
+
- report Tailwind utility selectors declared in authored stylesheets while still allowing semantic selectors such as BEM/OOCSS class names
|
|
102
|
+
- report invalid utility-like `@apply` candidates
|
|
103
|
+
- disallow `@apply` entirely
|
|
104
|
+
- disallow arbitrary values / arbitrary properties such as `w-[10px]` and `[mask-type:luminance]`
|
|
105
|
+
|
|
106
|
+
The underlying plugin supports both Tailwind CSS v3 and v4, and switches automatically based on the installed `tailwindcss` major version in the consuming project.
|
|
107
|
+
|
|
87
108
|
## Recommended Scripts
|
|
88
109
|
|
|
89
110
|
- `pnpm --filter @icebreakers/stylelint-config build` to produce the distributable `dist/` bundle.
|
package/README.zh.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## 概览
|
|
4
4
|
|
|
5
|
-
`@icebreakers/stylelint-config` 为 Vue + SCSS 技术栈提供开箱即用的 Stylelint 预设,并附带一个 CLI,可快速生成编辑器配置。它在上游推荐规则的基础上,补充了常用的单位白名单、UnoCSS / Tailwind
|
|
5
|
+
`@icebreakers/stylelint-config` 为 Vue + SCSS 技术栈提供开箱即用的 Stylelint 预设,并附带一个 CLI,可快速生成编辑器配置。它在上游推荐规则的基础上,补充了常用的单位白名单、UnoCSS / Tailwind 指令忽略项,以及默认启用的 Tailwind 原子类声明拦截规则,同时保留对预设开关和自定义规则的控制能力。
|
|
6
6
|
|
|
7
7
|
## 环境要求
|
|
8
8
|
|
|
@@ -80,8 +80,29 @@ export default createStylelintConfig({
|
|
|
80
80
|
- 允许 BEM / OOCSS 风格的类名(如 `block__element--modifier`、`object--state`)
|
|
81
81
|
- 允许 `rpx` 单位,兼容小程序
|
|
82
82
|
- 忽略 Tailwind / UnoCSS 常见指令(如 `apply`、`screen`)
|
|
83
|
+
- 禁止在手写样式中声明 `.flex`、`.hover\:bg-red-500` 这类 Tailwind 原子类选择器
|
|
83
84
|
- 忽略多端平台常见的 `page` 选择器
|
|
84
85
|
|
|
86
|
+
## Tailwind 原子类拦截
|
|
87
|
+
|
|
88
|
+
该预设默认启用了 `stylelint-plugin-tailwindcss`,对应规则为:
|
|
89
|
+
|
|
90
|
+
```txt
|
|
91
|
+
tailwindcss/no-atomic-class
|
|
92
|
+
tailwindcss/no-invalid-apply
|
|
93
|
+
tailwindcss/no-apply
|
|
94
|
+
tailwindcss/no-arbitrary-value
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
这些规则会:
|
|
98
|
+
|
|
99
|
+
- 拦截在样式文件中直接声明 Tailwind utility selector,但不会影响正常的语义化类名,例如 BEM / OOCSS 风格命名
|
|
100
|
+
- 拦截无效的 `@apply` utility candidate
|
|
101
|
+
- 直接禁止 `@apply`
|
|
102
|
+
- 拦截 `w-[10px]`、`[mask-type:luminance]` 这类 arbitrary value / arbitrary property
|
|
103
|
+
|
|
104
|
+
底层插件同时兼容 Tailwind CSS v3 和 v4,会根据使用方项目实际安装的 `tailwindcss` 主版本自动切换检测逻辑。
|
|
105
|
+
|
|
85
106
|
## 推荐脚本
|
|
86
107
|
|
|
87
108
|
- `pnpm --filter @icebreakers/stylelint-config build` 构建 `dist/` 产物。
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { }
|
|
1
|
+
export { };
|
package/dist/cli.js
CHANGED
|
@@ -1,42 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import { resolve } from "path";
|
|
4
|
-
import process from "process";
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { resolve } from "node:path";
|
|
5
4
|
import jsonc from "comment-json";
|
|
6
|
-
|
|
7
|
-
// src/shared.ts
|
|
5
|
+
//#region src/shared.ts
|
|
8
6
|
function asStringArray(value) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
return value.filter((entry) => typeof entry === "string");
|
|
7
|
+
if (!Array.isArray(value)) return [];
|
|
8
|
+
return value.filter((entry) => typeof entry === "string");
|
|
13
9
|
}
|
|
14
|
-
function setVscodeSettingsJson(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
10
|
+
function setVscodeSettingsJson(json = {}) {
|
|
11
|
+
json["css.validate"] = false;
|
|
12
|
+
json["less.validate"] = false;
|
|
13
|
+
json["scss.validate"] = false;
|
|
14
|
+
const existing = new Set(asStringArray(json["stylelint.validate"]));
|
|
15
|
+
existing.add("vue");
|
|
16
|
+
existing.add("css");
|
|
17
|
+
existing.add("scss");
|
|
18
|
+
json["stylelint.validate"] = [...existing];
|
|
19
|
+
return json;
|
|
24
20
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
fs.mkdirSync(resolve(cwd, ".vscode"), {
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
var json = {};
|
|
33
|
-
var isExisted = fs.existsSync(vscodeSettingsFilename);
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/cli.ts
|
|
23
|
+
const cwd = process.cwd();
|
|
24
|
+
fs.mkdirSync(resolve(cwd, ".vscode"), { recursive: true });
|
|
25
|
+
const vscodeSettingsFilename = resolve(cwd, ".vscode/settings.json");
|
|
26
|
+
let json = {};
|
|
27
|
+
const isExisted = fs.existsSync(vscodeSettingsFilename);
|
|
34
28
|
if (isExisted) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
json = value;
|
|
38
|
-
}
|
|
29
|
+
const value = jsonc.parse(fs.readFileSync(vscodeSettingsFilename, "utf8"));
|
|
30
|
+
if (value) json = value;
|
|
39
31
|
}
|
|
40
32
|
setVscodeSettingsJson(json);
|
|
41
33
|
fs.writeFileSync(vscodeSettingsFilename, jsonc.stringify(json, void 0, 2), "utf8");
|
|
42
34
|
console.info(`[@icebreakers/stylelint-config] ${isExisted ? "update" : "init"} '.vscode/settings.json' finished`);
|
|
35
|
+
//#endregion
|
|
36
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,42 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
interface StylelintRuleOptions {
|
|
3
|
+
[key: string]: unknown;
|
|
4
|
+
}
|
|
5
|
+
type StylelintRuleSetting = null | undefined | string | number | boolean | RegExp | StylelintRuleOptions | [unknown] | [unknown, StylelintRuleOptions];
|
|
6
|
+
interface StylelintOverride {
|
|
7
|
+
files: string | string[];
|
|
8
|
+
name?: string;
|
|
9
|
+
customSyntax?: any;
|
|
10
|
+
extends?: string | string[];
|
|
11
|
+
plugins?: string | object | Array<string | object>;
|
|
12
|
+
rules?: Record<string, StylelintRuleSetting>;
|
|
13
|
+
}
|
|
14
|
+
interface StylelintConfig {
|
|
15
|
+
extends?: string | string[];
|
|
16
|
+
plugins?: string | object | Array<string | object>;
|
|
17
|
+
overrides?: StylelintOverride[];
|
|
18
|
+
rules?: Record<string, StylelintRuleSetting>;
|
|
19
|
+
customSyntax?: any;
|
|
20
|
+
ignoreFiles?: string | string[];
|
|
21
|
+
}
|
|
3
22
|
interface PresetToggles {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
23
|
+
/** Include rules for SCSS syntax. Enabled by default. */
|
|
24
|
+
scss?: boolean;
|
|
25
|
+
/** Include Vue-specific recommendations. Enabled by default. */
|
|
26
|
+
vue?: boolean;
|
|
27
|
+
/** Enforce property ordering via recess-order. Enabled by default. */
|
|
28
|
+
order?: boolean;
|
|
10
29
|
}
|
|
11
30
|
interface IgnoreListOptions {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
31
|
+
/** Replace the default ignore-at-rules list. */
|
|
32
|
+
atRules?: string[];
|
|
33
|
+
/** Replace the default ignore selector types list. */
|
|
34
|
+
types?: string[];
|
|
35
|
+
/** Replace the default ignore units list. */
|
|
36
|
+
units?: string[];
|
|
37
|
+
/** Additional at-rules to ignore. */
|
|
38
|
+
addAtRules?: string[];
|
|
39
|
+
/** Additional selector types to ignore. */
|
|
40
|
+
addTypes?: string[];
|
|
41
|
+
/** Additional units to ignore. */
|
|
42
|
+
addUnits?: string[];
|
|
24
43
|
}
|
|
25
44
|
interface IcebreakerStylelintOptions {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
45
|
+
/** Toggle built-in preset bundles. */
|
|
46
|
+
presets?: PresetToggles;
|
|
47
|
+
/** Append extra extends entries. */
|
|
48
|
+
extends?: StylelintConfig['extends'];
|
|
49
|
+
/** Append override entries. */
|
|
50
|
+
overrides?: StylelintConfig['overrides'];
|
|
51
|
+
/** Provide additional or replacement rule ignore lists. */
|
|
52
|
+
ignores?: IgnoreListOptions;
|
|
53
|
+
/** Override or add rules. */
|
|
54
|
+
rules?: StylelintConfig['rules'];
|
|
36
55
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/config.d.ts
|
|
58
|
+
declare function createIcebreakerStylelintConfig(options?: IcebreakerStylelintOptions): StylelintConfig;
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/index.d.ts
|
|
61
|
+
declare function icebreaker(config?: StylelintConfig): StylelintConfig;
|
|
62
|
+
//#endregion
|
|
63
|
+
export { type IcebreakerStylelintOptions, type IgnoreListOptions, type PresetToggles, createIcebreakerStylelintConfig as createStylelintConfig, icebreaker };
|
package/dist/index.js
CHANGED
|
@@ -1,211 +1,160 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
]
|
|
26
|
-
|
|
27
|
-
"rpx"
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
// src/utils.ts
|
|
31
|
-
var IGNORE_DEFAULTS = {
|
|
32
|
-
atRules: DEFAULT_IGNORE_AT_RULES,
|
|
33
|
-
types: DEFAULT_IGNORE_TYPES,
|
|
34
|
-
units: DEFAULT_IGNORE_UNITS
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { noApplyRuleName, noArbitraryValueRuleName, noAtomicClassRuleName, noInvalidApplyRuleName, recommended } from "stylelint-plugin-tailwindcss";
|
|
5
|
+
//#region src/constants.ts
|
|
6
|
+
const PRESET_STANDARD_SCSS = "stylelint-config-standard-scss";
|
|
7
|
+
const PRESET_VUE_SCSS = "stylelint-config-recommended-vue/scss";
|
|
8
|
+
const PRESET_RECESS_ORDER = "stylelint-config-recess-order";
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/utils.ts
|
|
11
|
+
const IGNORE_DEFAULTS = {
|
|
12
|
+
atRules: [
|
|
13
|
+
"tailwind",
|
|
14
|
+
"theme",
|
|
15
|
+
"apply",
|
|
16
|
+
"source",
|
|
17
|
+
"utility",
|
|
18
|
+
"variant",
|
|
19
|
+
"custom-variant",
|
|
20
|
+
"reference",
|
|
21
|
+
"config",
|
|
22
|
+
"plugin",
|
|
23
|
+
"unocss"
|
|
24
|
+
],
|
|
25
|
+
types: ["page"],
|
|
26
|
+
units: ["rpx"]
|
|
35
27
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
28
|
+
const IGNORE_REPLACE_KEYS = {
|
|
29
|
+
atRules: "atRules",
|
|
30
|
+
types: "types",
|
|
31
|
+
units: "units"
|
|
40
32
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
const IGNORE_APPEND_KEYS = {
|
|
34
|
+
atRules: "addAtRules",
|
|
35
|
+
types: "addTypes",
|
|
36
|
+
units: "addUnits"
|
|
45
37
|
};
|
|
46
38
|
function toArray(value) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
return Array.isArray(value) ? value : [value];
|
|
39
|
+
if (value == null) return [];
|
|
40
|
+
return Array.isArray(value) ? value : [value];
|
|
51
41
|
}
|
|
52
42
|
function unique(values) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
return result;
|
|
43
|
+
const result = [];
|
|
44
|
+
const seen = /* @__PURE__ */ new Set();
|
|
45
|
+
for (const value of values) {
|
|
46
|
+
if (seen.has(value)) continue;
|
|
47
|
+
seen.add(value);
|
|
48
|
+
result.push(value);
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
63
51
|
}
|
|
64
52
|
function resolveIgnoreList(kind, options) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
return unique([...initial, ...extras]);
|
|
53
|
+
const replaceKey = IGNORE_REPLACE_KEYS[kind];
|
|
54
|
+
const appendKey = IGNORE_APPEND_KEYS[kind];
|
|
55
|
+
const base = options?.[replaceKey];
|
|
56
|
+
const extras = options?.[appendKey];
|
|
57
|
+
const initial = base !== void 0 ? base : IGNORE_DEFAULTS[kind];
|
|
58
|
+
if (!extras || extras.length === 0) return unique(initial);
|
|
59
|
+
return unique([...initial, ...extras]);
|
|
74
60
|
}
|
|
75
61
|
function normalizeExtends(base) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (Array.isArray(base)) {
|
|
80
|
-
return base.length === 1 ? base[0] : base;
|
|
81
|
-
}
|
|
82
|
-
return base;
|
|
62
|
+
if (!base || Array.isArray(base) && base.length === 0) return;
|
|
63
|
+
if (Array.isArray(base)) return base.length === 1 ? base[0] : base;
|
|
64
|
+
return base;
|
|
83
65
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/config.ts
|
|
68
|
+
const requireFromConfig = createRequire(import.meta.url);
|
|
69
|
+
const BEM_OOCSS_CLASS_NAME_PATTERN = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*(?:__[a-z0-9]+(?:-[a-z0-9]+)*)*(?:--[a-z0-9]+(?:-[a-z0-9]+)*)*$/;
|
|
88
70
|
function resolvePresetPath(specifier) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
try {
|
|
98
|
-
return requireFromConfig.resolve(specifier);
|
|
99
|
-
} catch {
|
|
100
|
-
return specifier;
|
|
101
|
-
}
|
|
71
|
+
if (!(process.env["ICEBREAKER_STYLELINT_DISABLE_IMPORT_META_RESOLVE"] === "1") && typeof import.meta.resolve === "function") try {
|
|
72
|
+
return fileURLToPath(import.meta.resolve(specifier));
|
|
73
|
+
} catch {}
|
|
74
|
+
try {
|
|
75
|
+
return requireFromConfig.resolve(specifier);
|
|
76
|
+
} catch {
|
|
77
|
+
return specifier;
|
|
78
|
+
}
|
|
102
79
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
80
|
+
const PRESET_PATH_STANDARD_SCSS = resolvePresetPath(PRESET_STANDARD_SCSS);
|
|
81
|
+
const PRESET_PATH_VUE_SCSS = resolvePresetPath(PRESET_VUE_SCSS);
|
|
82
|
+
const PRESET_PATH_RECESS_ORDER = resolvePresetPath(PRESET_RECESS_ORDER);
|
|
106
83
|
function resolvePresetExtends(presets) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
entries.push(PRESET_PATH_VUE_SCSS);
|
|
113
|
-
}
|
|
114
|
-
if (presets?.order !== false) {
|
|
115
|
-
entries.push(PRESET_PATH_RECESS_ORDER);
|
|
116
|
-
}
|
|
117
|
-
return entries;
|
|
84
|
+
const entries = [];
|
|
85
|
+
if (presets?.scss !== false) entries.push(PRESET_PATH_STANDARD_SCSS);
|
|
86
|
+
if (presets?.vue !== false) entries.push(PRESET_PATH_VUE_SCSS);
|
|
87
|
+
if (presets?.order !== false) entries.push(PRESET_PATH_RECESS_ORDER);
|
|
88
|
+
return entries;
|
|
118
89
|
}
|
|
119
90
|
function resolveExtends(options) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return normalizeExtends(values);
|
|
91
|
+
const presets = resolvePresetExtends(options?.presets);
|
|
92
|
+
const extras = toArray(options?.extends);
|
|
93
|
+
return normalizeExtends(unique([...presets, ...extras]));
|
|
124
94
|
}
|
|
125
95
|
function resolveOverrides(options) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
return [...overrides];
|
|
96
|
+
const overrides = options?.overrides;
|
|
97
|
+
if (!overrides || overrides.length === 0) return [];
|
|
98
|
+
return [...overrides];
|
|
131
99
|
}
|
|
132
100
|
function resolveRules(options) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
ignoreTypes
|
|
155
|
-
}
|
|
156
|
-
],
|
|
157
|
-
"at-rule-no-deprecated": [
|
|
158
|
-
true,
|
|
159
|
-
{
|
|
160
|
-
ignoreAtRules
|
|
161
|
-
}
|
|
162
|
-
],
|
|
163
|
-
"scss/selector-no-redundant-nesting-selector": true,
|
|
164
|
-
"scss/at-rule-no-unknown": [
|
|
165
|
-
true,
|
|
166
|
-
{
|
|
167
|
-
ignoreAtRules
|
|
168
|
-
}
|
|
169
|
-
]
|
|
170
|
-
};
|
|
171
|
-
if (options?.rules) {
|
|
172
|
-
return {
|
|
173
|
-
...rules,
|
|
174
|
-
...options.rules
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
return rules;
|
|
101
|
+
const ignoreUnits = resolveIgnoreList("units", options?.ignores);
|
|
102
|
+
const ignoreTypes = resolveIgnoreList("types", options?.ignores);
|
|
103
|
+
const ignoreAtRules = resolveIgnoreList("atRules", options?.ignores);
|
|
104
|
+
const rules = {
|
|
105
|
+
"function-name-case": null,
|
|
106
|
+
"media-feature-range-notation": "prefix",
|
|
107
|
+
"selector-class-pattern": [new RegExp(BEM_OOCSS_CLASS_NAME_PATTERN), {
|
|
108
|
+
message: "Use BEM/OOCSS-friendly class names",
|
|
109
|
+
resolveNestedSelectors: true
|
|
110
|
+
}],
|
|
111
|
+
"unit-no-unknown": [true, { ignoreUnits }],
|
|
112
|
+
"selector-type-no-unknown": [true, { ignoreTypes }],
|
|
113
|
+
"at-rule-no-deprecated": [true, { ignoreAtRules }],
|
|
114
|
+
"scss/selector-no-redundant-nesting-selector": true,
|
|
115
|
+
"scss/at-rule-no-unknown": [true, { ignoreAtRules }]
|
|
116
|
+
};
|
|
117
|
+
if (options?.rules) return {
|
|
118
|
+
...rules,
|
|
119
|
+
...options.rules
|
|
120
|
+
};
|
|
121
|
+
return rules;
|
|
178
122
|
}
|
|
179
123
|
function createIcebreakerStylelintConfig(options = {}) {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
124
|
+
const extendsConfig = resolveExtends(options);
|
|
125
|
+
const overrides = resolveOverrides(options);
|
|
126
|
+
const rules = resolveRules(options);
|
|
127
|
+
return {
|
|
128
|
+
...extendsConfig !== void 0 ? { extends: extendsConfig } : {},
|
|
129
|
+
plugins: [...recommended.plugins ?? []],
|
|
130
|
+
overrides,
|
|
131
|
+
rules: {
|
|
132
|
+
[noAtomicClassRuleName]: true,
|
|
133
|
+
[noInvalidApplyRuleName]: true,
|
|
134
|
+
[noApplyRuleName]: true,
|
|
135
|
+
[noArbitraryValueRuleName]: true,
|
|
136
|
+
...rules
|
|
137
|
+
}
|
|
138
|
+
};
|
|
188
139
|
}
|
|
189
|
-
|
|
190
|
-
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/index.ts
|
|
191
142
|
function mergeConfigs(base, overrides) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
143
|
+
if (!overrides) return base;
|
|
144
|
+
const basePlugins = Array.isArray(base.plugins) ? base.plugins : base.plugins ? [base.plugins] : [];
|
|
145
|
+
const overridePlugins = Array.isArray(overrides.plugins) ? overrides.plugins : overrides.plugins ? [overrides.plugins] : [];
|
|
146
|
+
return {
|
|
147
|
+
...base,
|
|
148
|
+
...overrides,
|
|
149
|
+
plugins: [...basePlugins, ...overridePlugins],
|
|
150
|
+
rules: {
|
|
151
|
+
...base.rules ?? {},
|
|
152
|
+
...overrides.rules ?? {}
|
|
153
|
+
}
|
|
154
|
+
};
|
|
203
155
|
}
|
|
204
156
|
function icebreaker(config) {
|
|
205
|
-
|
|
206
|
-
return mergeConfigs(base, config);
|
|
157
|
+
return mergeConfigs(createIcebreakerStylelintConfig(), config);
|
|
207
158
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
icebreaker
|
|
211
|
-
};
|
|
159
|
+
//#endregion
|
|
160
|
+
export { createIcebreakerStylelintConfig as createStylelintConfig, icebreaker };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icebreakers/stylelint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.5",
|
|
5
5
|
"description": "Stylelint preset from Icebreaker's dev-configs",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -35,6 +35,8 @@
|
|
|
35
35
|
"types": "./dist/index.d.ts",
|
|
36
36
|
"bin": "./bin/init.js",
|
|
37
37
|
"files": [
|
|
38
|
+
"README.md",
|
|
39
|
+
"README.zh.md",
|
|
38
40
|
"bin",
|
|
39
41
|
"dist"
|
|
40
42
|
],
|
|
@@ -44,16 +46,25 @@
|
|
|
44
46
|
"stylelint-config-recess-order": "^7.6.1",
|
|
45
47
|
"stylelint-config-recommended-scss": "^17.0.0",
|
|
46
48
|
"stylelint-config-recommended-vue": "^1.6.1",
|
|
47
|
-
"stylelint-config-standard-scss": "^17.0.0"
|
|
49
|
+
"stylelint-config-standard-scss": "^17.0.0",
|
|
50
|
+
"stylelint-plugin-tailwindcss": "0.0.1"
|
|
48
51
|
},
|
|
49
52
|
"publishConfig": {
|
|
50
53
|
"access": "public",
|
|
51
54
|
"registry": "https://registry.npmjs.org"
|
|
52
55
|
},
|
|
56
|
+
"tsd": {
|
|
57
|
+
"directory": "test-d",
|
|
58
|
+
"compilerOptions": {
|
|
59
|
+
"module": "node16",
|
|
60
|
+
"skipLibCheck": true
|
|
61
|
+
}
|
|
62
|
+
},
|
|
53
63
|
"scripts": {
|
|
54
|
-
"dev": "
|
|
55
|
-
"build": "
|
|
64
|
+
"dev": "tsdown --watch --sourcemap",
|
|
65
|
+
"build": "tsdown",
|
|
56
66
|
"test": "vitest run",
|
|
67
|
+
"test:types": "tsd",
|
|
57
68
|
"test:dev": "vitest",
|
|
58
69
|
"release": "pnpm publish",
|
|
59
70
|
"sync": "cnpm sync @icebreakers/stylelint-config",
|