@icebreakers/eslint-config 1.6.33 → 2.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/README.md CHANGED
@@ -72,6 +72,45 @@ export default icebreaker({
72
72
  - `formatters` – keeps the built-in formatting rules enabled by default.
73
73
  - `test` – relaxes certain Vitest/Jest style rules (`test/prefer-lowercase-title`).
74
74
 
75
+ ### Stylelint Bridge
76
+
77
+ `@icebreakers/eslint-config` bundles the Stylelint bridge and uses
78
+ `@icebreakers/stylelint-config` as the default Stylelint preset when you opt in.
79
+ The bridge is still disabled by default. Turn it on with `stylelint: true` to
80
+ lint `*.css`, `*.scss`, and `.vue` style blocks through ESLint:
81
+
82
+ ```ts
83
+ import { icebreaker } from '@icebreakers/eslint-config'
84
+
85
+ export default icebreaker({
86
+ vue: true,
87
+ stylelint: true,
88
+ })
89
+ ```
90
+
91
+ You can also inline Stylelint preset options directly in `eslint.config.ts`:
92
+
93
+ ```ts
94
+ import { icebreaker } from '@icebreakers/eslint-config'
95
+
96
+ export default icebreaker({
97
+ vue: true,
98
+ stylelint: {
99
+ cwd: process.cwd(),
100
+ presets: {
101
+ order: false,
102
+ },
103
+ rules: {
104
+ 'color-named': 'never',
105
+ },
106
+ },
107
+ })
108
+ ```
109
+
110
+ `stylelint.cwd` changes the resolution root, and the remaining fields follow
111
+ the `@icebreakers/stylelint-config` options (`presets`, `tailwindcssPreset`,
112
+ `ignores`, `extends`, `overrides`, `rules`).
113
+
75
114
  ### NestJS Projects
76
115
 
77
116
  Enable `nestjs: true` together with the TypeScript preset to apply rules tailored for Nest idioms:
package/README.zh.md CHANGED
@@ -70,6 +70,48 @@ export default icebreaker({
70
70
  - `formatters`:默认启用格式化辅助规则。
71
71
  - `test`:放宽 Vitest / Jest 常见规则,例如关闭 `test/prefer-lowercase-title`。
72
72
 
73
+ ### Stylelint 桥接
74
+
75
+ `@icebreakers/eslint-config` 已内置 Stylelint bridge,并在启用时默认使用
76
+ `@icebreakers/stylelint-config` 作为 Stylelint 预设;但 bridge 默认仍是关闭的。
77
+ 设置 `stylelint: true` 后,会把 Stylelint 诊断桥接到 ESLint,用于:
78
+
79
+ - `*.css`
80
+ - `*.scss`
81
+ - `.vue` 文件里的 `<style>` 块
82
+
83
+ ```ts
84
+ import { icebreaker } from '@icebreakers/eslint-config'
85
+
86
+ export default icebreaker({
87
+ vue: true,
88
+ stylelint: true,
89
+ })
90
+ ```
91
+
92
+ 也可以直接把 Stylelint 预设配置写进 `eslint.config.ts`:
93
+
94
+ ```ts
95
+ import { icebreaker } from '@icebreakers/eslint-config'
96
+
97
+ export default icebreaker({
98
+ vue: true,
99
+ stylelint: {
100
+ cwd: process.cwd(),
101
+ presets: {
102
+ order: false,
103
+ },
104
+ rules: {
105
+ 'color-named': 'never',
106
+ },
107
+ },
108
+ })
109
+ ```
110
+
111
+ 其中 `stylelint.cwd` 用来指定配置解析根目录,其余字段沿用
112
+ `@icebreakers/stylelint-config` 的选项结构,例如 `presets`、
113
+ `tailwindcssPreset`、`ignores`、`extends`、`overrides`、`rules`。
114
+
73
115
  ### NestJS 项目
74
116
 
75
117
  建议在 Nest 项目中同时开启 `typescript` 与 `nestjs`,以便应用以下定制:
package/dist/index.cjs CHANGED
@@ -149,6 +149,9 @@ function getDefaultTypescriptOptions(opts) {
149
149
  }
150
150
  //#endregion
151
151
  //#region src/features.ts
152
+ function resolveStylelintConfigLoader() {
153
+ return require("url").pathToFileURL(__filename).href.endsWith(".ts") ? new URL("./stylelint.ts", require("url").pathToFileURL(__filename).href).href : new URL("./stylelint.js", require("url").pathToFileURL(__filename).href).href;
154
+ }
152
155
  function resolveTailwindPresets(option) {
153
156
  if (!option) return [];
154
157
  if (typeof option === "object") return [(0, antfu_exports.interopDefault)(import("eslint-plugin-better-tailwindcss")).then((eslintPluginBetterTailwindcss) => {
@@ -170,6 +173,42 @@ function resolveTailwindPresets(option) {
170
173
  return tailwind.configs["flat/recommended"];
171
174
  }), { rules: { "tailwindcss/no-custom-classname": "off" } }];
172
175
  }
176
+ function resolveStylelintBridgeOptions(option) {
177
+ const { cwd, ...stylelintConfigOptions } = typeof option === "object" ? option : {};
178
+ return {
179
+ ...cwd ? { cwd } : {},
180
+ configLoader: resolveStylelintConfigLoader(),
181
+ configOptions: stylelintConfigOptions
182
+ };
183
+ }
184
+ function resolveStylelintBridgePresets(option) {
185
+ if (!option) return [];
186
+ const pluginModulePromise = import("eslint-plugin-better-stylelint");
187
+ const stylelintOptions = resolveStylelintBridgeOptions(option);
188
+ return [
189
+ pluginModulePromise.then((pluginModule) => {
190
+ return {
191
+ files: ["**/*.{css,pcss,postcss}"],
192
+ plugins: { stylelint: pluginModule.default },
193
+ processor: pluginModule.createStylelintProcessor(stylelintOptions)
194
+ };
195
+ }),
196
+ pluginModulePromise.then((pluginModule) => {
197
+ return {
198
+ files: ["**/*.{scss,sass}"],
199
+ plugins: { stylelint: pluginModule.default },
200
+ processor: pluginModule.createStylelintProcessor(stylelintOptions)
201
+ };
202
+ }),
203
+ pluginModulePromise.then((pluginModule) => {
204
+ return {
205
+ files: ["**/*.vue"],
206
+ plugins: { stylelint: pluginModule.default },
207
+ rules: { "stylelint/stylelint": ["error", stylelintOptions] }
208
+ };
209
+ })
210
+ ];
211
+ }
173
212
  function resolveMdxPresets(isEnabled) {
174
213
  if (!isEnabled) return [];
175
214
  return [(0, antfu_exports.interopDefault)(import("eslint-plugin-mdx")).then((mdx) => {
@@ -435,7 +474,7 @@ function getPresets(options, mode) {
435
474
  files: ["**/*.{css,scss,sass,less,pcss,postcss,json,jsonc,json5}"],
436
475
  rules: { "style/eol-last": "off" }
437
476
  }];
438
- presets.push(...resolveTailwindPresets(resolved.tailwindcss), ...resolveMdxPresets(resolved.mdx), ...resolveNestPresets(resolved.nestjs), ...resolveQueryPresets(resolved.query), ...resolveAccessibilityPresets(resolved.a11y, resolved.vue, resolved.react));
477
+ presets.push(...resolveStylelintBridgePresets(resolved.stylelint), ...resolveTailwindPresets(resolved.tailwindcss), ...resolveMdxPresets(resolved.mdx), ...resolveNestPresets(resolved.nestjs), ...resolveQueryPresets(resolved.query), ...resolveAccessibilityPresets(resolved.a11y, resolved.vue, resolved.react));
439
478
  return [resolved, ...presets];
440
479
  }
441
480
  //#endregion
@@ -447,6 +486,7 @@ function icebreakerLegacy(options = {}, ...userConfigs) {
447
486
  return (0, antfu_exports.antfu)(...getPresets(options, "legacy"), ...userConfigs);
448
487
  }
449
488
  //#endregion
489
+ exports.__toESM = __toESM;
450
490
  exports.getPresets = getPresets;
451
491
  exports.icebreaker = icebreaker;
452
492
  exports.icebreakerLegacy = icebreakerLegacy;
package/dist/index.d.cts CHANGED
@@ -2922,12 +2922,21 @@ interface TailwindcssOption {
2922
2922
  tailwindConfig?: string;
2923
2923
  }
2924
2924
  type TailwindcssConfig = boolean | TailwindcssOption;
2925
+ interface StylelintBridgeOption {
2926
+ cwd?: string;
2927
+ }
2928
+ type StylelintBridgeConfig = boolean | StylelintBridgeOption;
2925
2929
  type UserDefinedOptions = OptionsConfig & TypedFlatConfigItem$1 & {
2926
2930
  /**
2927
2931
  * Enable TailwindCSS support
2928
2932
  * @default false
2929
2933
  */
2930
2934
  tailwindcss?: TailwindcssConfig;
2935
+ /**
2936
+ * Bridge Stylelint diagnostics into ESLint for style files.
2937
+ * @default false
2938
+ */
2939
+ stylelint?: StylelintBridgeConfig;
2931
2940
  /**
2932
2941
  * Enable MDX support
2933
2942
  * @default false
@@ -2968,4 +2977,4 @@ declare function icebreakerLegacy(options?: UserDefinedOptions, ...userConfigs:
2968
2977
  //#region src/preset.d.ts
2969
2978
  declare function getPresets(options?: UserDefinedOptions, mode?: 'legacy'): [UserDefinedOptions, ...UserConfigItem[]];
2970
2979
  //#endregion
2971
- export { type ConfigNames, type FlatConfigComposer, type TailwindcssConfig, type TailwindcssOption, type TypedFlatConfigItem, type UserConfigItem, type UserDefinedOptions, getPresets, icebreaker, icebreakerLegacy };
2980
+ export { type ConfigNames, type FlatConfigComposer, type StylelintBridgeConfig, type StylelintBridgeOption, type TailwindcssConfig, type TailwindcssOption, type TypedFlatConfigItem, type UserConfigItem, type UserDefinedOptions, getPresets, icebreaker, icebreakerLegacy };
package/dist/index.d.ts CHANGED
@@ -2922,12 +2922,21 @@ interface TailwindcssOption {
2922
2922
  tailwindConfig?: string;
2923
2923
  }
2924
2924
  type TailwindcssConfig = boolean | TailwindcssOption;
2925
+ interface StylelintBridgeOption {
2926
+ cwd?: string;
2927
+ }
2928
+ type StylelintBridgeConfig = boolean | StylelintBridgeOption;
2925
2929
  type UserDefinedOptions = OptionsConfig & TypedFlatConfigItem$1 & {
2926
2930
  /**
2927
2931
  * Enable TailwindCSS support
2928
2932
  * @default false
2929
2933
  */
2930
2934
  tailwindcss?: TailwindcssConfig;
2935
+ /**
2936
+ * Bridge Stylelint diagnostics into ESLint for style files.
2937
+ * @default false
2938
+ */
2939
+ stylelint?: StylelintBridgeConfig;
2931
2940
  /**
2932
2941
  * Enable MDX support
2933
2942
  * @default false
@@ -2968,4 +2977,4 @@ declare function icebreakerLegacy(options?: UserDefinedOptions, ...userConfigs:
2968
2977
  //#region src/preset.d.ts
2969
2978
  declare function getPresets(options?: UserDefinedOptions, mode?: 'legacy'): [UserDefinedOptions, ...UserConfigItem[]];
2970
2979
  //#endregion
2971
- export { type ConfigNames, type FlatConfigComposer, type TailwindcssConfig, type TailwindcssOption, type TypedFlatConfigItem, type UserConfigItem, type UserDefinedOptions, getPresets, icebreaker, icebreakerLegacy };
2980
+ export { type ConfigNames, type FlatConfigComposer, type StylelintBridgeConfig, type StylelintBridgeOption, type TailwindcssConfig, type TailwindcssOption, type TypedFlatConfigItem, type UserConfigItem, type UserDefinedOptions, getPresets, icebreaker, icebreakerLegacy };
package/dist/index.js CHANGED
@@ -140,6 +140,9 @@ function getDefaultTypescriptOptions(opts) {
140
140
  }
141
141
  //#endregion
142
142
  //#region src/features.ts
143
+ function resolveStylelintConfigLoader() {
144
+ return import.meta.url.endsWith(".ts") ? new URL("./stylelint.ts", import.meta.url).href : new URL("./stylelint.js", import.meta.url).href;
145
+ }
143
146
  function resolveTailwindPresets(option) {
144
147
  if (!option) return [];
145
148
  if (typeof option === "object") return [(0, antfu_exports.interopDefault)(import("eslint-plugin-better-tailwindcss")).then((eslintPluginBetterTailwindcss) => {
@@ -161,6 +164,42 @@ function resolveTailwindPresets(option) {
161
164
  return tailwind.configs["flat/recommended"];
162
165
  }), { rules: { "tailwindcss/no-custom-classname": "off" } }];
163
166
  }
167
+ function resolveStylelintBridgeOptions(option) {
168
+ const { cwd, ...stylelintConfigOptions } = typeof option === "object" ? option : {};
169
+ return {
170
+ ...cwd ? { cwd } : {},
171
+ configLoader: resolveStylelintConfigLoader(),
172
+ configOptions: stylelintConfigOptions
173
+ };
174
+ }
175
+ function resolveStylelintBridgePresets(option) {
176
+ if (!option) return [];
177
+ const pluginModulePromise = import("eslint-plugin-better-stylelint");
178
+ const stylelintOptions = resolveStylelintBridgeOptions(option);
179
+ return [
180
+ pluginModulePromise.then((pluginModule) => {
181
+ return {
182
+ files: ["**/*.{css,pcss,postcss}"],
183
+ plugins: { stylelint: pluginModule.default },
184
+ processor: pluginModule.createStylelintProcessor(stylelintOptions)
185
+ };
186
+ }),
187
+ pluginModulePromise.then((pluginModule) => {
188
+ return {
189
+ files: ["**/*.{scss,sass}"],
190
+ plugins: { stylelint: pluginModule.default },
191
+ processor: pluginModule.createStylelintProcessor(stylelintOptions)
192
+ };
193
+ }),
194
+ pluginModulePromise.then((pluginModule) => {
195
+ return {
196
+ files: ["**/*.vue"],
197
+ plugins: { stylelint: pluginModule.default },
198
+ rules: { "stylelint/stylelint": ["error", stylelintOptions] }
199
+ };
200
+ })
201
+ ];
202
+ }
164
203
  function resolveMdxPresets(isEnabled) {
165
204
  if (!isEnabled) return [];
166
205
  return [(0, antfu_exports.interopDefault)(import("eslint-plugin-mdx")).then((mdx) => {
@@ -426,7 +465,7 @@ function getPresets(options, mode) {
426
465
  files: ["**/*.{css,scss,sass,less,pcss,postcss,json,jsonc,json5}"],
427
466
  rules: { "style/eol-last": "off" }
428
467
  }];
429
- presets.push(...resolveTailwindPresets(resolved.tailwindcss), ...resolveMdxPresets(resolved.mdx), ...resolveNestPresets(resolved.nestjs), ...resolveQueryPresets(resolved.query), ...resolveAccessibilityPresets(resolved.a11y, resolved.vue, resolved.react));
468
+ presets.push(...resolveStylelintBridgePresets(resolved.stylelint), ...resolveTailwindPresets(resolved.tailwindcss), ...resolveMdxPresets(resolved.mdx), ...resolveNestPresets(resolved.nestjs), ...resolveQueryPresets(resolved.query), ...resolveAccessibilityPresets(resolved.a11y, resolved.vue, resolved.react));
430
469
  return [resolved, ...presets];
431
470
  }
432
471
  //#endregion
@@ -0,0 +1,9 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("./index.cjs");
3
+ let _icebreakers_stylelint_config = require("@icebreakers/stylelint-config");
4
+ //#region src/stylelint.ts
5
+ function resolveStylelintConfig(options = {}) {
6
+ return (0, _icebreakers_stylelint_config.createStylelintConfig)(options);
7
+ }
8
+ //#endregion
9
+ exports.resolveStylelintConfig = resolveStylelintConfig;
@@ -0,0 +1,6 @@
1
+ import { IcebreakerStylelintOptions, IcebreakerStylelintOptions as IcebreakerStylelintOptions$1, createStylelintConfig } from "@icebreakers/stylelint-config";
2
+
3
+ //#region src/stylelint.d.ts
4
+ declare function resolveStylelintConfig(options?: IcebreakerStylelintOptions$1): ReturnType<typeof createStylelintConfig>;
5
+ //#endregion
6
+ export { type IcebreakerStylelintOptions, resolveStylelintConfig };
@@ -0,0 +1,6 @@
1
+ import { IcebreakerStylelintOptions, IcebreakerStylelintOptions as IcebreakerStylelintOptions$1, createStylelintConfig } from "@icebreakers/stylelint-config";
2
+
3
+ //#region src/stylelint.d.ts
4
+ declare function resolveStylelintConfig(options?: IcebreakerStylelintOptions$1): ReturnType<typeof createStylelintConfig>;
5
+ //#endregion
6
+ export { type IcebreakerStylelintOptions, resolveStylelintConfig };
@@ -0,0 +1,7 @@
1
+ import { createStylelintConfig } from "@icebreakers/stylelint-config";
2
+ //#region src/stylelint.ts
3
+ function resolveStylelintConfig(options = {}) {
4
+ return createStylelintConfig(options);
5
+ }
6
+ //#endregion
7
+ export { resolveStylelintConfig };
package/index.d.ts CHANGED
@@ -13,9 +13,14 @@ export interface TailwindcssOption {
13
13
  }
14
14
 
15
15
  export type TailwindcssConfig = boolean | TailwindcssOption
16
+ export interface StylelintBridgeOption {
17
+ cwd?: string
18
+ }
19
+ export type StylelintBridgeConfig = boolean | StylelintBridgeOption
16
20
 
17
21
  export type UserDefinedOptions = OptionsConfig & TypedFlatConfigItem & {
18
22
  tailwindcss?: TailwindcssConfig
23
+ stylelint?: StylelintBridgeConfig
19
24
  mdx?: boolean
20
25
  a11y?: boolean
21
26
  nestjs?: boolean
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@icebreakers/eslint-config",
3
3
  "type": "module",
4
- "version": "1.6.33",
4
+ "version": "2.0.1",
5
5
  "description": "ESLint preset from Icebreaker's dev-configs",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -24,6 +24,11 @@
24
24
  "import": "./dist/index.js",
25
25
  "require": "./dist/index.cjs"
26
26
  },
27
+ "./stylelint": {
28
+ "types": "./dist/stylelint.d.ts",
29
+ "import": "./dist/stylelint.js",
30
+ "require": "./dist/stylelint.cjs"
31
+ },
27
32
  "./*": "./*"
28
33
  },
29
34
  "main": "./dist/index.cjs",
@@ -44,18 +49,20 @@
44
49
  "dependencies": {
45
50
  "@antfu/eslint-config": "7.7.3",
46
51
  "@eslint-react/eslint-plugin": "^3.0.0",
47
- "@next/eslint-plugin-next": "^16.1.7",
48
- "@tanstack/eslint-plugin-query": "^5.91.4",
52
+ "@next/eslint-plugin-next": "^16.2.0",
53
+ "@tanstack/eslint-plugin-query": "^5.91.5",
49
54
  "eslint-plugin-better-tailwindcss": "^4.3.2",
50
55
  "eslint-plugin-format": "2.0.1",
51
56
  "eslint-plugin-jsx-a11y": "^6.10.2",
52
57
  "eslint-plugin-react-hooks": "^7.0.1",
53
58
  "eslint-plugin-react-refresh": "^0.5.2",
54
59
  "eslint-plugin-tailwindcss": "3.18.2",
55
- "eslint-plugin-vuejs-accessibility": "^2.5.0"
60
+ "eslint-plugin-vuejs-accessibility": "^2.5.0",
61
+ "@icebreakers/stylelint-config": "2.1.0",
62
+ "eslint-plugin-better-stylelint": "0.1.1"
56
63
  },
57
64
  "optionalDependencies": {
58
- "@unocss/eslint-plugin": "66.6.6",
65
+ "@unocss/eslint-plugin": "66.6.7",
59
66
  "eslint-plugin-mdx": "3.7.0"
60
67
  },
61
68
  "publishConfig": {
@@ -65,6 +72,8 @@
65
72
  "tsd": {
66
73
  "directory": "test-d",
67
74
  "compilerOptions": {
75
+ "module": "esnext",
76
+ "moduleResolution": "bundler",
68
77
  "skipLibCheck": true
69
78
  }
70
79
  },