@icebreakers/stylelint-config 1.2.0 → 1.2.2
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 +53 -22
- package/README.zh.md +93 -0
- package/dist/index.cjs +14 -3
- package/dist/index.js +10 -3
- package/package.json +7 -5
package/README.md
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
# @icebreakers/stylelint-config
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
- [简体中文指南](./README.zh.md)
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Overview
|
|
6
6
|
|
|
7
|
-
|
|
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.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Requirements
|
|
10
|
+
|
|
11
|
+
- Node.js 18+
|
|
12
|
+
- Stylelint 16 (flat-compatible configuration)
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add -D stylelint @icebreakers/stylelint-config
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
For new projects you can scaffold the VS Code integration:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
10
23
|
npx @icebreakers/stylelint-config
|
|
11
24
|
```
|
|
12
25
|
|
|
13
|
-
The
|
|
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.
|
|
14
27
|
|
|
15
|
-
## Basic
|
|
28
|
+
## Basic Usage
|
|
16
29
|
|
|
17
30
|
```ts
|
|
18
31
|
// stylelint.config.ts
|
|
@@ -21,25 +34,31 @@ import { icebreaker } from '@icebreakers/stylelint-config'
|
|
|
21
34
|
export default icebreaker()
|
|
22
35
|
```
|
|
23
36
|
|
|
24
|
-
`icebreaker()`
|
|
37
|
+
`icebreaker()` returns the default preset and merges any additional Stylelint config you pass in.
|
|
25
38
|
|
|
26
|
-
## Advanced
|
|
39
|
+
## Advanced Configuration
|
|
27
40
|
|
|
28
|
-
|
|
41
|
+
Use `createStylelintConfig` for fine-grained control over preset toggles, ignore lists, and rule overrides:
|
|
29
42
|
|
|
30
43
|
```ts
|
|
31
44
|
import { createStylelintConfig } from '@icebreakers/stylelint-config'
|
|
32
45
|
|
|
33
46
|
export default createStylelintConfig({
|
|
34
47
|
presets: {
|
|
35
|
-
vue: false, //
|
|
48
|
+
vue: false, // disable Vue rules for pure SCSS projects
|
|
36
49
|
},
|
|
37
50
|
ignores: {
|
|
38
|
-
units: [], // replace
|
|
39
|
-
|
|
51
|
+
units: ['upx'], // replace default list
|
|
52
|
+
addAtRules: ['tailwind'],
|
|
40
53
|
},
|
|
41
54
|
extends: [
|
|
42
|
-
'@acme/stylelint-config
|
|
55
|
+
'@acme/stylelint-config',
|
|
56
|
+
],
|
|
57
|
+
overrides: [
|
|
58
|
+
{
|
|
59
|
+
files: ['**/*.html'],
|
|
60
|
+
customSyntax: 'postcss-html',
|
|
61
|
+
},
|
|
43
62
|
],
|
|
44
63
|
rules: {
|
|
45
64
|
'color-hex-length': 'long',
|
|
@@ -47,18 +66,30 @@ export default createStylelintConfig({
|
|
|
47
66
|
})
|
|
48
67
|
```
|
|
49
68
|
|
|
50
|
-
|
|
69
|
+
### Option Reference
|
|
51
70
|
|
|
52
71
|
- `presets.scss` – include `stylelint-config-standard-scss` (default `true`)
|
|
53
72
|
- `presets.vue` – include `stylelint-config-recommended-vue/scss` (default `true`)
|
|
54
73
|
- `presets.order` – include `stylelint-config-recess-order` (default `true`)
|
|
55
|
-
- `ignores
|
|
56
|
-
- `ignores.
|
|
57
|
-
- `extends` – append
|
|
58
|
-
- `overrides`
|
|
74
|
+
- `ignores.*` – replace the default ignore lists (units, selector types, at-rules)
|
|
75
|
+
- `ignores.add*` – append to the default ignore allowlists
|
|
76
|
+
- `extends` – append additional Stylelint configs after the presets
|
|
77
|
+
- `overrides` – pass file-specific overrides (e.g. custom syntax)
|
|
78
|
+
- `rules` – merge extra Stylelint rules
|
|
79
|
+
|
|
80
|
+
Defaults include:
|
|
81
|
+
|
|
82
|
+
- Allowing the `rpx` unit for mini-program compatibility
|
|
83
|
+
- Ignoring Tailwind/UnoCSS style at-rules (`apply`, `screen`, etc.)
|
|
84
|
+
- Ignoring the `page` selector used by various platforms
|
|
85
|
+
|
|
86
|
+
## Recommended Scripts
|
|
87
|
+
|
|
88
|
+
- `pnpm --filter @icebreakers/stylelint-config build` to produce the distributable `dist/` bundle.
|
|
89
|
+
- `pnpm --filter @app lint:styles` running `stylelint "src/**/*.{css,scss,vue}" --fix`.
|
|
59
90
|
|
|
60
|
-
|
|
91
|
+
## Troubleshooting
|
|
61
92
|
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
-
|
|
93
|
+
- Tailwind directives require `postcss.config.*` to include `@icebreakers/stylelint-config` ignore lists; adjust `ignores.addAtRules` when adding new utilities.
|
|
94
|
+
- If Stylelint cannot resolve the preset, ensure your workspace hoists the package or add it to the specific package `devDependencies`.
|
|
95
|
+
- Use the generated VS Code settings to avoid duplicate diagnostics from the built-in CSS validation.
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# @icebreakers/stylelint-config
|
|
2
|
+
|
|
3
|
+
## 概览
|
|
4
|
+
|
|
5
|
+
`@icebreakers/stylelint-config` 为 Vue + SCSS 技术栈提供开箱即用的 Stylelint 预设,并附带一个 CLI,可快速生成编辑器配置。它在上游推荐规则的基础上,补充了常用的单位白名单、UnoCSS / Tailwind 指令忽略项,同时保留对预设开关和自定义规则的控制能力。
|
|
6
|
+
|
|
7
|
+
## 环境要求
|
|
8
|
+
|
|
9
|
+
- Node.js 18+
|
|
10
|
+
- Stylelint 16(支持 Flat Config)
|
|
11
|
+
|
|
12
|
+
## 安装
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm add -D stylelint @icebreakers/stylelint-config
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
全新项目可以直接运行 CLI 初始化 VS Code 设置:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npx @icebreakers/stylelint-config
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
该命令会创建或更新 `.vscode/settings.json`,为 VS Code 添加 `stylelint.validate` 条目,确保代码诊断来自 Stylelint 而非内置 CSS 校验器。
|
|
25
|
+
|
|
26
|
+
## 基本用法
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
// stylelint.config.ts
|
|
30
|
+
import { icebreaker } from '@icebreakers/stylelint-config'
|
|
31
|
+
|
|
32
|
+
export default icebreaker()
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`icebreaker()` 会返回默认预设,并与传入的额外 Stylelint 配置合并。
|
|
36
|
+
|
|
37
|
+
## 进阶配置
|
|
38
|
+
|
|
39
|
+
若需细粒度控制预设、忽略列表或规则,可使用 `createStylelintConfig`:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { createStylelintConfig } from '@icebreakers/stylelint-config'
|
|
43
|
+
|
|
44
|
+
export default createStylelintConfig({
|
|
45
|
+
presets: {
|
|
46
|
+
vue: false, // 纯 SCSS 项目无需 Vue 规则
|
|
47
|
+
},
|
|
48
|
+
ignores: {
|
|
49
|
+
units: ['upx'], // 覆盖默认单位白名单
|
|
50
|
+
addAtRules: ['tailwind'],
|
|
51
|
+
},
|
|
52
|
+
extends: [
|
|
53
|
+
'@acme/stylelint-config',
|
|
54
|
+
],
|
|
55
|
+
overrides: [
|
|
56
|
+
{
|
|
57
|
+
files: ['**/*.html'],
|
|
58
|
+
customSyntax: 'postcss-html',
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
rules: {
|
|
62
|
+
'color-hex-length': 'long',
|
|
63
|
+
},
|
|
64
|
+
})
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 配置说明
|
|
68
|
+
|
|
69
|
+
- `presets.scss`:是否包含 `stylelint-config-standard-scss`,默认开启
|
|
70
|
+
- `presets.vue`:是否包含 `stylelint-config-recommended-vue/scss`,默认开启
|
|
71
|
+
- `presets.order`:是否包含 `stylelint-config-recess-order`,默认开启
|
|
72
|
+
- `ignores.*`:替换默认的忽略列表(单位、选择器类型、指令)
|
|
73
|
+
- `ignores.add*`:在默认忽略列表基础上追加项
|
|
74
|
+
- `extends`:在预设之后追加自定义 Stylelint 配置
|
|
75
|
+
- `overrides`:声明文件级别的覆盖(如指定 `customSyntax`)
|
|
76
|
+
- `rules`:合并额外 Stylelint 规则
|
|
77
|
+
|
|
78
|
+
默认行为包括:
|
|
79
|
+
|
|
80
|
+
- 允许 `rpx` 单位,兼容小程序
|
|
81
|
+
- 忽略 Tailwind / UnoCSS 常见指令(如 `apply`、`screen`)
|
|
82
|
+
- 忽略多端平台常见的 `page` 选择器
|
|
83
|
+
|
|
84
|
+
## 推荐脚本
|
|
85
|
+
|
|
86
|
+
- `pnpm --filter @icebreakers/stylelint-config build` 构建 `dist/` 产物。
|
|
87
|
+
- 在应用内新增 `lint:styles` 脚本,例如 `stylelint "src/**/*.{css,scss,vue}" --fix`。
|
|
88
|
+
|
|
89
|
+
## 常见问题
|
|
90
|
+
|
|
91
|
+
- Tailwind 指令需要在 `postcss.config.*` 中配合忽略列表,否则可能误报,可通过 `ignores.addAtRules` 添加新指令。
|
|
92
|
+
- 如果 Stylelint 无法解析预设,请确认包已安装在当前 workspace 的 `devDependencies` 中,或已正确 hoist。
|
|
93
|
+
- 建议使用 CLI 生成的 VS Code 设置,避免内置 CSS 校验与 Stylelint 重复报错。
|
package/dist/index.cjs
CHANGED
|
@@ -25,6 +25,13 @@ __export(index_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(index_exports);
|
|
27
27
|
|
|
28
|
+
// ../../node_modules/.pnpm/tsup@8.5.0_jiti@2.6.1_postcss@8.5.6_tsx@4.20.6_typescript@5.9.3_yaml@2.8.1/node_modules/tsup/assets/cjs_shims.js
|
|
29
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
30
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
31
|
+
|
|
32
|
+
// src/config.ts
|
|
33
|
+
var import_node_module = require("module");
|
|
34
|
+
|
|
28
35
|
// src/constants.ts
|
|
29
36
|
var PRESET_STANDARD_SCSS = "stylelint-config-standard-scss";
|
|
30
37
|
var PRESET_VUE_SCSS = "stylelint-config-recommended-vue/scss";
|
|
@@ -105,16 +112,20 @@ function normalizeExtends(base) {
|
|
|
105
112
|
}
|
|
106
113
|
|
|
107
114
|
// src/config.ts
|
|
115
|
+
var requireFromConfig = (0, import_node_module.createRequire)(importMetaUrl);
|
|
116
|
+
var PRESET_PATH_STANDARD_SCSS = requireFromConfig.resolve(PRESET_STANDARD_SCSS);
|
|
117
|
+
var PRESET_PATH_VUE_SCSS = requireFromConfig.resolve(PRESET_VUE_SCSS);
|
|
118
|
+
var PRESET_PATH_RECESS_ORDER = requireFromConfig.resolve(PRESET_RECESS_ORDER);
|
|
108
119
|
function resolvePresetExtends(presets) {
|
|
109
120
|
const entries = [];
|
|
110
121
|
if (presets?.scss !== false) {
|
|
111
|
-
entries.push(
|
|
122
|
+
entries.push(PRESET_PATH_STANDARD_SCSS);
|
|
112
123
|
}
|
|
113
124
|
if (presets?.vue !== false) {
|
|
114
|
-
entries.push(
|
|
125
|
+
entries.push(PRESET_PATH_VUE_SCSS);
|
|
115
126
|
}
|
|
116
127
|
if (presets?.order !== false) {
|
|
117
|
-
entries.push(
|
|
128
|
+
entries.push(PRESET_PATH_RECESS_ORDER);
|
|
118
129
|
}
|
|
119
130
|
return entries;
|
|
120
131
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// src/config.ts
|
|
2
|
+
import { createRequire } from "module";
|
|
3
|
+
|
|
1
4
|
// src/constants.ts
|
|
2
5
|
var PRESET_STANDARD_SCSS = "stylelint-config-standard-scss";
|
|
3
6
|
var PRESET_VUE_SCSS = "stylelint-config-recommended-vue/scss";
|
|
@@ -78,16 +81,20 @@ function normalizeExtends(base) {
|
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
// src/config.ts
|
|
84
|
+
var requireFromConfig = createRequire(import.meta.url);
|
|
85
|
+
var PRESET_PATH_STANDARD_SCSS = requireFromConfig.resolve(PRESET_STANDARD_SCSS);
|
|
86
|
+
var PRESET_PATH_VUE_SCSS = requireFromConfig.resolve(PRESET_VUE_SCSS);
|
|
87
|
+
var PRESET_PATH_RECESS_ORDER = requireFromConfig.resolve(PRESET_RECESS_ORDER);
|
|
81
88
|
function resolvePresetExtends(presets) {
|
|
82
89
|
const entries = [];
|
|
83
90
|
if (presets?.scss !== false) {
|
|
84
|
-
entries.push(
|
|
91
|
+
entries.push(PRESET_PATH_STANDARD_SCSS);
|
|
85
92
|
}
|
|
86
93
|
if (presets?.vue !== false) {
|
|
87
|
-
entries.push(
|
|
94
|
+
entries.push(PRESET_PATH_VUE_SCSS);
|
|
88
95
|
}
|
|
89
96
|
if (presets?.order !== false) {
|
|
90
|
-
entries.push(
|
|
97
|
+
entries.push(PRESET_PATH_RECESS_ORDER);
|
|
91
98
|
}
|
|
92
99
|
return entries;
|
|
93
100
|
}
|
package/package.json
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icebreakers/stylelint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.2.
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "1.2.2",
|
|
5
|
+
"description": "Stylelint preset from Icebreaker's dev-configs",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/sonofmagic/
|
|
10
|
+
"url": "git+https://github.com/sonofmagic/dev-configs.git",
|
|
11
11
|
"directory": "packages/stylelint"
|
|
12
12
|
},
|
|
13
13
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/sonofmagic/
|
|
14
|
+
"url": "https://github.com/sonofmagic/dev-configs/issues"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
|
+
"dev-configs",
|
|
18
|
+
"icebreakers",
|
|
17
19
|
"stylelint"
|
|
18
20
|
],
|
|
19
21
|
"sideEffects": false,
|
|
@@ -41,7 +43,7 @@
|
|
|
41
43
|
"dependencies": {
|
|
42
44
|
"comment-json": "^4.4.1",
|
|
43
45
|
"postcss-html": "^1.8.0",
|
|
44
|
-
"stylelint-config-recess-order": "^7.
|
|
46
|
+
"stylelint-config-recess-order": "^7.4.0",
|
|
45
47
|
"stylelint-config-recommended-scss": "^16.0.2",
|
|
46
48
|
"stylelint-config-recommended-vue": "^1.6.1",
|
|
47
49
|
"stylelint-config-standard-scss": "^16.0.0"
|