@secret-momo/toolchain-config 2.0.0 → 2.1.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 CHANGED
@@ -1,6 +1,34 @@
1
1
  # @secret-momo/toolchain-config
2
2
 
3
- 跨项目共享的 TypeScript 配置。需要 Node.js 26+ 和 TypeScript `~6.0.3`。
3
+ 跨项目共享的 TypeScript 和 Prettier 配置。需要 Node.js 26+,按需安装所用工具。
4
+
5
+ ## Prettier 预设
6
+
7
+ ```bash
8
+ pnpm add -D @secret-momo/toolchain-config prettier@^3
9
+ ```
10
+
11
+ 在项目的 `package.json` 中引用预设。
12
+
13
+ ```json
14
+ {
15
+ "prettier": "@secret-momo/toolchain-config/prettier.config.mjs"
16
+ }
17
+ ```
18
+
19
+ 预设使用 120 列目标行宽和多行尾逗号。JavaScript 和 TypeScript 字符串优先使用单引号,包括 JSX 表达式、Vue 的 `<script>` 以及模板绑定表达式中的字符串。JSX 字符串属性和 Vue 模板属性的外层使用双引号。
20
+
21
+ `*.md` 和 `*.markdown` 不自动折行,也不限制行宽。`*.jsonc` 禁用尾逗号。
22
+
23
+ 需要调整规则时,可在项目的 `prettier.config.mjs` 或 `prettier.config.mts` 中继承预设,例如将代码行宽设为 100。
24
+
25
+ ```js
26
+ import config from '@secret-momo/toolchain-config/prettier.config.mjs';
27
+
28
+ export default { ...config, printWidth: 100 };
29
+ ```
30
+
31
+ ## TypeScript 预设
4
32
 
5
33
  ```bash
6
34
  pnpm add -D @secret-momo/toolchain-config typescript@~6.0.3
@@ -12,8 +40,6 @@ pnpm add -D @secret-momo/toolchain-config typescript@~6.0.3
12
40
  pnpm add -D @types/node@26
13
41
  ```
14
42
 
15
- ## TypeScript 预设
16
-
17
43
  在 `tsconfig.json` 的 `extends` 中使用 `@secret-momo/toolchain-config/` 加下表中的入口。
18
44
 
19
45
  | 入口 | 适用场景 |
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@secret-momo/toolchain-config",
3
- "version": "2.0.0",
4
- "description": "跨项目共享的 TypeScript 配置。",
3
+ "version": "2.1.0",
4
+ "description": "跨项目共享的 TypeScript 和 Prettier 配置。",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -10,6 +10,10 @@
10
10
  "directory": "packages/toolchain-config"
11
11
  },
12
12
  "exports": {
13
+ "./prettier.config.mjs": {
14
+ "types": "./prettier.config.d.mts",
15
+ "default": "./prettier.config.mjs"
16
+ },
13
17
  "./tsconfig/base.json": "./tsconfig/base.json",
14
18
  "./tsconfig/node.json": "./tsconfig/node.json",
15
19
  "./tsconfig/browser.json": "./tsconfig/browser.json",
@@ -24,6 +28,8 @@
24
28
  "./tsconfig/declarations.json": "./tsconfig/declarations.json"
25
29
  },
26
30
  "files": [
31
+ "prettier.config.mjs",
32
+ "prettier.config.d.mts",
27
33
  "tsconfig/**/*.json"
28
34
  ],
29
35
  "engines": {
@@ -34,9 +40,13 @@
34
40
  "registry": "https://registry.npmjs.org/"
35
41
  },
36
42
  "peerDependencies": {
43
+ "prettier": "^3.0.0",
37
44
  "typescript": "~6.0.3"
38
45
  },
39
46
  "peerDependenciesMeta": {
47
+ "prettier": {
48
+ "optional": true
49
+ },
40
50
  "typescript": {
41
51
  "optional": true
42
52
  }
@@ -0,0 +1,5 @@
1
+ import type { Config } from 'prettier';
2
+
3
+ declare const config: Config;
4
+
5
+ export default config;
@@ -0,0 +1,22 @@
1
+ /** @type {import('prettier').Config} */
2
+ const config = {
3
+ singleQuote: true,
4
+ jsxSingleQuote: false,
5
+ trailingComma: 'all',
6
+ printWidth: 120,
7
+ overrides: [
8
+ {
9
+ files: ['*.md', '*.markdown'],
10
+ options: {
11
+ printWidth: Number.POSITIVE_INFINITY,
12
+ proseWrap: 'never',
13
+ },
14
+ },
15
+ {
16
+ files: '*.jsonc',
17
+ options: { trailingComma: 'none' },
18
+ },
19
+ ],
20
+ };
21
+
22
+ export default config;