@secret-momo/toolchain-config 2.2.0 → 2.3.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 +29 -1
- package/package.json +10 -2
- package/stylelint.config.d.mts +5 -0
- package/stylelint.config.mjs +29 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @secret-momo/toolchain-config
|
|
2
2
|
|
|
3
|
-
跨项目共享的 TypeScript、ESLint 和
|
|
3
|
+
跨项目共享的 TypeScript、ESLint、Prettier 和 Stylelint 配置。需要 Node.js 26+,按需安装所用工具。
|
|
4
4
|
|
|
5
5
|
## ESLint 预设
|
|
6
6
|
|
|
@@ -77,6 +77,34 @@ import config from '@secret-momo/toolchain-config/prettier.config.mjs';
|
|
|
77
77
|
export default { ...config, printWidth: 100 };
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
+
## Stylelint 预设
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
pnpm add -D @secret-momo/toolchain-config stylelint@^18
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
在项目根目录创建 `stylelint.config.mjs`。标准预设及其所需的 Stylelint 版本随共享包安装,可以与项目已有的 Stylelint 版本共存。
|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
export default {
|
|
90
|
+
extends: ['@secret-momo/toolchain-config/stylelint'],
|
|
91
|
+
};
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
也可以直接导入预设,在本地补充设置。
|
|
95
|
+
|
|
96
|
+
```js
|
|
97
|
+
import config from '@secret-momo/toolchain-config/stylelint';
|
|
98
|
+
|
|
99
|
+
export default { ...config, ignoreFiles: ['**/dist/**'] };
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
普通 CSS 使用 `stylelint-config-standard`,类名采用 kebab-case。`*.module.css` 的选择器和 `@keyframes` 可使用 `:global()` 和 `:local()`。预设关闭模块的类名格式检查,并保留 `composes` 中类名的大小写。消费项目通过 `rules` 或 `overrides` 添加设计 token 等约束,并通过 lint 命令的 glob 或 `ignoreFiles` 指定检查范围。
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
pnpm exec stylelint 'src/**/*.css' --max-warnings=0
|
|
106
|
+
```
|
|
107
|
+
|
|
80
108
|
## TypeScript 预设
|
|
81
109
|
|
|
82
110
|
```bash
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secret-momo/toolchain-config",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "跨项目共享的 TypeScript、ESLint 和
|
|
3
|
+
"version": "2.3.0",
|
|
4
|
+
"description": "跨项目共享的 TypeScript、ESLint、Prettier 和 Stylelint 配置。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -18,6 +18,10 @@
|
|
|
18
18
|
"types": "./prettier.config.d.mts",
|
|
19
19
|
"default": "./prettier.config.mjs"
|
|
20
20
|
},
|
|
21
|
+
"./stylelint": {
|
|
22
|
+
"types": "./stylelint.config.d.mts",
|
|
23
|
+
"default": "./stylelint.config.mjs"
|
|
24
|
+
},
|
|
21
25
|
"./tsconfig/base.json": "./tsconfig/base.json",
|
|
22
26
|
"./tsconfig/node.json": "./tsconfig/node.json",
|
|
23
27
|
"./tsconfig/browser.json": "./tsconfig/browser.json",
|
|
@@ -36,6 +40,8 @@
|
|
|
36
40
|
"eslint/*.d.mts",
|
|
37
41
|
"prettier.config.mjs",
|
|
38
42
|
"prettier.config.d.mts",
|
|
43
|
+
"stylelint.config.mjs",
|
|
44
|
+
"stylelint.config.d.mts",
|
|
39
45
|
"tsconfig/**/*.json"
|
|
40
46
|
],
|
|
41
47
|
"engines": {
|
|
@@ -53,6 +59,8 @@
|
|
|
53
59
|
"eslint-plugin-import-x": "4.18.1",
|
|
54
60
|
"eslint-plugin-unused-imports": "4.4.1",
|
|
55
61
|
"globals": "17.14.0",
|
|
62
|
+
"stylelint": "18.1.0",
|
|
63
|
+
"stylelint-config-standard": "41.1.0",
|
|
56
64
|
"typescript-eslint": "8.74.0"
|
|
57
65
|
},
|
|
58
66
|
"peerDependencies": {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
|
|
3
|
+
/** @type {import('stylelint').Config} */
|
|
4
|
+
const config = {
|
|
5
|
+
// 让 ESM 导入的配置也从共享包解析标准预设。
|
|
6
|
+
extends: [fileURLToPath(import.meta.resolve('stylelint-config-standard'))],
|
|
7
|
+
overrides: [
|
|
8
|
+
{
|
|
9
|
+
files: ['**/*.module.css'],
|
|
10
|
+
languageOptions: {
|
|
11
|
+
syntax: {
|
|
12
|
+
atRules: {
|
|
13
|
+
keyframes: { prelude: '| :global( <custom-ident> ) | :local( <custom-ident> )' },
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
rules: {
|
|
18
|
+
'selector-class-pattern': null,
|
|
19
|
+
'selector-pseudo-class-no-unknown': [true, { ignorePseudoClasses: ['global', 'local'] }],
|
|
20
|
+
'property-no-unknown': [true, { ignoreProperties: ['composes'] }],
|
|
21
|
+
'value-keyword-case': ['lower', { ignoreProperties: ['composes'] }],
|
|
22
|
+
// 作用域内的名称由关键帧语法校验。普通关键帧名称沿用 kebab-case。
|
|
23
|
+
'keyframes-name-pattern': /^(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|:(?:global|local)\([\s\S]+\))$/,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default config;
|