Skip to content

Commit 366c64a

Browse files
author
chj_damon
committed
chore: 更新格式化配置文件
1 parent 23fac04 commit 366c64a

File tree

11 files changed

+154
-3036
lines changed

11 files changed

+154
-3036
lines changed

.eslintrc.js

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
1+
/** @format */
2+
13
module.exports = {
2-
extends: [require.resolve('@umijs/fabric/dist/eslint')],
3-
rules: {
4-
'no-console': 0,
5-
'global-require': 0,
6-
'no-param-reassign': 0,
7-
'symbol-description': 0,
8-
'no-unused-expressions': 'off',
9-
'max-classes-per-file': 0,
10-
'@typescript-eslint/no-unused-expressions': 2,
11-
'@typescript-eslint/no-shadow': 0,
12-
'@typescript-eslint/consistent-type-definitions': 0,
13-
},
14-
};
4+
parser: '@typescript-eslint/parser',
5+
extends: ['plugin:@typescript-eslint/recommended'], //使用推荐的React代码检测规范
6+
plugins: ['@typescript-eslint'],
7+
env: {
8+
browser: true,
9+
node: true,
10+
},
11+
settings: {
12+
//自动发现React的版本,从而进行规范react代码
13+
react: {
14+
pragma: 'React',
15+
version: 'detect',
16+
},
17+
},
18+
parserOptions: {
19+
//指定ESLint可以解析JSX语法
20+
ecmaVersion: 2019,
21+
sourceType: 'module',
22+
ecmaFeatures: {
23+
jsx: true,
24+
},
25+
},
26+
rules: {
27+
'@typescript-eslint/explicit-module-boundary-types': 0,
28+
'@typescript-eslint/no-non-null-assertion': 0,
29+
},
30+
}

.prettierrc.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
const fabric = require('@umijs/fabric');
2-
31
module.exports = {
4-
...fabric.prettier,
2+
printWidth: 120,
3+
semi: true,
4+
singleQuote: true,
5+
trailingComma: 'all',
6+
bracketSpacing: true,
7+
jsxBracketSameLine: true,
8+
arrowParens: 'avoid',
9+
insertPragma: false,
10+
tabWidth: 2,
11+
useTabs: false,
512
};

.stylelintrc.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@
2020
"build": "cross-env UMI_ENV=prod MOCK=none umi build",
2121
"test": "jest --passWithNoTests --detectOpenHandles --watch",
2222
"tsc": "tsc -p ./tsconfig.json",
23-
"eslint:fix": "eslint --fix --ext .ts,.tsx src/",
24-
"prettier:fix": "prettier --check src/**/*.{ts,tsx} --write",
25-
"style:fix": "stylelint src/**/*.{css,less,scss} --fix"
23+
"eslint": "eslint --fix --ext .ts,.tsx src/",
24+
"prettier": "prettier --check src/**/*.{ts,tsx} --write"
2625
},
2726
"config": {
2827
"commitizen": {
@@ -64,14 +63,16 @@
6463
"@types/jest": "^26.0.20",
6564
"@types/react": "^17.0.3",
6665
"@types/react-dom": "^17.0.2",
67-
"@umijs/fabric": "^2.5.7",
66+
"@typescript-eslint/eslint-plugin": "^4.20.0",
67+
"@typescript-eslint/parser": "^4.20.0",
6868
"@umijs/plugin-esbuild": "^1.1.0",
6969
"antd-dayjs-webpack-plugin": "^1.0.6",
7070
"commitizen": "^4.2.3",
7171
"conventional-changelog-cli": "^2.1.0",
7272
"conventional-changelog-custom-config": "^0.3.1",
7373
"cross-env": "^7.0.3",
7474
"cz-customizable": "^6.3.0",
75+
"eslint": "^7.23.0",
7576
"husky": "^5.1.3",
7677
"jest": "^26.6.3",
7778
"jest-fetch-mock": "^3.0.3",
@@ -81,7 +82,6 @@
8182
"prettier": "^2.2.1",
8283
"react-test-renderer": "^17.0.1",
8384
"standard-version": "^9.1.1",
84-
"stylelint": "^13.12.0",
8585
"ts-jest": "^26.5.3",
8686
"typescript": "^4.2.3"
8787
},

src/components/Loading.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ export default function Loading() {
1010
display: 'flex',
1111
justifyContent: 'center',
1212
alignItems: 'center',
13-
}}
14-
>
13+
}}>
1514
<Spin size="large" />
1615
</div>
1716
);

src/layouts/index.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ export default (props: IRouteComponentProps) => {
1414
<ConfigProvider
1515
locale={zhCN}
1616
renderEmpty={() => <Empty image={require('@/assets/pic_empty.png')} description="暂无数据" />}
17-
getPopupContainer={(trigger) => trigger.parentElement || document.body}
18-
form={{ validateMessages }}
19-
>
17+
getPopupContainer={trigger => trigger.parentElement || document.body}
18+
form={{ validateMessages }}>
2019
<SWRConfig
2120
value={{
2221
/** 是否开启suspense模式,默认值false */
@@ -53,7 +52,7 @@ export default (props: IRouteComponentProps) => {
5352
/** 请求成功完成时的回调函数 */
5453
// onSuccess(data, key, config)
5554
/** 请求返回错误时的回调函数 */
56-
onError: (err) => {
55+
onError: err => {
5756
message.error(err.message);
5857
},
5958
/** 错误重试的处理函数 */
@@ -62,8 +61,7 @@ export default (props: IRouteComponentProps) => {
6261
// compare(a, b)
6362
/** 用于检测是否暂停重新验证的函数,当返回 true 时将忽略所请求的数据和错误。默认返回 false */
6463
// isPaused()
65-
}}
66-
>
64+
}}>
6765
<AuthContext.Provider value={authService}>{props.children}</AuthContext.Provider>
6866
</SWRConfig>
6967
</ConfigProvider>

src/pages/404.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ export default () => {
99
display: 'flex',
1010
justifyContent: 'center',
1111
alignItems: 'center',
12-
}}
13-
>
12+
}}>
1413
<div style={{ width: 600, textAlign: 'center' }}>
1514
<img alt="" src={require('@/assets/pic_404.png')} style={{ width: '100%' }} />
1615
<div style={{ lineHeight: 3 }}>对不起,您访问的页面不存在</div>

src/utils/getContextService.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import { createContext } from 'react';
88
* @param {(T | undefined)} [initialData=undefined]
99
* @returns
1010
*/
11-
export default function getContextService<T>(
12-
initialData: T | undefined = undefined,
13-
) {
11+
export default function getContextService<T>(initialData: T | undefined = undefined) {
1412
return createContext<T>(initialData as T);
1513
}

src/utils/json.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
*/
66
reverseObj(obj: Record<string, string | number>) {
77
const reversedObj: Record<string, string | number> = {};
8-
Object.keys(obj).forEach((key) => {
8+
Object.keys(obj).forEach(key => {
99
const value = obj[key];
1010
reversedObj[value] = key;
1111
});
@@ -18,7 +18,7 @@ export default {
1818
*/
1919
removeEmpty(obj: any) {
2020
const newObj = {};
21-
Object.keys(obj).forEach((key) => {
21+
Object.keys(obj).forEach(key => {
2222
if (!['', null, undefined].includes(obj[key])) {
2323
newObj[key] = obj[key];
2424
}

src/utils/string.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export default {
7777
canvas = null;
7878
resolve(dataURL);
7979
};
80-
img.onerror = (error) => {
80+
img.onerror = error => {
8181
reject(error);
8282
};
8383
img.src = url;

0 commit comments

Comments
 (0)