@soybeanjs/oxc-config 0.1.0 → 0.1.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.en.md CHANGED
@@ -12,7 +12,7 @@ Shared [oxlint](https://oxc.rs/docs/guide/usage/linter.html) and [oxfmt](https:/
12
12
  - 🚀 **oxfmt formatter config** — Unified code style with fine-grained import sorting groups
13
13
  - 🔍 **oxlint linter config** — Integrated with ESLint / TypeScript / Unicorn / Vue plugins
14
14
  - 📦 **Import sorting** — Auto-group and sort imports by dependency layer
15
- - 🎯 **type-before-value rule** — Custom oxlint JS plugin ensuring `import type` comes after `import` for the same module
15
+ - 🎯 **custom import plugin** — Includes auto-merging duplicate imports, disallowing inline type imports, and enforcing value imports before type imports
16
16
 
17
17
  ## Installation
18
18
 
@@ -109,9 +109,35 @@ export default lint;
109
109
  - **import** — Import/Export rules
110
110
  - **vue** — Vue SFC rules
111
111
 
112
- #### Custom Rule: import-type-order
112
+ #### Custom Rules: soybeanjs-import
113
113
 
114
- A custom oxlint JS plugin that ensures `import type` always comes after `import` for the same module:
114
+ This config ships with a custom oxlint JS plugin loaded from `@soybeanjs/oxc-config/plugins/import`, with 3 built-in rules:
115
+
116
+ - `soybeanjs-import/merge-duplicates`: keep at most one value import and one type import per module, and auto-merge duplicate imports
117
+ - `soybeanjs-import/no-inline-type-import`: disallow inline type imports like `import { type Foo }`, and auto-convert them to top-level `import type`
118
+ - `soybeanjs-import/type-after-value`: ensure value imports come before type imports for the same module
119
+
120
+ Examples:
121
+
122
+ ```ts
123
+ // ✅ After fixing
124
+ import { a, b } from './types';
125
+ import type { DemoTest } from './types';
126
+
127
+ // ❌ Duplicate imports
128
+ import { b } from './types';
129
+ import { a } from './types';
130
+ import type { DemoTest } from './types';
131
+ ```
132
+
133
+ ```ts
134
+ // ✅ After fixing
135
+ import { a } from './types';
136
+ import type { DemoTest } from './types';
137
+
138
+ // ❌ Inline type import
139
+ import { a, type DemoTest } from './types';
140
+ ```
115
141
 
116
142
  ```ts
117
143
  // ✅ Correct
@@ -130,9 +156,11 @@ import { lint } from '@soybeanjs/oxc-config';
130
156
 
131
157
  export default {
132
158
  ...lint,
133
- jsPlugins: ['@soybeanjs/oxc-config/import-type-order'],
159
+ jsPlugins: ['@soybeanjs/oxc-config/plugins/import'],
134
160
  rules: {
135
- 'import-type-order/type-after-value': 'warn'
161
+ 'soybeanjs-import/merge-duplicates': 'warn',
162
+ 'soybeanjs-import/no-inline-type-import': 'warn',
163
+ 'soybeanjs-import/type-after-value': 'warn'
136
164
  }
137
165
  };
138
166
  ```
package/README.md CHANGED
@@ -12,7 +12,7 @@ SoybeanJS 的共享 [oxlint](https://oxc.rs/docs/guide/usage/linter.html) 和 [o
12
12
  - 🚀 **oxfmt 格式化配置** — 统一代码风格,包含精细的 import 排序分组
13
13
  - 🔍 **oxlint 代码检查** — 集成 ESLint / TypeScript / Unicorn / Vue 等插件
14
14
  - 📦 **Import 排序** — 按依赖层级自动分组排序 external 和 internal import
15
- - 🎯 **type-before-value 规则** — 自定义 oxlint JS 插件,确保同模块 `import type` 在 `import` 之后
15
+ - 🎯 **自定义 import 插件** — 附带自动合并重复导入、禁止 inline type import、保证 value import 在 type import 之前
16
16
 
17
17
  ## 安装
18
18
 
@@ -109,9 +109,35 @@ export default lint;
109
109
  - **import** — Import/Export 规则
110
110
  - **vue** — Vue SFC 规则
111
111
 
112
- #### 自定义规则:import-type-order
112
+ #### 自定义规则:soybeanjs-import
113
113
 
114
- 本配置附带一个 oxlint JS 插件,确保同一模块的 `import type` 始终在 `import` 之后:
114
+ 本配置附带一个 oxlint JS 插件,加载路径为 `@soybeanjs/oxc-config/plugins/import`,内置 3 条规则:
115
+
116
+ - `soybeanjs-import/merge-duplicates`:同一模块最多保留一条 value import 和一条 type import,并自动合并重复导入
117
+ - `soybeanjs-import/no-inline-type-import`:禁止 `import { type Foo }` 这种 inline type import,自动改成顶层 `import type`
118
+ - `soybeanjs-import/type-after-value`:同一模块内要求 value import 在前,type import 在后
119
+
120
+ 示例:
121
+
122
+ ```ts
123
+ // ✅ 修复后
124
+ import { a, b } from './types';
125
+ import type { DemoTest } from './types';
126
+
127
+ // ❌ 重复导入
128
+ import { b } from './types';
129
+ import { a } from './types';
130
+ import type { DemoTest } from './types';
131
+ ```
132
+
133
+ ```ts
134
+ // ✅ 修复后
135
+ import { a } from './types';
136
+ import type { DemoTest } from './types';
137
+
138
+ // ❌ inline type import
139
+ import { a, type DemoTest } from './types';
140
+ ```
115
141
 
116
142
  ```ts
117
143
  // ✅ 正确
@@ -132,9 +158,11 @@ import { lint } from '@soybeanjs/oxc-config';
132
158
 
133
159
  export default {
134
160
  ...lint,
135
- jsPlugins: ['@soybeanjs/oxc-config/import-type-order'],
161
+ jsPlugins: ['@soybeanjs/oxc-config/plugins/import'],
136
162
  rules: {
137
- 'import-type-order/type-after-value': 'warn'
163
+ 'soybeanjs-import/merge-duplicates': 'warn',
164
+ 'soybeanjs-import/no-inline-type-import': 'warn',
165
+ 'soybeanjs-import/type-after-value': 'warn'
138
166
  }
139
167
  };
140
168
  ```
package/dist/index.js CHANGED
@@ -19,6 +19,9 @@ var external = [
19
19
  "@vueuse/**",
20
20
  "vue-**",
21
21
  "nuxt",
22
+ "hono",
23
+ "@hono/**",
24
+ "hono-**",
22
25
  "@nuxt/**",
23
26
  "nuxt-**",
24
27
  "react",
@@ -50,6 +53,10 @@ var external = [
50
53
  "@arco-design/**",
51
54
  "@iconify/**",
52
55
  "axios",
56
+ "valibot",
57
+ "@valibot/**",
58
+ "zod",
59
+ "@zod/**",
53
60
  "date-fns",
54
61
  "dayjs",
55
62
  "es-toolkit",
@@ -225,6 +232,7 @@ const lint = {
225
232
  "unicorn/no-array-sort": "off",
226
233
  "unicorn/no-empty-file": "off",
227
234
  "unicorn/require-module-specifiers": "off",
235
+ "vue/no-undef-properties": "off",
228
236
  "vue/prefer-import-from-vue": "off"
229
237
  }
230
238
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soybeanjs/oxc-config",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "SoybeanJS's oxlint and oxfmt config",
5
5
  "keywords": [
6
6
  "eslint",