@resolid/config 2.1.2 → 3.0.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 +57 -32
- package/package.json +29 -13
- package/src/eslint.base.js +39 -0
- package/src/eslint.browser.js +12 -0
- package/src/eslint.node.js +24 -0
- package/src/eslint.react.js +77 -0
- package/src/eslint.typescript.js +13 -0
- package/src/prettier.js +8 -0
- package/{config/tsconfig.base.json → tsconfig/base.json} +0 -7
- package/tsconfig/react.json +7 -0
- package/config/biome.json +0 -37
- package/config/biome.react.json +0 -21
- package/config/biome.tailwind.json +0 -15
- package/config/tsconfig.react.json +0 -6
package/README.md
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
# @resolid/config
|
|
2
2
|
|
|
3
|
-
Resolid 通用配置, 包含了 `TypeScript`, `
|
|
3
|
+
Resolid 通用配置, 包含了 `TypeScript`, `Eslint` 和 `Prettier` 的基础配置
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
### 安装
|
|
5
|
+
## 安装
|
|
8
6
|
|
|
9
7
|
```bash
|
|
10
8
|
pnpm add -D @resolid/config
|
|
11
9
|
```
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
## TypeScript 配置
|
|
14
12
|
|
|
15
13
|
增加下面内容到 `tsconfig.json`
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
### 普通项目
|
|
18
16
|
|
|
19
17
|
```json
|
|
20
18
|
{
|
|
@@ -22,7 +20,7 @@ pnpm add -D @resolid/config
|
|
|
22
20
|
}
|
|
23
21
|
```
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
### React 项目
|
|
26
24
|
|
|
27
25
|
```json
|
|
28
26
|
{
|
|
@@ -30,38 +28,65 @@ pnpm add -D @resolid/config
|
|
|
30
28
|
}
|
|
31
29
|
```
|
|
32
30
|
|
|
33
|
-
|
|
31
|
+
## ESLint 配置
|
|
34
32
|
|
|
35
|
-
|
|
33
|
+
本配置包是纯 ESM 包, 并使用了 ESLint 扁平配置, 需要使用 `eslint.config.js` 文件来进行配置
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
语言选项默认为 `ecmaVersion: 2022`, `sourceType: 'module'`
|
|
36
|
+
|
|
37
|
+
### 基本 Lint 配置
|
|
38
|
+
|
|
39
|
+
```js
|
|
40
|
+
// eslint.config.js
|
|
41
|
+
import eslintBase from "@resolid/config/eslint.base";
|
|
42
|
+
|
|
43
|
+
/** @type {import('eslint').Linter.FlatConfig[]} */
|
|
44
|
+
export default [...eslintBase];
|
|
42
45
|
```
|
|
43
46
|
|
|
44
|
-
|
|
47
|
+
### TypeScript Lint 配置
|
|
45
48
|
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
]
|
|
53
|
-
}
|
|
49
|
+
```js
|
|
50
|
+
// eslint.config.js
|
|
51
|
+
import eslintTypescript from "@resolid/config/eslint.typescript";
|
|
52
|
+
|
|
53
|
+
/** @type {import('eslint').Linter.FlatConfig[]} */
|
|
54
|
+
export default [...eslintTypescript];
|
|
54
55
|
```
|
|
55
56
|
|
|
56
|
-
|
|
57
|
+
### React Lint 配置
|
|
57
58
|
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
```js
|
|
60
|
+
// eslint.config.js
|
|
61
|
+
import eslintReact from "@resolid/config/eslint.react";
|
|
62
|
+
|
|
63
|
+
/** @type {import('eslint').Linter.FlatConfig[]} */
|
|
64
|
+
export default [...eslintReact];
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### ESLint 环境设置
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
// eslint.config.js
|
|
71
|
+
|
|
72
|
+
// 浏览器环境
|
|
73
|
+
import eslintBowser from "@resolid/config/eslint.bowser";
|
|
74
|
+
|
|
75
|
+
// Node 环境
|
|
76
|
+
import eslintNode from "@resolid/config/eslint.node";
|
|
77
|
+
|
|
78
|
+
/** @type {import('eslint').Linter.FlatConfig[]} */
|
|
79
|
+
export default [...eslintBowser, ...eslintNode];
|
|
66
80
|
```
|
|
67
81
|
|
|
82
|
+
### ESLint 配置查看
|
|
83
|
+
|
|
84
|
+
你可以进入拥有 `eslint.config.js` 文件的目录运行下面的命令来检查
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npx @eslint/config-inspector@latest
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## 致谢
|
|
91
|
+
|
|
92
|
+
- [ESLint Config Inspector](https://github.com/eslint/config-inspector) 用于检查和理解 ESLint 平面配置的可视化工具。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@resolid/config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Resolid 通用配置",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"keywords": [
|
|
10
10
|
"resolid",
|
|
11
|
-
"
|
|
11
|
+
"eslint",
|
|
12
|
+
"prettier",
|
|
12
13
|
"typescript"
|
|
13
14
|
],
|
|
14
15
|
"publishConfig": {
|
|
@@ -16,24 +17,38 @@
|
|
|
16
17
|
"provenance": true
|
|
17
18
|
},
|
|
18
19
|
"files": [
|
|
19
|
-
"
|
|
20
|
+
"src",
|
|
21
|
+
"tsconfig"
|
|
20
22
|
],
|
|
21
23
|
"exports": {
|
|
22
|
-
"
|
|
23
|
-
"./tsconfig.
|
|
24
|
-
"./
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
"./*": "./src/*.js",
|
|
25
|
+
"./tsconfig.base": "./tsconfig/base.json",
|
|
26
|
+
"./tsconfig.react": "./tsconfig/react.json"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@eslint/js": "^9.16.0",
|
|
30
|
+
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
31
|
+
"eslint-plugin-n": "^17.15.0",
|
|
32
|
+
"eslint-plugin-react": "^7.37.2",
|
|
33
|
+
"eslint-plugin-react-compiler": "beta",
|
|
34
|
+
"eslint-plugin-react-hooks": "^5.1.0",
|
|
35
|
+
"eslint-plugin-react-refresh": "^0.4.16",
|
|
36
|
+
"globals": "^15.13.0",
|
|
37
|
+
"prettier-plugin-organize-imports": "^4.1.0",
|
|
38
|
+
"typescript-eslint": "^8.18.0"
|
|
27
39
|
},
|
|
28
40
|
"devDependencies": {
|
|
29
41
|
"@arethetypeswrong/cli": "^0.17.1",
|
|
30
|
-
"@biomejs/biome": "^1.9.4",
|
|
31
42
|
"@changesets/changelog-github": "^0.5.0",
|
|
32
43
|
"@changesets/cli": "^2.27.10",
|
|
33
44
|
"@commitlint/cli": "^19.6.0",
|
|
34
45
|
"@commitlint/config-conventional": "^19.6.0",
|
|
35
|
-
"lefthook": "^1.9.
|
|
36
|
-
"
|
|
46
|
+
"lefthook": "^1.9.1",
|
|
47
|
+
"prettier": "^3.4.2"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"eslint": "^9.16.0",
|
|
51
|
+
"prettier": "^3.4.2"
|
|
37
52
|
},
|
|
38
53
|
"engines": {
|
|
39
54
|
"node": ">=20.0.0"
|
|
@@ -45,7 +60,8 @@
|
|
|
45
60
|
},
|
|
46
61
|
"scripts": {
|
|
47
62
|
"preinstall": "npx only-allow pnpm",
|
|
48
|
-
"check": "
|
|
49
|
-
"
|
|
63
|
+
"check-exports": "attw --pack . --no-definitely-typed --profile esm-only",
|
|
64
|
+
"lint": "eslint .",
|
|
65
|
+
"format": "prettier --write ."
|
|
50
66
|
}
|
|
51
67
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import js from "@eslint/js";
|
|
2
|
+
|
|
3
|
+
/** @type {import('eslint').Linter.FlatConfig[]} */
|
|
4
|
+
export default [
|
|
5
|
+
{
|
|
6
|
+
ignores: [
|
|
7
|
+
"**/node_modules",
|
|
8
|
+
"**/build",
|
|
9
|
+
"**/dist",
|
|
10
|
+
"**/package-lock.json",
|
|
11
|
+
"**/pnpm-lock.yaml",
|
|
12
|
+
"**/.vercel",
|
|
13
|
+
"**/.changeset",
|
|
14
|
+
"**/.idea",
|
|
15
|
+
"**/.cache",
|
|
16
|
+
"**/.output",
|
|
17
|
+
"**/.resolid",
|
|
18
|
+
"**/.vite-inspect",
|
|
19
|
+
"**/*.min.*",
|
|
20
|
+
"**/LICENSE*",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
languageOptions: {
|
|
25
|
+
ecmaVersion: 2022,
|
|
26
|
+
sourceType: "module",
|
|
27
|
+
parserOptions: {
|
|
28
|
+
ecmaVersion: 2022,
|
|
29
|
+
sourceType: "module",
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
linterOptions: {
|
|
33
|
+
reportUnusedDisableDirectives: true,
|
|
34
|
+
},
|
|
35
|
+
rules: {
|
|
36
|
+
...js.configs.recommended.rules,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import n from "eslint-plugin-n";
|
|
2
|
+
import globals from "globals";
|
|
3
|
+
|
|
4
|
+
/** @type {import('eslint').Linter.FlatConfig[]} */
|
|
5
|
+
export default [
|
|
6
|
+
{
|
|
7
|
+
plugins: { n },
|
|
8
|
+
rules: {
|
|
9
|
+
"n/handle-callback-err": ["error", "^(err|error)$"],
|
|
10
|
+
"n/no-deprecated-api": "error",
|
|
11
|
+
"n/no-exports-assign": "error",
|
|
12
|
+
"n/no-new-require": "error",
|
|
13
|
+
"n/no-path-concat": "error",
|
|
14
|
+
"n/prefer-global/buffer": ["error", "never"],
|
|
15
|
+
"n/prefer-global/process": ["error", "never"],
|
|
16
|
+
"n/process-exit-as-throw": "error",
|
|
17
|
+
},
|
|
18
|
+
languageOptions: {
|
|
19
|
+
globals: {
|
|
20
|
+
...globals.node,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
];
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import jsxA11y from "eslint-plugin-jsx-a11y";
|
|
2
|
+
import react from "eslint-plugin-react";
|
|
3
|
+
import reactCompiler from "eslint-plugin-react-compiler";
|
|
4
|
+
import reactHooks from "eslint-plugin-react-hooks";
|
|
5
|
+
import reactRefresh from "eslint-plugin-react-refresh";
|
|
6
|
+
import eslintTypescript from "./eslint.typescript.js";
|
|
7
|
+
|
|
8
|
+
/** @type {import('eslint').Linter.FlatConfig[]} */
|
|
9
|
+
export default [
|
|
10
|
+
...eslintTypescript,
|
|
11
|
+
{
|
|
12
|
+
files: ["**/*.{jsx,tsx}"],
|
|
13
|
+
plugins: {
|
|
14
|
+
react: react,
|
|
15
|
+
"react-refresh": reactRefresh,
|
|
16
|
+
},
|
|
17
|
+
rules: {
|
|
18
|
+
...react.configs.recommended.rules,
|
|
19
|
+
...react.configs["jsx-runtime"].rules,
|
|
20
|
+
"react/prop-types": "off",
|
|
21
|
+
"react-refresh/only-export-components": [
|
|
22
|
+
"warn",
|
|
23
|
+
{
|
|
24
|
+
allowConstantExport: true,
|
|
25
|
+
allowExportNames: [
|
|
26
|
+
"clientAction",
|
|
27
|
+
"clientLoader",
|
|
28
|
+
"ErrorBoundary",
|
|
29
|
+
"handle",
|
|
30
|
+
"HydrateFallback",
|
|
31
|
+
"Layout",
|
|
32
|
+
"links",
|
|
33
|
+
"meta",
|
|
34
|
+
"loader",
|
|
35
|
+
"action",
|
|
36
|
+
"shouldRevalidate",
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
languageOptions: {
|
|
42
|
+
parserOptions: {
|
|
43
|
+
ecmaVersion: 2022,
|
|
44
|
+
sourceType: "module",
|
|
45
|
+
ecmaFeatures: {
|
|
46
|
+
jsx: true,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
settings: {
|
|
51
|
+
react: {
|
|
52
|
+
version: "detect",
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
files: ["**/*.{js,jsx,ts,tsx}"],
|
|
58
|
+
plugins: {
|
|
59
|
+
"react-hooks": reactHooks,
|
|
60
|
+
"react-compiler": reactCompiler,
|
|
61
|
+
},
|
|
62
|
+
rules: {
|
|
63
|
+
...reactHooks.configs.recommended.rules,
|
|
64
|
+
"react-hooks/exhaustive-deps": [
|
|
65
|
+
"warn",
|
|
66
|
+
{
|
|
67
|
+
additionalHooks: "(useIsomorphicEffect)",
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
"react-compiler/react-compiler": "warn",
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
files: ["**/*.{jsx,tsx}"],
|
|
75
|
+
...jsxA11y.flatConfigs.recommended,
|
|
76
|
+
},
|
|
77
|
+
];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import typescript from "typescript-eslint";
|
|
2
|
+
import eslintBase from "./eslint.base.js";
|
|
3
|
+
|
|
4
|
+
/** @type {import('eslint').Linter.FlatConfig[]} */
|
|
5
|
+
export default typescript.config(...eslintBase, ...typescript.configs.recommended, {
|
|
6
|
+
rules: {
|
|
7
|
+
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
8
|
+
"@typescript-eslint/method-signature-style": ["error", "property"],
|
|
9
|
+
"@typescript-eslint/prefer-function-type": "error",
|
|
10
|
+
"@typescript-eslint/prefer-for-of": "error",
|
|
11
|
+
"@typescript-eslint/consistent-type-imports": "error",
|
|
12
|
+
},
|
|
13
|
+
});
|
package/src/prettier.js
ADDED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
/* Base Options: */
|
|
5
4
|
"esModuleInterop": true,
|
|
6
5
|
"skipLibCheck": true,
|
|
7
6
|
"target": "es2022",
|
|
@@ -10,17 +9,11 @@
|
|
|
10
9
|
"moduleDetection": "force",
|
|
11
10
|
"isolatedModules": true,
|
|
12
11
|
"verbatimModuleSyntax": true,
|
|
13
|
-
|
|
14
|
-
/* Strictness */
|
|
15
12
|
"strict": true,
|
|
16
13
|
"noFallthroughCasesInSwitch": true,
|
|
17
14
|
"noImplicitOverride": true,
|
|
18
|
-
|
|
19
|
-
/* If NOT transpiling with TypeScript: */
|
|
20
15
|
"module": "preserve",
|
|
21
16
|
"noEmit": true,
|
|
22
|
-
|
|
23
|
-
/* If your code runs in the DOM: */
|
|
24
17
|
"lib": ["es2022", "dom", "dom.iterable"]
|
|
25
18
|
}
|
|
26
19
|
}
|
package/config/biome.json
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"files": {
|
|
3
|
-
"ignore": ["tsconfig.*.json"]
|
|
4
|
-
},
|
|
5
|
-
"vcs": {
|
|
6
|
-
"enabled": true,
|
|
7
|
-
"clientKind": "git",
|
|
8
|
-
"defaultBranch": "main"
|
|
9
|
-
},
|
|
10
|
-
"organizeImports": {
|
|
11
|
-
"enabled": true
|
|
12
|
-
},
|
|
13
|
-
"formatter": {
|
|
14
|
-
"enabled": true,
|
|
15
|
-
"indentStyle": "space",
|
|
16
|
-
"indentWidth": 2,
|
|
17
|
-
"lineEnding": "lf",
|
|
18
|
-
"lineWidth": 120
|
|
19
|
-
},
|
|
20
|
-
"linter": {
|
|
21
|
-
"enabled": true,
|
|
22
|
-
"rules": {
|
|
23
|
-
"recommended": true,
|
|
24
|
-
"style": {
|
|
25
|
-
"noNonNullAssertion": "off"
|
|
26
|
-
},
|
|
27
|
-
"suspicious": {
|
|
28
|
-
"noDoubleEquals": "off"
|
|
29
|
-
},
|
|
30
|
-
"a11y": {
|
|
31
|
-
"noSvgWithoutTitle": "off",
|
|
32
|
-
"useSemanticElements": "off",
|
|
33
|
-
"noLabelWithoutControl": "off"
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
package/config/biome.react.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"linter": {
|
|
3
|
-
"rules": {
|
|
4
|
-
"correctness": {
|
|
5
|
-
"useExhaustiveDependencies": {
|
|
6
|
-
"level": "error",
|
|
7
|
-
"options": {
|
|
8
|
-
"hooks": [
|
|
9
|
-
{
|
|
10
|
-
"name": "useIsomorphicEffect",
|
|
11
|
-
"closureIndex": 0,
|
|
12
|
-
"dependenciesIndex": 1,
|
|
13
|
-
"stableResult": true
|
|
14
|
-
}
|
|
15
|
-
]
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|