Skip to content

Commit 0e83cbc

Browse files
committed
feat: update base
1 parent 2c27c6a commit 0e83cbc

19 files changed

+429
-258
lines changed

.eslintrc.json

+198-20
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
"browser": true,
44
"es2021": true
55
},
6-
// 也可以不用airbnb-typescript
7-
// 因为你都用@typescript-eslint/parser解析器了,可以识别
86
"extends": [
9-
// 你配置了airbnb这个规则 就不用再配置多个 选择一个就行 当然也可以多个 重复的话就覆盖
10-
// "plugin:react/recommended",
11-
"plugin:@typescript-eslint/recommended",
127
"airbnb",
13-
"plugin:prettier/recommended",
8+
"plugin:import/errors",
9+
"plugin:import/warnings",
10+
// ts项目可能跟eslint规则冲突,这个插件就是解决这个问题的
11+
// 注意优先级
12+
"plugin:react/recommended",
13+
"plugin:@typescript-eslint/recommended",
1414
"prettier", // 可能会覆盖eslint-config-airbnb的rule配置 不需要prettier/airbnb 理清楚这种关系 ===>基础配置
15-
"prettier/react"
15+
"plugin:prettier/recommended"
1616
],
1717
"parser": "@typescript-eslint/parser",
1818
"parserOptions": {
@@ -23,21 +23,199 @@
2323
"sourceType": "module",
2424
"project": "./tsconfig.json"
2525
},
26-
"plugins": ["react", "@typescript-eslint", "react-hooks", "prettier"],
26+
"plugins": ["react", "@typescript-eslint", "prettier", "import", "react-hooks"],
27+
"settings": {
28+
"react": {
29+
"pragma": "React",
30+
"version": "detect"
31+
}
32+
},
2733
"rules": {
28-
"prettier/prettier": "error",
29-
"import/extensions": 0,
30-
"import/no-cycle": 0,
31-
"import/no-aextraneous-dependencies": ["error", { "devDependencies": true }],
32-
"import/no-named-as-default": 0,
33-
"react/jsx-props-no-spreading": 0,
34-
"import/prefer-default-export": 0,
35-
"react/button-has-type": 0,
36-
"react/require-default-props": 0,
34+
"@typescript-eslint/adjacent-overload-signatures": "error",
35+
"@typescript-eslint/array-type": "error",
36+
"@typescript-eslint/ban-types": "off",
37+
"@typescript-eslint/naming-convention": "off",
38+
"@typescript-eslint/consistent-type-assertions": "error",
39+
"@typescript-eslint/consistent-type-definitions": "error",
40+
"@typescript-eslint/explicit-member-accessibility": [
41+
"error",
42+
{
43+
"accessibility": "no-public"
44+
}
45+
],
46+
"@typescript-eslint/explicit-function-return-type": "off",
47+
"@typescript-eslint/indent": "off",
48+
"@typescript-eslint/member-delimiter-style": [
49+
"off",
50+
{
51+
"multiline": {
52+
"delimiter": "none",
53+
"requireLast": true
54+
},
55+
"singleline": {
56+
"delimiter": "semi",
57+
"requireLast": false
58+
}
59+
}
60+
],
61+
"@typescript-eslint/member-ordering": "error",
62+
"@typescript-eslint/no-empty-function": "error",
63+
"@typescript-eslint/no-empty-interface": "off",
64+
"@typescript-eslint/no-explicit-any": "off",
65+
"@typescript-eslint/no-misused-new": "error",
66+
"@typescript-eslint/no-namespace": "off",
67+
"@typescript-eslint/no-parameter-properties": "off",
68+
"@typescript-eslint/no-var-requires": "error",
69+
"@typescript-eslint/prefer-for-of": "error",
70+
"@typescript-eslint/prefer-function-type": "error",
71+
"@typescript-eslint/prefer-namespace-keyword": "off",
72+
"@typescript-eslint/quotes": "off",
73+
"@typescript-eslint/semi": ["off", null],
74+
"@typescript-eslint/space-within-parens": ["off", "never"],
75+
"@typescript-eslint/triple-slash-reference": [
76+
"error",
77+
{
78+
"path": "always",
79+
"types": "always",
80+
"lib": "always"
81+
}
82+
],
83+
"@typescript-eslint/type-annotation-spacing": "off",
84+
"@typescript-eslint/unified-signatures": "error",
85+
"arrow-body-style": "error",
86+
"arrow-parens": ["off", "as-needed"],
87+
"camelcase": "off",
88+
"comma-dangle": "off",
89+
"complexity": "off",
90+
"constructor-super": "error",
91+
"curly": "error",
92+
"dot-notation": "error",
93+
"eol-last": "off",
94+
"eqeqeq": ["error", "always"],
95+
"guard-for-in": "error",
96+
"id-blacklist": [
97+
"error",
98+
"any",
99+
"Number",
100+
"number",
101+
"String",
102+
"string",
103+
"Boolean",
104+
"boolean",
105+
"Undefined",
106+
"undefined"
107+
],
108+
"id-match": "error",
109+
"import/order": "off",
110+
"linebreak-style": "off",
111+
"max-classes-per-file": "off",
112+
"max-len": "off",
113+
"new-parens": "off",
114+
"newline-per-chained-call": "off",
115+
"no-bitwise": "error",
116+
"no-caller": "error",
117+
"no-cond-assign": "error",
118+
"no-console": "off",
119+
"no-debugger": "error",
120+
"no-empty": "error",
121+
"no-eval": "error",
122+
"no-extra-semi": "off",
123+
"no-fallthrough": "off",
124+
"no-invalid-this": "off",
125+
"no-irregular-whitespace": "off",
126+
"no-multiple-empty-lines": "off",
127+
"no-new-wrappers": "error",
128+
"no-shadow": [
129+
"off",
130+
{
131+
"hoist": "all"
132+
}
133+
],
134+
"no-throw-literal": "error",
135+
"no-trailing-spaces": "off",
136+
"no-undef-init": "error",
137+
"no-underscore-dangle": [
138+
"error",
139+
{
140+
"allow": ["__INITIAL_DATA__", "__STORE__", "_insertCss"],
141+
"allowAfterThis": true,
142+
"allowAfterThisConstructor": true
143+
}
144+
],
145+
"no-unsafe-finally": "error",
146+
"no-unused-expressions": [
147+
"error",
148+
{
149+
"allowShortCircuit": true,
150+
"allowTernary": true
151+
}
152+
],
153+
"no-use-before-define": "off",
154+
"no-unused-labels": "error",
155+
"no-var": "error",
156+
"object-shorthand": "error",
157+
"one-var": ["error", "never"],
158+
"prefer-arrow-callback": ["error", { "allowNamedFunctions": true }],
159+
"prefer-const": "error",
160+
"quote-props": "off",
161+
"radix": "error",
162+
"space-before-function-paren": "off",
163+
"spaced-comment": ["error", "always", { "markers": ["/"] }],
164+
"use-isnan": "error",
165+
"valid-typeof": "off",
166+
"react/jsx-no-target-blank": [
167+
"error",
168+
{
169+
"enforceDynamicLinks": "always"
170+
}
171+
],
172+
"no-restricted-syntax": "off",
173+
"import/extensions": "off",
174+
"import/no-unresolved": "off",
175+
"react/no-unused-state": "error",
176+
"react/self-closing-comp": "error",
177+
"react/boolean-prop-naming": ["error", { "rule": "^(is|has)[A-Z]([A-Za-z0-9]?)+" }],
178+
"react/no-direct-mutation-state": "error",
179+
"react/no-multi-comp": [
180+
"error",
181+
{
182+
"ignoreStateless": true
183+
}
184+
],
185+
"react/no-this-in-sfc": "error",
186+
"react/no-unsafe": [
187+
"error",
188+
{
189+
"checkAliases": true
190+
}
191+
],
192+
"react/state-in-constructor": ["error", "never"],
193+
"react/jsx-uses-vars": "error",
194+
"react/jsx-pascal-case": "error",
195+
"react/jsx-no-useless-fragment": "error",
196+
"react/jsx-no-bind": [
197+
"error",
198+
{
199+
"allowArrowFunctions": true,
200+
"ignoreRefs": true
201+
}
202+
],
203+
"react/jsx-no-duplicate-props": "error",
204+
"react/jsx-equals-spacing": [2, "never"],
205+
"react/jsx-boolean-value": ["error", "never"],
206+
"react/jsx-closing-tag-location": "error",
207+
"react/display-name": "off",
208+
"react/jsx-props-no-spreading": "off",
37209
"react-hooks/rules-of-hooks": "error", // 检查 Hook 的规则
38210
"react-hooks/exhaustive-deps": "warn", // 检查 effect 的依赖
39-
"no-console": "off",
40-
"no-void": "off",
41-
"@typescript-eslint/dot-notation": ["error"]
211+
"react/jsx-filename-extension": [2, { "extensions": [".js", ".jsx", ".ts", ".tsx"] }]
42212
}
213+
// "overrides": [
214+
// {
215+
// "files": ["global.d.ts", "css.modules.d.ts", "pro-config.ts"],
216+
// "rules": {
217+
// "@typescript-eslint/naming-convention": "off"
218+
// }
219+
// }
220+
// ]
43221
}

