@icebreakers/eslint-config 1.6.31 → 2.0.0
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 +34 -1
- package/dist/index.cjs +33 -2
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +33 -2
- package/package.json +9 -5
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
- Node.js 18 or newer
|
|
12
12
|
- ESLint 9 with flat config support
|
|
13
|
-
- Install optional peer plugins when you turn on Tailwind (`eslint-plugin-tailwindcss` or `eslint-plugin-better-tailwindcss`), MDX (`eslint-plugin-mdx`), or UnoCSS (`@unocss/eslint-plugin`)
|
|
13
|
+
- Install optional peer plugins when you turn on Tailwind (`eslint-plugin-tailwindcss` or `eslint-plugin-better-tailwindcss`), MDX (`eslint-plugin-mdx`), Stylelint bridge (`eslint-plugin-better-stylelint`), or UnoCSS (`@unocss/eslint-plugin`)
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
@@ -72,6 +72,27 @@ 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
|
+
Set `stylelint: true` to bridge Stylelint diagnostics into ESLint for
|
|
78
|
+
`*.css`, `*.scss`, and `.vue` style blocks:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
pnpm add -D eslint-plugin-better-stylelint
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
import { icebreaker } from '@icebreakers/eslint-config'
|
|
86
|
+
|
|
87
|
+
export default icebreaker({
|
|
88
|
+
vue: true,
|
|
89
|
+
stylelint: true,
|
|
90
|
+
})
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
You can also pass `stylelint: { cwd: '/path/to/project' }` if Stylelint should
|
|
94
|
+
resolve its config from a different working directory.
|
|
95
|
+
|
|
75
96
|
### NestJS Projects
|
|
76
97
|
|
|
77
98
|
Enable `nestjs: true` together with the TypeScript preset to apply rules tailored for Nest idioms:
|
package/README.zh.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
- Node.js 18 或更高版本
|
|
10
10
|
- 支持 Flat Config 的 ESLint 9
|
|
11
|
-
- 如需启用 Tailwind、MDX、UnoCSS 等,可安装对应的可选依赖:`eslint-plugin-tailwindcss` / `eslint-plugin-better-tailwindcss`、`eslint-plugin-mdx`、`@unocss/eslint-plugin`
|
|
11
|
+
- 如需启用 Tailwind、MDX、Stylelint 桥接、UnoCSS 等,可安装对应的可选依赖:`eslint-plugin-tailwindcss` / `eslint-plugin-better-tailwindcss`、`eslint-plugin-mdx`、`eslint-plugin-better-stylelint`、`@unocss/eslint-plugin`
|
|
12
12
|
|
|
13
13
|
## 安装
|
|
14
14
|
|
|
@@ -70,6 +70,39 @@ export default icebreaker({
|
|
|
70
70
|
- `formatters`:默认启用格式化辅助规则。
|
|
71
71
|
- `test`:放宽 Vitest / Jest 常见规则,例如关闭 `test/prefer-lowercase-title`。
|
|
72
72
|
|
|
73
|
+
### Stylelint 桥接
|
|
74
|
+
|
|
75
|
+
设置 `stylelint: true` 后,会把 Stylelint 诊断桥接到 ESLint,用于:
|
|
76
|
+
|
|
77
|
+
- `*.css`
|
|
78
|
+
- `*.scss`
|
|
79
|
+
- `.vue` 文件里的 `<style>` 块
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
pnpm add -D eslint-plugin-better-stylelint
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
import { icebreaker } from '@icebreakers/eslint-config'
|
|
87
|
+
|
|
88
|
+
export default icebreaker({
|
|
89
|
+
vue: true,
|
|
90
|
+
stylelint: true,
|
|
91
|
+
})
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
如果 Stylelint 需要从其它目录解析配置,也可以传:
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
import { icebreaker } from '@icebreakers/eslint-config'
|
|
98
|
+
|
|
99
|
+
export default icebreaker({
|
|
100
|
+
stylelint: {
|
|
101
|
+
cwd: '/path/to/project',
|
|
102
|
+
},
|
|
103
|
+
})
|
|
104
|
+
```
|
|
105
|
+
|
|
73
106
|
### NestJS 项目
|
|
74
107
|
|
|
75
108
|
建议在 Nest 项目中同时开启 `typescript` 与 `nestjs`,以便应用以下定制:
|
package/dist/index.cjs
CHANGED
|
@@ -170,6 +170,34 @@ function resolveTailwindPresets(option) {
|
|
|
170
170
|
return tailwind.configs["flat/recommended"];
|
|
171
171
|
}), { rules: { "tailwindcss/no-custom-classname": "off" } }];
|
|
172
172
|
}
|
|
173
|
+
function resolveStylelintBridgePresets(option) {
|
|
174
|
+
if (!option) return [];
|
|
175
|
+
const stylelintOptions = typeof option === "object" ? option : {};
|
|
176
|
+
const pluginPromise = (0, antfu_exports.interopDefault)(import("eslint-plugin-better-stylelint"));
|
|
177
|
+
return [
|
|
178
|
+
pluginPromise.then((plugin) => {
|
|
179
|
+
return {
|
|
180
|
+
files: ["**/*.{css,pcss,postcss}"],
|
|
181
|
+
plugins: { stylelint: plugin },
|
|
182
|
+
processor: "stylelint/css"
|
|
183
|
+
};
|
|
184
|
+
}),
|
|
185
|
+
pluginPromise.then((plugin) => {
|
|
186
|
+
return {
|
|
187
|
+
files: ["**/*.{scss,sass}"],
|
|
188
|
+
plugins: { stylelint: plugin },
|
|
189
|
+
processor: "stylelint/scss"
|
|
190
|
+
};
|
|
191
|
+
}),
|
|
192
|
+
pluginPromise.then((plugin) => {
|
|
193
|
+
return {
|
|
194
|
+
files: ["**/*.vue"],
|
|
195
|
+
plugins: { stylelint: plugin },
|
|
196
|
+
rules: { "stylelint/stylelint": ["error", stylelintOptions] }
|
|
197
|
+
};
|
|
198
|
+
})
|
|
199
|
+
];
|
|
200
|
+
}
|
|
173
201
|
function resolveMdxPresets(isEnabled) {
|
|
174
202
|
if (!isEnabled) return [];
|
|
175
203
|
return [(0, antfu_exports.interopDefault)(import("eslint-plugin-mdx")).then((mdx) => {
|
|
@@ -431,8 +459,11 @@ function createBaseRuleSet(isLegacy) {
|
|
|
431
459
|
//#region src/preset.ts
|
|
432
460
|
function getPresets(options, mode) {
|
|
433
461
|
const resolved = resolveUserOptions(options);
|
|
434
|
-
const presets = [{ rules: createBaseRuleSet(mode === "legacy") }
|
|
435
|
-
|
|
462
|
+
const presets = [{ rules: createBaseRuleSet(mode === "legacy") }, {
|
|
463
|
+
files: ["**/*.{css,scss,sass,less,pcss,postcss,json,jsonc,json5}"],
|
|
464
|
+
rules: { "style/eol-last": "off" }
|
|
465
|
+
}];
|
|
466
|
+
presets.push(...resolveStylelintBridgePresets(resolved.stylelint), ...resolveTailwindPresets(resolved.tailwindcss), ...resolveMdxPresets(resolved.mdx), ...resolveNestPresets(resolved.nestjs), ...resolveQueryPresets(resolved.query), ...resolveAccessibilityPresets(resolved.a11y, resolved.vue, resolved.react));
|
|
436
467
|
return [resolved, ...presets];
|
|
437
468
|
}
|
|
438
469
|
//#endregion
|
package/dist/index.d.cts
CHANGED
|
@@ -2922,12 +2922,20 @@ interface TailwindcssOption {
|
|
|
2922
2922
|
tailwindConfig?: string;
|
|
2923
2923
|
}
|
|
2924
2924
|
type TailwindcssConfig = boolean | TailwindcssOption;
|
|
2925
|
+
type StylelintBridgeConfig = boolean | {
|
|
2926
|
+
cwd?: string;
|
|
2927
|
+
};
|
|
2925
2928
|
type UserDefinedOptions = OptionsConfig & TypedFlatConfigItem$1 & {
|
|
2926
2929
|
/**
|
|
2927
2930
|
* Enable TailwindCSS support
|
|
2928
2931
|
* @default false
|
|
2929
2932
|
*/
|
|
2930
2933
|
tailwindcss?: TailwindcssConfig;
|
|
2934
|
+
/**
|
|
2935
|
+
* Bridge Stylelint diagnostics into ESLint for style files.
|
|
2936
|
+
* @default false
|
|
2937
|
+
*/
|
|
2938
|
+
stylelint?: StylelintBridgeConfig;
|
|
2931
2939
|
/**
|
|
2932
2940
|
* Enable MDX support
|
|
2933
2941
|
* @default false
|
package/dist/index.d.ts
CHANGED
|
@@ -2922,12 +2922,20 @@ interface TailwindcssOption {
|
|
|
2922
2922
|
tailwindConfig?: string;
|
|
2923
2923
|
}
|
|
2924
2924
|
type TailwindcssConfig = boolean | TailwindcssOption;
|
|
2925
|
+
type StylelintBridgeConfig = boolean | {
|
|
2926
|
+
cwd?: string;
|
|
2927
|
+
};
|
|
2925
2928
|
type UserDefinedOptions = OptionsConfig & TypedFlatConfigItem$1 & {
|
|
2926
2929
|
/**
|
|
2927
2930
|
* Enable TailwindCSS support
|
|
2928
2931
|
* @default false
|
|
2929
2932
|
*/
|
|
2930
2933
|
tailwindcss?: TailwindcssConfig;
|
|
2934
|
+
/**
|
|
2935
|
+
* Bridge Stylelint diagnostics into ESLint for style files.
|
|
2936
|
+
* @default false
|
|
2937
|
+
*/
|
|
2938
|
+
stylelint?: StylelintBridgeConfig;
|
|
2931
2939
|
/**
|
|
2932
2940
|
* Enable MDX support
|
|
2933
2941
|
* @default false
|
package/dist/index.js
CHANGED
|
@@ -161,6 +161,34 @@ function resolveTailwindPresets(option) {
|
|
|
161
161
|
return tailwind.configs["flat/recommended"];
|
|
162
162
|
}), { rules: { "tailwindcss/no-custom-classname": "off" } }];
|
|
163
163
|
}
|
|
164
|
+
function resolveStylelintBridgePresets(option) {
|
|
165
|
+
if (!option) return [];
|
|
166
|
+
const stylelintOptions = typeof option === "object" ? option : {};
|
|
167
|
+
const pluginPromise = (0, antfu_exports.interopDefault)(import("eslint-plugin-better-stylelint"));
|
|
168
|
+
return [
|
|
169
|
+
pluginPromise.then((plugin) => {
|
|
170
|
+
return {
|
|
171
|
+
files: ["**/*.{css,pcss,postcss}"],
|
|
172
|
+
plugins: { stylelint: plugin },
|
|
173
|
+
processor: "stylelint/css"
|
|
174
|
+
};
|
|
175
|
+
}),
|
|
176
|
+
pluginPromise.then((plugin) => {
|
|
177
|
+
return {
|
|
178
|
+
files: ["**/*.{scss,sass}"],
|
|
179
|
+
plugins: { stylelint: plugin },
|
|
180
|
+
processor: "stylelint/scss"
|
|
181
|
+
};
|
|
182
|
+
}),
|
|
183
|
+
pluginPromise.then((plugin) => {
|
|
184
|
+
return {
|
|
185
|
+
files: ["**/*.vue"],
|
|
186
|
+
plugins: { stylelint: plugin },
|
|
187
|
+
rules: { "stylelint/stylelint": ["error", stylelintOptions] }
|
|
188
|
+
};
|
|
189
|
+
})
|
|
190
|
+
];
|
|
191
|
+
}
|
|
164
192
|
function resolveMdxPresets(isEnabled) {
|
|
165
193
|
if (!isEnabled) return [];
|
|
166
194
|
return [(0, antfu_exports.interopDefault)(import("eslint-plugin-mdx")).then((mdx) => {
|
|
@@ -422,8 +450,11 @@ function createBaseRuleSet(isLegacy) {
|
|
|
422
450
|
//#region src/preset.ts
|
|
423
451
|
function getPresets(options, mode) {
|
|
424
452
|
const resolved = resolveUserOptions(options);
|
|
425
|
-
const presets = [{ rules: createBaseRuleSet(mode === "legacy") }
|
|
426
|
-
|
|
453
|
+
const presets = [{ rules: createBaseRuleSet(mode === "legacy") }, {
|
|
454
|
+
files: ["**/*.{css,scss,sass,less,pcss,postcss,json,jsonc,json5}"],
|
|
455
|
+
rules: { "style/eol-last": "off" }
|
|
456
|
+
}];
|
|
457
|
+
presets.push(...resolveStylelintBridgePresets(resolved.stylelint), ...resolveTailwindPresets(resolved.tailwindcss), ...resolveMdxPresets(resolved.mdx), ...resolveNestPresets(resolved.nestjs), ...resolveQueryPresets(resolved.query), ...resolveAccessibilityPresets(resolved.a11y, resolved.vue, resolved.react));
|
|
427
458
|
return [resolved, ...presets];
|
|
428
459
|
}
|
|
429
460
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icebreakers/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.0",
|
|
5
5
|
"description": "ESLint preset from Icebreaker's dev-configs",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -34,9 +34,13 @@
|
|
|
34
34
|
"index.d.ts"
|
|
35
35
|
],
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"eslint-plugin-pnpm": "^1.4.3"
|
|
37
|
+
"eslint-plugin-pnpm": "^1.4.3",
|
|
38
|
+
"eslint-plugin-better-stylelint": "0.1.0"
|
|
38
39
|
},
|
|
39
40
|
"peerDependenciesMeta": {
|
|
41
|
+
"eslint-plugin-better-stylelint": {
|
|
42
|
+
"optional": true
|
|
43
|
+
},
|
|
40
44
|
"eslint-plugin-pnpm": {
|
|
41
45
|
"optional": true
|
|
42
46
|
}
|
|
@@ -44,8 +48,8 @@
|
|
|
44
48
|
"dependencies": {
|
|
45
49
|
"@antfu/eslint-config": "7.7.3",
|
|
46
50
|
"@eslint-react/eslint-plugin": "^3.0.0",
|
|
47
|
-
"@next/eslint-plugin-next": "^16.
|
|
48
|
-
"@tanstack/eslint-plugin-query": "^5.91.
|
|
51
|
+
"@next/eslint-plugin-next": "^16.2.0",
|
|
52
|
+
"@tanstack/eslint-plugin-query": "^5.91.5",
|
|
49
53
|
"eslint-plugin-better-tailwindcss": "^4.3.2",
|
|
50
54
|
"eslint-plugin-format": "2.0.1",
|
|
51
55
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
@@ -55,7 +59,7 @@
|
|
|
55
59
|
"eslint-plugin-vuejs-accessibility": "^2.5.0"
|
|
56
60
|
},
|
|
57
61
|
"optionalDependencies": {
|
|
58
|
-
"@unocss/eslint-plugin": "66.6.
|
|
62
|
+
"@unocss/eslint-plugin": "66.6.7",
|
|
59
63
|
"eslint-plugin-mdx": "3.7.0"
|
|
60
64
|
},
|
|
61
65
|
"publishConfig": {
|