@resolid/config 5.0.3 → 5.1.1
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 +34 -55
- package/oxlint/javascript.js +10 -4
- package/oxlint/react.js +1 -1
- package/oxlint/typescript.js +3 -2
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# @resolid/config
|
|
2
2
|
|
|
3
|
-
Resolid 通用配置, 包含了 `TypeScript`, `
|
|
3
|
+
Resolid 通用配置, 包含了 `TypeScript`, `Oxlint` 的基础配置
|
|
4
4
|
|
|
5
5
|
## 安装
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
pnpm add -D @resolid/config
|
|
8
|
+
pnpm add -D @resolid/config oxlint typescript
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## TypeScript 配置
|
|
@@ -28,82 +28,61 @@ pnpm add -D @resolid/config eslint prettier typescript
|
|
|
28
28
|
}
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
##
|
|
32
|
-
|
|
33
|
-
本配置包是纯 ESM 包, 并使用了 ESLint 扁平配置, 需要使用 `eslint.config.js` 文件来进行配置
|
|
34
|
-
|
|
35
|
-
语言选项默认为 `ecmaVersion: 2022`, `sourceType: 'module'`
|
|
31
|
+
## Oxlint 配置
|
|
36
32
|
|
|
37
33
|
### Javascript Lint 配置
|
|
38
34
|
|
|
39
35
|
```js
|
|
40
|
-
//
|
|
41
|
-
import
|
|
36
|
+
// oxlint.config.ts
|
|
37
|
+
import javascriptConfig from "@resolid/config/oxlint/javascript";
|
|
38
|
+
import { defineConfig } from "oxlint";
|
|
42
39
|
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
export default defineConfig({
|
|
41
|
+
extends: [javascriptConfig],
|
|
42
|
+
});
|
|
45
43
|
```
|
|
46
44
|
|
|
47
45
|
### TypeScript Lint 配置
|
|
48
46
|
|
|
49
47
|
```js
|
|
50
|
-
//
|
|
51
|
-
import
|
|
48
|
+
// oxlint.config.ts
|
|
49
|
+
import typescriptConfig from "@resolid/config/oxlint/typescript";
|
|
50
|
+
import { defineConfig } from "oxlint";
|
|
52
51
|
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
export default defineConfig({
|
|
53
|
+
extends: [typescriptConfig],
|
|
54
|
+
});
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
### React Lint 配置
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
// eslint.config.js
|
|
61
|
-
import eslintReact from "@resolid/config/eslint.react";
|
|
59
|
+
由于 Oxlint 配置解析器的限制,目前你必须直接安装所需的 JS 插件
|
|
62
60
|
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
```shell
|
|
62
|
+
pnpm add -D eslint-plugin-react-hooks eslint-plugin-react-you-might-not-need-an-effect
|
|
65
63
|
```
|
|
66
64
|
|
|
67
|
-
### ESLint 环境设置
|
|
68
|
-
|
|
69
65
|
```js
|
|
70
|
-
//
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
import eslintBowser from "@resolid/config/eslint.bowser";
|
|
74
|
-
|
|
75
|
-
// Node 环境
|
|
76
|
-
import eslintNode from "@resolid/config/eslint.node";
|
|
66
|
+
// oxlint.config.ts
|
|
67
|
+
import reactConfig from "@resolid/config/oxlint/react";
|
|
68
|
+
import { defineConfig } from "oxlint";
|
|
77
69
|
|
|
78
|
-
|
|
79
|
-
|
|
70
|
+
export default defineConfig({
|
|
71
|
+
extends: [reactConfig],
|
|
72
|
+
});
|
|
80
73
|
```
|
|
81
74
|
|
|
82
|
-
###
|
|
83
|
-
|
|
84
|
-
你可以进入拥有 `eslint.config.js` 文件的目录运行下面的命令来检查
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
npx @eslint/config-inspector@latest
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
## Prettier 设置
|
|
75
|
+
### 环境 Lint 设置
|
|
91
76
|
|
|
92
77
|
```js
|
|
93
|
-
// .
|
|
94
|
-
|
|
95
|
-
import
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
*/
|
|
100
|
-
const config = {
|
|
101
|
-
...prettierConfig,
|
|
102
|
-
};
|
|
78
|
+
// oxlint.config.ts
|
|
79
|
+
// 浏览器环境
|
|
80
|
+
import browserConfig from "@resolid/config/oxlint/browser";
|
|
81
|
+
// Node 环境
|
|
82
|
+
import nodeConfig from "@resolid/config/oxlint/node";
|
|
83
|
+
import { defineConfig } from "oxlint";
|
|
103
84
|
|
|
104
|
-
export default
|
|
85
|
+
export default defineConfig({
|
|
86
|
+
extends: [browserConfig, nodeConfig],
|
|
87
|
+
});
|
|
105
88
|
```
|
|
106
|
-
|
|
107
|
-
## 致谢
|
|
108
|
-
|
|
109
|
-
- [ESLint Config Inspector](https://github.com/eslint/config-inspector) 用于检查和理解 ESLint 平面配置的可视化工具。
|
package/oxlint/javascript.js
CHANGED
|
@@ -19,8 +19,11 @@ export default defineConfig({
|
|
|
19
19
|
"**/.vercel",
|
|
20
20
|
"**/.vite-inspect",
|
|
21
21
|
],
|
|
22
|
-
plugins: ["eslint", "oxc", "
|
|
22
|
+
plugins: ["eslint", "import", "oxc", "promise", "unicorn"],
|
|
23
23
|
rules: {
|
|
24
|
+
curly: "warn",
|
|
25
|
+
"guard-for-in": "warn",
|
|
26
|
+
|
|
24
27
|
"no-case-declarations": "error",
|
|
25
28
|
"no-empty": "error",
|
|
26
29
|
"no-fallthrough": "error",
|
|
@@ -29,22 +32,25 @@ export default defineConfig({
|
|
|
29
32
|
"no-unexpected-multiline": "error",
|
|
30
33
|
"no-var": "error",
|
|
31
34
|
"no-array-constructor": "error",
|
|
35
|
+
"no-useless-call": "error",
|
|
36
|
+
"no-await-in-loop": "error",
|
|
37
|
+
|
|
32
38
|
"prefer-const": "error",
|
|
33
39
|
"prefer-rest-params": "error",
|
|
34
40
|
"prefer-spread": "error",
|
|
35
|
-
|
|
36
41
|
"prefer-template": "warn",
|
|
37
42
|
"prefer-destructuring": "warn",
|
|
38
43
|
"prefer-object-spread": "warn",
|
|
39
44
|
"prefer-exponentiation-operator": "warn",
|
|
40
45
|
"prefer-numeric-literals": "warn",
|
|
41
|
-
curly: "warn",
|
|
42
|
-
"guard-for-in": "warn",
|
|
43
46
|
|
|
44
47
|
"import/export": "error",
|
|
45
48
|
"import/named": "error",
|
|
46
49
|
"import/no-named-as-default": "warn",
|
|
47
50
|
"import/no-named-as-default-member": "warn",
|
|
48
51
|
"import/no-duplicates": "warn",
|
|
52
|
+
|
|
53
|
+
"oxc/no-accumulating-spread": "error",
|
|
54
|
+
"oxc/no-map-spread": "error",
|
|
49
55
|
},
|
|
50
56
|
});
|
package/oxlint/react.js
CHANGED
|
@@ -11,7 +11,7 @@ export default defineConfig({
|
|
|
11
11
|
specifier: "eslint-plugin-react-you-might-not-need-an-effect",
|
|
12
12
|
},
|
|
13
13
|
],
|
|
14
|
-
plugins: ["react", "jsx-a11y"],
|
|
14
|
+
plugins: ["react", "react-perf", "jsx-a11y"],
|
|
15
15
|
rules: {
|
|
16
16
|
"react/display-name": "error",
|
|
17
17
|
"react/jsx-key": "error",
|
package/oxlint/typescript.js
CHANGED
|
@@ -5,8 +5,10 @@ export default defineConfig({
|
|
|
5
5
|
extends: [javascriptConfig],
|
|
6
6
|
plugins: ["typescript"],
|
|
7
7
|
rules: {
|
|
8
|
+
"typescript/array-type": "warn",
|
|
8
9
|
"typescript/ban-ts-comment": "error",
|
|
9
10
|
"typescript/consistent-type-imports": "error",
|
|
11
|
+
|
|
10
12
|
"typescript/no-empty-object-type": "error",
|
|
11
13
|
"typescript/no-explicit-any": "error",
|
|
12
14
|
"typescript/no-import-type-side-effects": "error",
|
|
@@ -14,11 +16,10 @@ export default defineConfig({
|
|
|
14
16
|
"typescript/no-require-imports": "error",
|
|
15
17
|
"typescript/no-unnecessary-type-constraint": "error",
|
|
16
18
|
"typescript/no-unsafe-function-type": "error",
|
|
19
|
+
|
|
17
20
|
"typescript/prefer-for-of": "error",
|
|
18
21
|
"typescript/prefer-function-type": "error",
|
|
19
22
|
"typescript/prefer-nullish-coalescing": "error",
|
|
20
23
|
"typescript/prefer-optional-chain": "error",
|
|
21
|
-
|
|
22
|
-
"typescript/array-type": "warn",
|
|
23
24
|
},
|
|
24
25
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@resolid/config",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.1",
|
|
4
4
|
"description": "Oxlint and Typescript config",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"oxfmt",
|
|
@@ -37,9 +37,11 @@
|
|
|
37
37
|
"@commitlint/cli": "^20.4.3",
|
|
38
38
|
"@commitlint/config-conventional": "^20.4.3",
|
|
39
39
|
"@svitejs/changesets-changelog-github-compact": "^1.2.0",
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
40
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
41
|
+
"eslint-plugin-react-you-might-not-need-an-effect": "^0.9.2",
|
|
42
|
+
"lefthook": "^2.1.3",
|
|
43
|
+
"oxfmt": "^0.37.0",
|
|
44
|
+
"oxlint": "^1.52.0",
|
|
43
45
|
"typescript": "^5.9.3"
|
|
44
46
|
},
|
|
45
47
|
"peerDependencies": {
|