Skip to content

Commit fa6d50a

Browse files
committed
chore: lint
1 parent 69f78e6 commit fa6d50a

File tree

37 files changed

+286
-333
lines changed

37 files changed

+286
-333
lines changed

env/env.cjs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
/* eslint-disable @typescript-eslint/no-var-requires */
2-
const path = require("path");
3-
const fs = require("fs");
1+
const fs = require("node:fs");
2+
const path = require("node:path");
43
const dotEnv = require("dotenv");
54

65
// 先构造出.env*文件的绝对路径

scripts/webpack.config.base.cjs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
/* eslint-disable @typescript-eslint/no-var-requires */
21
require("../env/env.cjs"); // 导入对应环境变量
3-
const pak = require("../package.json");
4-
const path = require("path");
5-
const webpack = require("webpack");
2+
const path = require("node:path");
63
const HtmlWebpackPlugin = require("html-webpack-plugin");
74
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
5+
const webpack = require("webpack");
6+
const pak = require("../package.json");
87

98
const rootDir = path.resolve(__dirname, "../");
109
const dynamicConf = require(`./${process.env.NODE_ENV}.config.cjs`); // 加载对应环境打包配置
1110

1211
const publicVars = Object.keys(process.env)
13-
.filter((key) => key.startsWith("PUBLIC_"))
12+
.filter(key => key.startsWith("PUBLIC_"))
1413
.reduce((env, key) => {
1514
env[key] = process.env[key];
1615
return env;

scripts/webpack.config.cjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-var-requires */
21
const webpack = require("webpack");
32
const baseConfig = require("./webpack.config.base.cjs");
43
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;

src/api/account.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import request from "&src/utils/request";
21
import type { AccountApi } from "../types/api";
2+
import request from "&src/utils/request";
33

4-
export const loginReq = (data: AccountApi.Login) => {
4+
export async function loginReq(data: AccountApi.Login) {
55
return request.send<{ token: string; userInfo: { account: string } }>("/login", "post", data);
6-
};
6+
}

src/api/setting.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import request from "&src/utils/request";
21
import type { CompanyApi } from "../types/api";
2+
import request from "&src/utils/request";
33

44
export const companyService = {
5-
insert: (data: CompanyApi.InsertReq) => {
5+
insert: async (data: CompanyApi.InsertReq) => {
66
return request.send<string>("/company/insert", "post", data, {
77
headers: { "Content-Type": "application/json" },
88
});
99
},
10-
list: (data: CompanyApi.ListReq) => {
10+
list: async (data: CompanyApi.ListReq) => {
1111
return request.send<CompanyApi.ListRes>("/company/list", "post", data);
1212
},
1313
};

src/components/BreadCrumb/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import { memo, useMemo } from "react";
21
import classNames from "classnames";
2+
import { memo, useMemo } from "react";
33
import { useLocation, useNavigate } from "react-router-dom";
44

55
interface BreadCrumbProps {
66
routerPath: { [prop: string]: string };
77
}
88

9-
const BreadCrumb = ({ routerPath = {} }: BreadCrumbProps) => {
9+
function BreadCrumb({ routerPath }: BreadCrumbProps) {
1010
const { pathname } = useLocation();
1111
const navigate = useNavigate();
1212
const currentPath = routerPath[Object.keys(routerPath).find(item => item.startsWith(pathname)) || ""];
1313

1414
const pathMap = useMemo(() => {
1515
const temp: Record<string, string> = {};
1616

17-
Object.keys(routerPath).map(e => {
17+
Object.keys(routerPath).forEach((e) => {
1818
const arr = routerPath[e].split("/");
1919
temp[arr[arr.length - 1].trim()] = e;
2020
});
@@ -42,12 +42,12 @@ const BreadCrumb = ({ routerPath = {} }: BreadCrumbProps) => {
4242
{text}
4343
</span>
4444

45-
{isLast ? null : <span className="ml-2 mr-2">/</span>}
45+
{isLast ? null : <span className="mx-2">/</span>}
4646
</span>
4747
);
4848
})}
4949
</div>
5050
);
51-
};
51+
}
5252

5353
export default memo(BreadCrumb);

src/components/Error/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { memo } from "react";
2-
31
import error from "&src/assets/images/error.png";
42

5-
const Error = () => {
3+
import { memo } from "react";
4+
5+
function Error() {
66
return (
77
<div className=" flex h-screen w-screen flex-col items-center justify-center">
88
<img src={error} alt="" className="h-1/2" />
99
<div>系统错误!!</div>
1010
</div>
1111
);
12-
};
12+
}
1313

1414
export default memo(Error);

src/components/ErrorBoundary/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Component, ReactElement } from "react";
1+
import type { ReactElement } from "react";
2+
import { Component } from "react";
23

34
class ErrorBoundary extends Component<{
45
children: ReactElement;

src/components/FormFilter/index.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { memo, useRef } from "react";
2-
import { Button, Card, FormInstance } from "antd";
1+
import type { FormInstance } from "antd";
2+
import type { FormListProps } from "../FormList";
3+
import { Button, Card } from "antd";
34

4-
import FormList, { FormListProps } from "../FormList";
5+
import { memo, useRef } from "react";
6+
import FormList from "../FormList";
57

68
export interface FormFilterProps extends Pick<FormListProps, "form" | "onOk" | "onForm" | "onValuesChange" | "initialValues" | "stageValues"> {
79
className?: string;
@@ -12,7 +14,7 @@ export interface FormFilterProps extends Pick<FormListProps, "form" | "onOk" | "
1214
searchBtn?: boolean;
1315
}
1416

15-
const FormFilter = (props: FormFilterProps) => {
17+
function FormFilter(props: FormFilterProps) {
1618
const { className, filterInfo, reset, loading, compact = false, searchBtn = true, onForm, ...resetProps } = props;
1719

1820
const formInstance = useRef<FormInstance<any> | null>(null);
@@ -46,6 +48,6 @@ const FormFilter = (props: FormFilterProps) => {
4648
/>
4749
</Card>
4850
);
49-
};
51+
}
5052

5153
export default memo(FormFilter);

src/components/FormList/index.tsx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import { memo, ReactElement, useEffect, useMemo } from "react";
2-
import { Button, Form, FormInstance, FormProps } from "antd";
1+
import type { FormInstance, FormProps } from "antd";
2+
import type { ReactElement } from "react";
3+
import { Button, Form } from "antd";
4+
import { memo, useEffect, useMemo } from "react";
35

46
import { getFormElement } from "../tools";
57

@@ -31,7 +33,7 @@ export interface FormListProps extends Omit<FormProps, "labelCol" | "wrapperCol"
3133
*
3234
* @description extend antd Form
3335
*/
34-
const FormList = (props: FormListProps) => {
36+
function FormList(props: FormListProps) {
3537
const {
3638
form,
3739
itemInfo,
@@ -50,16 +52,17 @@ const FormList = (props: FormListProps) => {
5052
} = props;
5153

5254
const [insideForm] = Form.useForm();
53-
const realForm = form ? form : insideForm;
55+
const realForm = form || insideForm;
5456

5557
// 只在初始化时生效
5658
useEffect(() => {
5759
onForm?.(realForm);
5860

5961
if (initialValues) {
6062
realForm.setFieldsValue(initialValues);
61-
} else {
62-
itemInfo.forEach(e => {
63+
}
64+
else {
65+
itemInfo.forEach((e) => {
6366
if (e.initialValue !== undefined && e.initialValue !== null) {
6467
realForm.setFieldValue(e.name, e.initialValue);
6568
}
@@ -84,22 +87,24 @@ const FormList = (props: FormListProps) => {
8487
if (submitBtn) {
8588
if (submitNode) {
8689
return submitNode;
87-
} else {
90+
}
91+
else {
8892
return (
8993
<Button htmlType="submit" type="primary" block>
9094
保存
9195
</Button>
9296
);
9397
}
94-
} else {
98+
}
99+
else {
95100
return null;
96101
}
97102
}, [submitBtn, submitNode]);
98103

99104
return (
100105
<Form form={realForm} labelCol={labelCol ? { span: labelCol } : undefined} wrapperCol={wrapperCol ? { span: wrapperCol } : undefined} onFinish={onOk} {...restProps}>
101106
{itemInfo.map((e, idx) => {
102-
const key = e.name instanceof Array ? e.name.join("_") : e.name || idx;
107+
const key = Array.isArray(e.name) ? e.name.join("_") : e.name || idx;
103108

104109
if (e.hide) {
105110
return null;
@@ -131,6 +136,6 @@ const FormList = (props: FormListProps) => {
131136
{submitBtnNode}
132137
</Form>
133138
);
134-
};
139+
}
135140

136141
export default memo(FormList);

0 commit comments

Comments
 (0)