@resolid/config 1.0.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/LICENSE +21 -0
- package/README.md +84 -0
- package/package.json +58 -0
- package/src/eslint.base.js +41 -0
- package/src/eslint.bowser.js +12 -0
- package/src/eslint.node.js +24 -0
- package/src/eslint.react.js +65 -0
- package/src/eslint.typescript.js +5 -0
- package/tsconfig.base.json +32 -0
- package/tsconfig.react.json +6 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022-present, Resolid Tech
|
|
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
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# @resolid/config
|
|
2
|
+
|
|
3
|
+
Resolid 通用配置, 包含了 `TypeScript`, `ESLint` 的基础配置
|
|
4
|
+
|
|
5
|
+
## 使用方法
|
|
6
|
+
|
|
7
|
+
### 安装
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add -D eslint @resolid/config
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### TypeScript 配置
|
|
14
|
+
|
|
15
|
+
增加下面内容到 `tsconfig.json`
|
|
16
|
+
|
|
17
|
+
#### 普通项目
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"extends": "@resolid/config/tsconfig.base"
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
#### React 项目
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"extends": "@resolid/config/tsconfig.react"
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### ESLint 配置
|
|
34
|
+
|
|
35
|
+
本配置包是纯 ESM 包, 并使用了 ESLint 扁平配置, 需要使用 `eslint.config.js` 文件来进行配置
|
|
36
|
+
|
|
37
|
+
语言选项默认为 `ecmaVersion: 2022`, `sourceType: 'module'`
|
|
38
|
+
|
|
39
|
+
#### TypeScript Lint 配置
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
// eslint.config.js
|
|
43
|
+
import eslintTypescript from "@resolid/config/eslint.typescript";
|
|
44
|
+
|
|
45
|
+
/** @type {import('eslint').Linter.FlatConfig[]} */
|
|
46
|
+
export default [...eslintTypescript];
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
#### React Lint 配置
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
// eslint.config.js
|
|
53
|
+
import eslintReact from "@resolid/config/eslint.react";
|
|
54
|
+
|
|
55
|
+
/** @type {import('eslint').Linter.FlatConfig[]} */
|
|
56
|
+
export default [...eslintReact];
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### ESLint 环境设置
|
|
60
|
+
|
|
61
|
+
```js
|
|
62
|
+
// eslint.config.js
|
|
63
|
+
|
|
64
|
+
// 浏览器环境
|
|
65
|
+
import eslintBowser from "@resolid/config/eslint.bowser";
|
|
66
|
+
|
|
67
|
+
// Node 环境
|
|
68
|
+
import eslintNode from "@resolid/config/eslint.node";
|
|
69
|
+
|
|
70
|
+
/** @type {import('eslint').Linter.FlatConfig[]} */
|
|
71
|
+
export default [...eslintBowser, ...eslintNode];
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### ESLint 配置查看
|
|
75
|
+
|
|
76
|
+
你可以进入拥有 `eslint.config.js` 文件的目录运行下面的命令来检查
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
npx eslint-flat-config-viewer
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## 感谢
|
|
83
|
+
|
|
84
|
+
- [eslint-flat-config-viewer](https://github.com/antfu/eslint-flat-config-viewer)
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@resolid/config",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"description": "Resolid 通用配置",
|
|
7
|
+
"author": "Huijie Wei",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"resolid",
|
|
11
|
+
"eslint",
|
|
12
|
+
"typescript"
|
|
13
|
+
],
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public",
|
|
16
|
+
"provenance": true
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"src",
|
|
20
|
+
"tsconfig.base.json",
|
|
21
|
+
"tsconfig.react.json"
|
|
22
|
+
],
|
|
23
|
+
"exports": {
|
|
24
|
+
"./tsconfig.base": "./tsconfig.base.json",
|
|
25
|
+
"./tsconfig.react": "./tsconfig.react.json",
|
|
26
|
+
"./*": "./src/*.js"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@eslint/js": "^8.57.0",
|
|
30
|
+
"eslint-plugin-jsx-a11y": "^6.8.0",
|
|
31
|
+
"eslint-plugin-n": "^16.6.2",
|
|
32
|
+
"eslint-plugin-react": "^7.34.0",
|
|
33
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
34
|
+
"globals": "^14.0.0",
|
|
35
|
+
"typescript-eslint": "^7.1.1"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"eslint": "^8.57.0",
|
|
39
|
+
"typescript": "^5.4.2"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"eslint": "^8.57.0",
|
|
43
|
+
"typescript": "^5.4.2"
|
|
44
|
+
},
|
|
45
|
+
"peerDependenciesMeta": {
|
|
46
|
+
"typescript": {
|
|
47
|
+
"optional": true
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"homepage": "https://resolid.tech",
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "git+https://github.com/huijiewei/resolid-config.git"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"lint": "eslint ."
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
"no-extra-semi": "off",
|
|
38
|
+
"no-mixed-spaces-and-tabs": "off",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
];
|
|
@@ -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,65 @@
|
|
|
1
|
+
import jsxA11y from "eslint-plugin-jsx-a11y";
|
|
2
|
+
import react from "eslint-plugin-react";
|
|
3
|
+
import reactHooks from "eslint-plugin-react-hooks";
|
|
4
|
+
import eslintTypescript from "./eslint.typescript.js";
|
|
5
|
+
|
|
6
|
+
/** @type {import('eslint').Linter.FlatConfig[]} */
|
|
7
|
+
export default [
|
|
8
|
+
...eslintTypescript,
|
|
9
|
+
{
|
|
10
|
+
files: ["**/*.{jsx,tsx}"],
|
|
11
|
+
plugins: {
|
|
12
|
+
react: react,
|
|
13
|
+
},
|
|
14
|
+
rules: {
|
|
15
|
+
...react.configs.recommended.rules,
|
|
16
|
+
...react.configs["jsx-runtime"].rules,
|
|
17
|
+
"react/prop-types": "off",
|
|
18
|
+
},
|
|
19
|
+
languageOptions: {
|
|
20
|
+
parserOptions: {
|
|
21
|
+
ecmaVersion: 2022,
|
|
22
|
+
sourceType: "module",
|
|
23
|
+
ecmaFeatures: {
|
|
24
|
+
jsx: true,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
settings: {
|
|
29
|
+
react: {
|
|
30
|
+
version: "detect",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
files: ["**/*.{js,jsx,ts,tsx}"],
|
|
36
|
+
plugins: {
|
|
37
|
+
"react-hooks": reactHooks,
|
|
38
|
+
},
|
|
39
|
+
rules: {
|
|
40
|
+
...reactHooks.configs.recommended.rules,
|
|
41
|
+
"react-hooks/exhaustive-deps": [
|
|
42
|
+
"warn",
|
|
43
|
+
{
|
|
44
|
+
additionalHooks: "(useIsomorphicEffect)",
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
files: ["**/*.{jsx,tsx}"],
|
|
51
|
+
plugins: {
|
|
52
|
+
"jsx-a11y": jsxA11y,
|
|
53
|
+
},
|
|
54
|
+
rules: {
|
|
55
|
+
...jsxA11y.configs.recommended.rules,
|
|
56
|
+
},
|
|
57
|
+
languageOptions: {
|
|
58
|
+
parserOptions: {
|
|
59
|
+
ecmaFeatures: {
|
|
60
|
+
jsx: true,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
// Type Checking
|
|
5
|
+
"strict": true,
|
|
6
|
+
"noFallthroughCasesInSwitch": true,
|
|
7
|
+
|
|
8
|
+
// Modules
|
|
9
|
+
"module": "ES2022",
|
|
10
|
+
"moduleResolution": "Bundler",
|
|
11
|
+
"resolveJsonModule": true,
|
|
12
|
+
"moduleDetection": "force",
|
|
13
|
+
|
|
14
|
+
// Emit
|
|
15
|
+
"noEmit": true,
|
|
16
|
+
"verbatimModuleSyntax": true,
|
|
17
|
+
|
|
18
|
+
// JavaScript Support
|
|
19
|
+
"allowJs": true,
|
|
20
|
+
|
|
21
|
+
// Interop Constraints
|
|
22
|
+
"esModuleInterop": true,
|
|
23
|
+
"forceConsistentCasingInFileNames": true,
|
|
24
|
+
|
|
25
|
+
// Language and Environment
|
|
26
|
+
"lib": ["DOM", "DOM.Iterable", "ES2022"],
|
|
27
|
+
"target": "ES2022",
|
|
28
|
+
|
|
29
|
+
// Completeness
|
|
30
|
+
"skipLibCheck": true
|
|
31
|
+
}
|
|
32
|
+
}
|