build/start.js

+5-10
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const getIp = require('../src/server/utils/get-ip')
1818
// node server port
1919
const nodeServerPort = proConfig.nodeServerPort
2020

21-
2221
const localHostIp = getIp()
2322

2423
log(chalk.red('servers starting....'))
@@ -39,20 +38,16 @@ let nodeServerProcess = null
3938
const startNodeServer = () => {
4039
// 重启 node 服务
4140
nodeServerProcess && nodeServerProcess.kill()
42-
nodeServerProcess = spawn(
43-
'node',
44-
['./build/server/dev-server.js', localHostIp],
45-
{ stdio: 'inherit', shell: process.platform === 'win32' }
46-
)
41+
nodeServerProcess = spawn('node', ['./build/server/dev-server.js', localHostIp], {
42+
stdio: 'inherit',
43+
shell: process.platform === 'win32'
44+
})
4745
}
4846

49-
let flag=false
50-
5147
// 控制台输出信息
5248
function print(data) {
5349
let str = data.toString()
54-
if (str.indexOf(constantCode.SVRCODECOMPLETED) > -1&&!flag) {
55-
flag=true
50+
if (str.indexOf(constantCode.SVRCODECOMPLETED) > -1) {
5651
// 服务端代码编译完成
5752
startNodeServer() // 重启 node 服务
5853
} else {

package.json

+9-6
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@
2323
"license": "ISC",
2424
"dependencies": {
2525
"@babel/runtime": "^7.13.17",
26-
"@forchange/apis": "0.0.20",
2726
"@rematch/core": "^2.0.1",
2827
"art-apis": "^1.0.0",
2928
"axios": "^0.21.1",
3029
"classnames": "^2.3.1",
3130
"history": "^5.0.0",
31+
"isomorphic-style-loader": "^5.1.0",
3232
"koa": "^2.13.1",
3333
"koa-static": "^5.0.0",
34+
"koa2-proxy-middleware": "0.0.4",
3435
"react": "^17.0.2",
3536
"react-dom": "^17.0.2",
3637
"react-redux": "^7.2.4",
@@ -40,7 +41,8 @@
4041
"redux-actions": "^2.6.5",
4142
"redux-promise-middleware": "^6.1.2",
4243
"sa-sdk-javascript": "^1.16.12",
43-
"uuid": "^8.3.2"
44+
"uuid": "^8.3.2",
45+
"react-hot-loader": "^4.13.0"
4446
},
4547
"devDependencies": {
4648
"@babel/core": "^7.13.16",
@@ -55,14 +57,17 @@
5557
"@commitlint/config-conventional": "^12.1.1",
5658
"@hot-loader/react-dom": "^17.0.1",
5759
"@types/classnames": "^2.3.1",
60+
"@types/node": "^15.0.1",
5861
"@types/react-dom": "^17.0.3",
5962
"@types/react-router-dom": "^5.1.7",
60-
"@typescript-eslint/eslint-plugin": "^4.22.0",
63+
"@types/webpack-env": "^1.16.0",
64+
"@typescript-eslint/eslint-plugin": "4.0.1",
6165
"@typescript-eslint/parser": "^4.22.0",
6266
"babel-loader": "^8.2.2",
6367
"clean-webpack-plugin": "^4.0.0-alpha.0",
6468
"commitizen": "^4.2.3",
6569
"connect-history-api-fallback": "^1.6.0",
70+
"cross-env": "^7.0.3",
6671
"css-loader": "^3.4.0",
6772
"cz-customizable": "^6.3.0",
6873
"eslint": "^7.25.0",
@@ -82,8 +87,6 @@
8287
"get-port": "^5.1.1",
8388
"html-webpack-plugin": "^5.3.1",
8489
"husky": "^4.2.5",
85-
"isomorphic-style-loader": "^5.1.0",
86-
"koa2-proxy-middleware": "0.0.4",
8790
"less": "^4.1.1",
8891
"less-loader": "^8.1.1",
8992
"lint-staged": "^10.5.4",
@@ -93,7 +96,6 @@
9396
"postcss-loader": "^5.2.0",
9497
"prettier": "^2.2.1",
9598
"progress-bar-webpack-plugin": "^2.1.0",
96-
"react-hot-loader": "^4.13.0",
9799
"redux-devtools-extension": "^2.13.9",
98100
"redux-logger": "^3.0.6",
99101
"standard-version": "^9.2.0",
@@ -106,6 +108,7 @@
106108
"url-loader": "^4.1.1",
107109
"webpack": "^5.35.1",
108110
"webpack-bundle-analyzer": "^4.4.1",
111+
"webpack-cli": "^4.6.0",
109112
"webpack-dev-middleware": "^4.1.0",
110113
"webpack-hot-middleware": "^2.25.0",
111114
"webpack-merge": "^5.7.3",

0 commit comments

Comments
 (0)