@vocawiki/oxfmt-config 0.0.0-stage → 0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Vocawiki contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,62 @@
1
- # Temporary Holding Version
1
+ # @vocawiki/oxfmt-config
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Vocawiki 共享的 [Oxfmt](https://oxc.rs/docs/guide/usage/formatter) 格式化配置。
4
+
5
+ `oxfmt` 作为 **peer dependency**,由使用方自行安装并锁定版本,配置包本身不携带 formatter。
6
+
7
+ ## 安装
8
+
9
+ ```bash
10
+ pnpm add -D @vocawiki/oxfmt-config oxfmt
11
+ ```
12
+
13
+ ## 使用
14
+
15
+ `oxfmt.config.ts`:
16
+
17
+ ```ts
18
+ import baseConfig from '@vocawiki/oxfmt-config'
19
+ import { defineConfig } from 'oxfmt'
20
+
21
+ export default defineConfig({
22
+ ...baseConfig,
23
+ printWidth: 80,
24
+ })
25
+
26
+ // 若不做任何覆盖,`oxfmt.config.ts` 可以只写一行:
27
+ export { default } from '@vocawiki/oxfmt-config'
28
+ ```
29
+
30
+ ## 项目级追加
31
+
32
+ 以下设置与具体项目强相关,**不在共享配置里**,请在项目自己的 `oxfmt.config.ts` 中补充:
33
+
34
+ ```ts
35
+ import baseConfig from '@vocawiki/oxfmt-config'
36
+ import { defineConfig } from 'oxfmt'
37
+
38
+ export default defineConfig({
39
+ ...baseConfig,
40
+ // Tailwind 类名排序:指向项目自己的样式入口
41
+ sortTailwindcss: {
42
+ stylesheet: './src/theme.css',
43
+ functions: ['cn', 'cva'],
44
+ },
45
+ // 自定义 import 分组,例如把自己项目的「服务端专用」导入提到最前
46
+ sortImports: {
47
+ ...baseConfig.sortImports,
48
+ customGroups: [
49
+ {
50
+ groupName: 'directive_like',
51
+ elementNamePattern: ['@/lib/server-only'],
52
+ },
53
+ ],
54
+ groups: ['directive_like', ...baseConfig.sortImports.groups],
55
+ },
56
+ })
57
+ ```
58
+
59
+ ## 版本兼容
60
+
61
+ 本包与 `oxfmt` 的 schema 绑定,`peerDependencies` 声明为 `^0.81.0`。
62
+ Oxfmt 处于 `0.x`,配置项可能在小版本间调整,升级 `oxfmt` 时请同时确认本包是否有对应版本发布。
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Vocawiki 共享的 Oxfmt 配置。
3
+ *
4
+ * 只包含与具体项目无关的部分,项目级设置(例如 `sortTailwindcss.stylesheet`、
5
+ * `sortImports.customGroups`)请在项目自己的 `oxfmt.config.ts` 中追加。
6
+ */
7
+ declare const baseConfig: {
8
+ readonly endOfLine: "lf";
9
+ readonly printWidth: 100;
10
+ readonly tabWidth: 2;
11
+ readonly useTabs: true;
12
+ readonly semi: false;
13
+ readonly singleQuote: true;
14
+ readonly sortImports: {
15
+ readonly newlinesBetween: false;
16
+ readonly groups: ["builtin", {
17
+ readonly newlinesBetween: true;
18
+ }, "external", {
19
+ readonly newlinesBetween: true;
20
+ }, "internal", {
21
+ readonly newlinesBetween: true;
22
+ }, "parent", "sibling", "index", {
23
+ readonly newlinesBetween: true;
24
+ }, "side_effect", "style", "unknown"];
25
+ };
26
+ readonly sortPackageJson: false;
27
+ readonly overrides: [{
28
+ readonly files: ["*.{css,scss,sass,less}"];
29
+ readonly options: {
30
+ readonly tabWidth: 4;
31
+ readonly singleQuote: false;
32
+ };
33
+ }];
34
+ readonly ignorePatterns: ["pnpm-lock.yaml"];
35
+ };
36
+ export { baseConfig as default };
package/dist/index.js ADDED
@@ -0,0 +1,43 @@
1
+ // index.ts
2
+ /**
3
+ * Vocawiki 共享的 Oxfmt 配置。
4
+ *
5
+ * 只包含与具体项目无关的部分,项目级设置(例如 `sortTailwindcss.stylesheet`、
6
+ * `sortImports.customGroups`)请在项目自己的 `oxfmt.config.ts` 中追加。
7
+ */
8
+ const baseConfig = {
9
+ endOfLine: "lf",
10
+ printWidth: 100,
11
+ tabWidth: 2,
12
+ useTabs: true,
13
+ semi: false,
14
+ singleQuote: true,
15
+ sortImports: {
16
+ newlinesBetween: false,
17
+ groups: [
18
+ "builtin",
19
+ { newlinesBetween: true },
20
+ "external",
21
+ { newlinesBetween: true },
22
+ "internal",
23
+ { newlinesBetween: true },
24
+ "parent",
25
+ "sibling",
26
+ "index",
27
+ { newlinesBetween: true },
28
+ "side_effect",
29
+ "style",
30
+ "unknown"
31
+ ]
32
+ },
33
+ sortPackageJson: false,
34
+ overrides: [{
35
+ files: ["*.{css,scss,sass,less}"],
36
+ options: {
37
+ tabWidth: 4,
38
+ singleQuote: false
39
+ }
40
+ }],
41
+ ignorePatterns: ["pnpm-lock.yaml"]
42
+ };
43
+ export { baseConfig as default };
package/package.json CHANGED
@@ -1,6 +1,44 @@
1
1
  {
2
2
  "name": "@vocawiki/oxfmt-config",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Vocawiki 共享的 Oxfmt 格式化配置",
5
+ "keywords": [
6
+ "oxfmt",
7
+ "formatter",
8
+ "config"
9
+ ],
10
+ "license": "MIT",
11
+ "type": "module",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/vocawiki/project-configs.git",
24
+ "directory": "packages/oxfmt-config"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public",
28
+ "provenance": true
29
+ },
30
+ "peerDependencies": {
31
+ "oxfmt": "^0.81.0"
32
+ },
33
+ "devDependencies": {
34
+ "@vocawiki/tsconfig": "0.1.0",
35
+ "oxfmt": "^0.81.0",
36
+ "tsdown": "^0.23.8",
37
+ "typescript": "npm:@typescript/typescript6@^6.0.2"
38
+ },
39
+ "scripts": {
40
+ "build": "tsdown"
41
+ },
42
+ "main": "./dist/index.js",
43
+ "types": "./dist/index.d.ts"
6
44
  }