@icebreakers/stylelint-config 2.0.4 → 2.0.6

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 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
- // src/cli.ts
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
- if (!Array.isArray(value)) {
10
- return [];
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(json2 = {}) {
15
- json2["css.validate"] = false;
16
- json2["less.validate"] = false;
17
- json2["scss.validate"] = false;
18
- const existing = new Set(asStringArray(json2["stylelint.validate"]));
19
- existing.add("vue");
20
- existing.add("css");
21
- existing.add("scss");
22
- json2["stylelint.validate"] = [...existing];
23
- return json2;
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
- // src/cli.ts
27
- var cwd = process.cwd();
28
- fs.mkdirSync(resolve(cwd, ".vscode"), {
29
- recursive: true
30
- });
31
- var vscodeSettingsFilename = resolve(cwd, ".vscode/settings.json");
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
- const value = jsonc.parse(fs.readFileSync(vscodeSettingsFilename, "utf8"));
36
- if (value) {
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
- import { Config } from 'stylelint';
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
- /** Include rules for SCSS syntax. Enabled by default. */
5
- scss?: boolean;
6
- /** Include Vue-specific recommendations. Enabled by default. */
7
- vue?: boolean;
8
- /** Enforce property ordering via recess-order. Enabled by default. */
9
- order?: boolean;
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
- /** Replace the default ignore-at-rules list. */
13
- atRules?: string[];
14
- /** Replace the default ignore selector types list. */
15
- types?: string[];
16
- /** Replace the default ignore units list. */
17
- units?: string[];
18
- /** Additional at-rules to ignore. */
19
- addAtRules?: string[];
20
- /** Additional selector types to ignore. */
21
- addTypes?: string[];
22
- /** Additional units to ignore. */
23
- addUnits?: string[];
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
- /** Toggle built-in preset bundles. */
27
- presets?: PresetToggles;
28
- /** Append extra extends entries. */
29
- extends?: Config['extends'];
30
- /** Append override entries. */
31
- overrides?: Config['overrides'];
32
- /** Provide additional or replacement rule ignore lists. */
33
- ignores?: IgnoreListOptions;
34
- /** Override or add rules. */
35
- rules?: Config['rules'];
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
- declare function createIcebreakerStylelintConfig(options?: IcebreakerStylelintOptions): Config;
39
-
40
- declare function icebreaker(config?: Config): Config;
41
-
42
- export { type IcebreakerStylelintOptions, type IgnoreListOptions, type PresetToggles, createIcebreakerStylelintConfig as createStylelintConfig, icebreaker };
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,212 +1,160 @@
1
- // src/config.ts
2
- import { createRequire } from "module";
3
- import process from "process";
4
- import { fileURLToPath } from "url";
5
-
6
- // src/constants.ts
7
- var PRESET_STANDARD_SCSS = "stylelint-config-standard-scss";
8
- var PRESET_VUE_SCSS = "stylelint-config-recommended-vue/scss";
9
- var PRESET_RECESS_ORDER = "stylelint-config-recess-order";
10
- var DEFAULT_IGNORE_AT_RULES = [
11
- "tailwind",
12
- "theme",
13
- "apply",
14
- "source",
15
- "utility",
16
- "variant",
17
- "custom-variant",
18
- "reference",
19
- "config",
20
- "plugin",
21
- "unocss"
22
- ];
23
- var DEFAULT_IGNORE_TYPES = [
24
- "page"
25
- ];
26
- var DEFAULT_IGNORE_UNITS = [
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
- var IGNORE_REPLACE_KEYS = {
37
- atRules: "atRules",
38
- types: "types",
39
- units: "units"
28
+ const IGNORE_REPLACE_KEYS = {
29
+ atRules: "atRules",
30
+ types: "types",
31
+ units: "units"
40
32
  };
41
- var IGNORE_APPEND_KEYS = {
42
- atRules: "addAtRules",
43
- types: "addTypes",
44
- units: "addUnits"
33
+ const IGNORE_APPEND_KEYS = {
34
+ atRules: "addAtRules",
35
+ types: "addTypes",
36
+ units: "addUnits"
45
37
  };
46
38
  function toArray(value) {
47
- if (value == null) {
48
- return [];
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
- const result = [];
54
- const seen = /* @__PURE__ */ new Set();
55
- for (const value of values) {
56
- if (seen.has(value)) {
57
- continue;
58
- }
59
- seen.add(value);
60
- result.push(value);
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
- const replaceKey = IGNORE_REPLACE_KEYS[kind];
66
- const appendKey = IGNORE_APPEND_KEYS[kind];
67
- const base = options?.[replaceKey];
68
- const extras = options?.[appendKey];
69
- const initial = base !== void 0 ? base : IGNORE_DEFAULTS[kind];
70
- if (!extras || extras.length === 0) {
71
- return unique(initial);
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
- if (!base || Array.isArray(base) && base.length === 0) {
77
- return void 0;
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
- // src/config.ts
86
- var requireFromConfig = createRequire(import.meta.url);
87
- var 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]+)*)*$/;
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
- const disableImportMetaResolve = process.env["ICEBREAKER_STYLELINT_DISABLE_IMPORT_META_RESOLVE"] === "1";
90
- if (!disableImportMetaResolve && typeof import.meta.resolve === "function") {
91
- try {
92
- const resolved = import.meta.resolve(specifier);
93
- return fileURLToPath(resolved);
94
- } catch {
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
- var PRESET_PATH_STANDARD_SCSS = resolvePresetPath(PRESET_STANDARD_SCSS);
104
- var PRESET_PATH_VUE_SCSS = resolvePresetPath(PRESET_VUE_SCSS);
105
- var PRESET_PATH_RECESS_ORDER = resolvePresetPath(PRESET_RECESS_ORDER);
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
- const entries = [];
108
- if (presets?.scss !== false) {
109
- entries.push(PRESET_PATH_STANDARD_SCSS);
110
- }
111
- if (presets?.vue !== false) {
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
- const presets = resolvePresetExtends(options?.presets);
121
- const extras = toArray(options?.extends);
122
- const values = unique([...presets, ...extras]);
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
- const overrides = options?.overrides;
127
- if (!overrides || overrides.length === 0) {
128
- return [];
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
- const ignoreUnits = resolveIgnoreList("units", options?.ignores);
134
- const ignoreTypes = resolveIgnoreList("types", options?.ignores);
135
- const ignoreAtRules = resolveIgnoreList("atRules", options?.ignores);
136
- const rules = {
137
- "function-name-case": null,
138
- "media-feature-range-notation": "prefix",
139
- "selector-class-pattern": [
140
- new RegExp(BEM_OOCSS_CLASS_NAME_PATTERN),
141
- {
142
- message: "Use BEM/OOCSS-friendly class names",
143
- resolveNestedSelectors: true
144
- }
145
- ],
146
- "unit-no-unknown": [
147
- true,
148
- {
149
- ignoreUnits
150
- }
151
- ],
152
- "selector-type-no-unknown": [
153
- true,
154
- {
155
- ignoreTypes
156
- }
157
- ],
158
- "at-rule-no-deprecated": [
159
- true,
160
- {
161
- ignoreAtRules
162
- }
163
- ],
164
- "scss/selector-no-redundant-nesting-selector": true,
165
- "scss/at-rule-no-unknown": [
166
- true,
167
- {
168
- ignoreAtRules
169
- }
170
- ]
171
- };
172
- if (options?.rules) {
173
- return {
174
- ...rules,
175
- ...options.rules
176
- };
177
- }
178
- 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;
179
122
  }
180
123
  function createIcebreakerStylelintConfig(options = {}) {
181
- const extendsConfig = resolveExtends(options);
182
- const overrides = resolveOverrides(options);
183
- const rules = resolveRules(options);
184
- return {
185
- ...extendsConfig !== void 0 ? { extends: extendsConfig } : {},
186
- overrides,
187
- rules
188
- };
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
+ };
189
139
  }
190
-
191
- // src/index.ts
140
+ //#endregion
141
+ //#region src/index.ts
192
142
  function mergeConfigs(base, overrides) {
193
- if (!overrides) {
194
- return base;
195
- }
196
- return {
197
- ...base,
198
- ...overrides,
199
- rules: {
200
- ...base.rules ?? {},
201
- ...overrides.rules ?? {}
202
- }
203
- };
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
+ };
204
155
  }
205
156
  function icebreaker(config) {
206
- const base = createIcebreakerStylelintConfig();
207
- return mergeConfigs(base, config);
157
+ return mergeConfigs(createIcebreakerStylelintConfig(), config);
208
158
  }
209
- export {
210
- createIcebreakerStylelintConfig as createStylelintConfig,
211
- icebreaker
212
- };
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",
4
+ "version": "2.0.6",
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.2"
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": "tsup --watch --sourcemap",
55
- "build": "tsup",
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",