@icebreakers/stylelint-config 1.2.1 → 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.
Files changed (3) hide show
  1. package/README.md +53 -22
  2. package/README.zh.md +93 -0
  3. package/package.json +7 -5
package/README.md CHANGED
@@ -1,18 +1,31 @@
1
1
  # @icebreakers/stylelint-config
2
2
 
3
- Reusable stylelint configuration with sensible defaults for Vue + SCSS projects and an opt-in API for tailoring the rule set.
3
+ - [简体中文指南](./README.zh.md)
4
4
 
5
- ## CLI helper
5
+ ## Overview
6
6
 
7
- Bootstrap VS Code settings so diagnostics come from stylelint instead of the built-in CSS linters:
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
- ```sh
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 command creates (or updates) `.vscode/settings.json` with the required `stylelint.validate` entries.
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 usage
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()` reflects the legacy behaviour: it returns the default preset and merges any partial stylelint config you pass in.
37
+ `icebreaker()` returns the default preset and merges any additional Stylelint config you pass in.
25
38
 
26
- ## Advanced configuration
39
+ ## Advanced Configuration
27
40
 
28
- For granular control, use `createStylelintConfig` which exposes preset toggles and ignore list helpers:
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, // drop vue-specific rules if you lint pure SCSS
48
+ vue: false, // disable Vue rules for pure SCSS projects
36
49
  },
37
50
  ignores: {
38
- units: [], // replace the default ignore list
39
- addUnits: ['upx'],
51
+ units: ['upx'], // replace default list
52
+ addAtRules: ['tailwind'],
40
53
  },
41
54
  extends: [
42
- '@acme/stylelint-config-custom',
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
- Available options:
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.atRules`, `ignores.types`, `ignores.units` – replace the defaults
56
- - `ignores.addAtRules`, `ignores.addTypes`, `ignores.addUnits` – append extra entries
57
- - `extends` – append custom configs after the presets
58
- - `overrides` / `rules` – carried straight into the resulting Stylelint config
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
- Both helpers share the same defaults:
91
+ ## Troubleshooting
61
92
 
62
- - Allow the `rpx` unit to ease mini-program support
63
- - Ignore custom at-rules used by Tailwind CSS and UnoCSS
64
- - Ignore the `page` selector for platform-specific stylesheets
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/package.json CHANGED
@@ -1,19 +1,21 @@
1
1
  {
2
2
  "name": "@icebreakers/stylelint-config",
3
3
  "type": "module",
4
- "version": "1.2.1",
5
- "description": "icebreaker's stylelint config",
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/eslint-config.git",
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/eslint-config/issues"
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.3.0",
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"