@icebreakers/stylelint-config 2.0.6 → 2.0.7
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 +2 -2
- package/README.zh.md +2 -2
- package/dist/cli.js +18 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ For new projects you can scaffold the VS Code integration:
|
|
|
23
23
|
npx @icebreakers/stylelint-config
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
The CLI will create or update `.vscode/settings.json` with the proper `stylelint.validate` entries so editor diagnostics use Stylelint instead of language servers.
|
|
26
|
+
The CLI will create or update `.vscode/settings.json` with the proper `stylelint.validate` entries so editor diagnostics use Stylelint instead of language servers. It also removes CSS-like languages (`css`, `less`, `scss`, `pcss`, `postcss`) from `eslint.validate` to avoid ESLint and Stylelint fighting over the same file on save.
|
|
27
27
|
|
|
28
28
|
## Basic Usage
|
|
29
29
|
|
|
@@ -114,4 +114,4 @@ The underlying plugin supports both Tailwind CSS v3 and v4, and switches automat
|
|
|
114
114
|
|
|
115
115
|
- Tailwind directives require `postcss.config.*` to include `@icebreakers/stylelint-config` ignore lists; adjust `ignores.addAtRules` when adding new utilities.
|
|
116
116
|
- If Stylelint cannot resolve the preset, ensure your workspace hoists the package or add it to the specific package `devDependencies`.
|
|
117
|
-
- Use the generated VS Code settings to avoid duplicate diagnostics from the built-in CSS validation.
|
|
117
|
+
- Use the generated VS Code settings to avoid duplicate diagnostics from the built-in CSS validation and from ESLint handling CSS files.
|
package/README.zh.md
CHANGED
|
@@ -21,7 +21,7 @@ pnpm add -D stylelint @icebreakers/stylelint-config
|
|
|
21
21
|
npx @icebreakers/stylelint-config
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
该命令会创建或更新 `.vscode/settings.json`,为 VS Code 添加 `stylelint.validate` 条目,确保代码诊断来自 Stylelint 而非内置 CSS
|
|
24
|
+
该命令会创建或更新 `.vscode/settings.json`,为 VS Code 添加 `stylelint.validate` 条目,确保代码诊断来自 Stylelint 而非内置 CSS 校验器。同时它会把 `css`、`less`、`scss`、`pcss`、`postcss` 从 `eslint.validate` 中移除,避免 ESLint 与 Stylelint 在保存时同时改同一个样式文件。
|
|
25
25
|
|
|
26
26
|
## 基本用法
|
|
27
27
|
|
|
@@ -112,4 +112,4 @@ tailwindcss/no-arbitrary-value
|
|
|
112
112
|
|
|
113
113
|
- Tailwind 指令需要在 `postcss.config.*` 中配合忽略列表,否则可能误报,可通过 `ignores.addAtRules` 添加新指令。
|
|
114
114
|
- 如果 Stylelint 无法解析预设,请确认包已安装在当前 workspace 的 `devDependencies` 中,或已正确 hoist。
|
|
115
|
-
- 建议使用 CLI 生成的 VS Code 设置,避免内置 CSS
|
|
115
|
+
- 建议使用 CLI 生成的 VS Code 设置,避免内置 CSS 校验、ESLint 与 Stylelint 对样式文件重复报错或冲突修复。
|
package/dist/cli.js
CHANGED
|
@@ -3,6 +3,18 @@ import fs from "node:fs";
|
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
4
|
import jsonc from "comment-json";
|
|
5
5
|
//#region src/shared.ts
|
|
6
|
+
const STYLELINT_LANGUAGES = [
|
|
7
|
+
"vue",
|
|
8
|
+
"css",
|
|
9
|
+
"scss"
|
|
10
|
+
];
|
|
11
|
+
const ESLINT_STYLE_LANGUAGES = [
|
|
12
|
+
"css",
|
|
13
|
+
"less",
|
|
14
|
+
"scss",
|
|
15
|
+
"pcss",
|
|
16
|
+
"postcss"
|
|
17
|
+
];
|
|
6
18
|
function asStringArray(value) {
|
|
7
19
|
if (!Array.isArray(value)) return [];
|
|
8
20
|
return value.filter((entry) => typeof entry === "string");
|
|
@@ -12,10 +24,13 @@ function setVscodeSettingsJson(json = {}) {
|
|
|
12
24
|
json["less.validate"] = false;
|
|
13
25
|
json["scss.validate"] = false;
|
|
14
26
|
const existing = new Set(asStringArray(json["stylelint.validate"]));
|
|
15
|
-
existing.add(
|
|
16
|
-
|
|
17
|
-
|
|
27
|
+
for (const language of STYLELINT_LANGUAGES) existing.add(language);
|
|
28
|
+
const eslintValidate = asStringArray(json["eslint.validate"]).filter((language) => {
|
|
29
|
+
return !ESLINT_STYLE_LANGUAGES.includes(language);
|
|
30
|
+
});
|
|
18
31
|
json["stylelint.validate"] = [...existing];
|
|
32
|
+
if (eslintValidate.length > 0) json["eslint.validate"] = eslintValidate;
|
|
33
|
+
else delete json["eslint.validate"];
|
|
19
34
|
return json;
|
|
20
35
|
}
|
|
21
36
|
//#endregion
|
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.7",
|
|
5
5
|
"description": "Stylelint preset from Icebreaker's dev-configs",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"stylelint-config-recommended-scss": "^17.0.0",
|
|
48
48
|
"stylelint-config-recommended-vue": "^1.6.1",
|
|
49
49
|
"stylelint-config-standard-scss": "^17.0.0",
|
|
50
|
-
"stylelint-plugin-tailwindcss": "0.0.
|
|
50
|
+
"stylelint-plugin-tailwindcss": "0.0.3"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public",
|