增加eslint
parent
6e12219a31
commit
b0464e48fa
|
|
@ -0,0 +1,49 @@
|
|||
import antfu from "@antfu/eslint-config";
|
||||
|
||||
export default antfu({
|
||||
formatters: {
|
||||
html: false,
|
||||
css: true,
|
||||
},
|
||||
test: false,
|
||||
typescript: true,
|
||||
react: true,
|
||||
vue: false,
|
||||
markdown: false,
|
||||
stylistic: {
|
||||
semi: true,
|
||||
quotes: "double",
|
||||
},
|
||||
overrides: {
|
||||
react: {
|
||||
"react/no-comment-textnodes": "off",
|
||||
"react/no-implicit-key": "off",
|
||||
"react-hooks-extra/no-unnecessary-use-prefix": "off",
|
||||
"react-hooks-extra/prefer-use-state-lazy-initialization": "off",
|
||||
"react-hooks/exhaustive-deps": "off",
|
||||
},
|
||||
javascript: {
|
||||
"no-console": ["warn", { allow: ["warn", "error"] }],
|
||||
"no-debugger": "error",
|
||||
"no-alert": "error",
|
||||
"no-restricted-syntax": [
|
||||
"error",
|
||||
{
|
||||
selector: "VariableDeclarator[id.name='pd']",
|
||||
message: "不允许使用 pd,请改用有语义化的变量名",
|
||||
},
|
||||
{
|
||||
selector: "ObjectExpression > Property[key.name='pd']",
|
||||
message: "不允许使用 pd,请改用有语义化的变量名",
|
||||
},
|
||||
],
|
||||
"no-unused-vars": ["error", { varsIgnorePattern: "^React$" }],
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
"antfu/top-level-function": "off",
|
||||
"node/prefer-global/process": "off",
|
||||
"dot-notation": "off",
|
||||
"linebreak-style": ["off", "windows"],
|
||||
},
|
||||
});
|
||||
|
|
@ -46,15 +46,22 @@
|
|||
"use-antd-resizable-header": "^3.2.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@antfu/eslint-config": "^5.4.1",
|
||||
"@babel/core": "^7.28.5",
|
||||
"@babel/preset-react": "^7.28.5",
|
||||
"@eslint-react/eslint-plugin": "^2.2.2",
|
||||
"@rollup/plugin-babel": "^6.1.0",
|
||||
"@rollup/plugin-commonjs": "^29.0.0",
|
||||
"@rollup/plugin-image": "^3.0.3",
|
||||
"@rollup/plugin-json": "^6.1.0",
|
||||
"@rollup/plugin-node-resolve": "^16.0.3",
|
||||
"@rollup/plugin-terser": "^0.4.4",
|
||||
"eslint": "^9.37.0",
|
||||
"eslint-plugin-format": "^1.0.2",
|
||||
"eslint-plugin-react-hooks": "^7.0.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.23",
|
||||
"glob": "^13.0.0",
|
||||
"rollup": "^4.54.0"
|
||||
"rollup": "^4.54.0",
|
||||
"typescript": "^5.9.3"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import type { FC } from "react";
|
||||
import type { BasicLeftTreeProps } from "../../Basic";
|
||||
import type { DepartmentSelectTreeProps } from "../../../SelectTree/Department/Gwj";
|
||||
import type { BasicLeftTreeProps } from "../../Basic";
|
||||
|
||||
/**
|
||||
* 组件属性
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import billboardImage from './h.png';
|
||||
import billboardImage from "./h.png";
|
||||
|
||||
export default class CesiumMap {
|
||||
viewer;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ function Page(props) {
|
|||
contentPadding = "20px",
|
||||
customActionButtons,
|
||||
extraActionButtons,
|
||||
children
|
||||
children,
|
||||
} = props;
|
||||
|
||||
const [pageWidth, setPageWidth] = useState(window.innerWidth);
|
||||
|
|
|
|||
|
|
@ -35,11 +35,11 @@ function PersonnelSelect(props) {
|
|||
}
|
||||
|
||||
// 根据参数决定是否发送请求
|
||||
if (isNeedCorpInfoId && (!params.corpinfoId || typeof params.corpinfoId !== 'string'))
|
||||
if (isNeedCorpInfoId && (!params.corpinfoId || typeof params.corpinfoId !== "string"))
|
||||
return;
|
||||
if (isNeedDepartmentId && (!params.departmentId || typeof params.departmentId !== 'string'))
|
||||
if (isNeedDepartmentId && (!params.departmentId || typeof params.departmentId !== "string"))
|
||||
return;
|
||||
if (isNeedPostId && (!params.postId || typeof params.postId !== 'string'))
|
||||
if (isNeedPostId && (!params.postId || typeof params.postId !== "string"))
|
||||
return;
|
||||
|
||||
const actualExtraParams = { ...defaultExtraParams, ...extraParams };
|
||||
|
|
|
|||
|
|
@ -52,8 +52,8 @@ function Signature(props) {
|
|||
</Button>
|
||||
</div>
|
||||
{base64 && (
|
||||
<div style={{ border: "1px dashed #d9d9d9", width: '100%', height, marginTop: 16 }}>
|
||||
<Image src={base64} style={{ width: '100%', height, objectFit: "contain" }} />
|
||||
<div style={{ border: "1px dashed #d9d9d9", width: "100%", height, marginTop: 16 }}>
|
||||
<Image src={base64} style={{ width: "100%", height, objectFit: "contain" }} />
|
||||
</div>
|
||||
)}
|
||||
<Modal
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ export default function useImportFile(returnType = "object") {
|
|||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
const { files = [], params = {} } = options;
|
||||
const formData = new FormData();
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ function getService(service, getExtraParams = {}, transform, usePermission) {
|
|||
pageSize,
|
||||
...transformedFormData,
|
||||
...extraParams,
|
||||
}
|
||||
};
|
||||
|
||||
if (usePermission)
|
||||
params.menuPath = window.location.pathname;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { ID_NUMBER } from "../regular";
|
||||
import dayjs from "dayjs";
|
||||
import { ID_NUMBER } from "../regular";
|
||||
|
||||
/**
|
||||
* 计算序号
|
||||
|
|
@ -20,10 +20,7 @@ export function toArrayString(value) {
|
|||
* 判断文件后缀名是否符合
|
||||
*/
|
||||
export function interceptTheSuffix(name, suffix) {
|
||||
return (
|
||||
name.substring(name.lastIndexOf("."), name.length).toLowerCase()
|
||||
=== suffix.toLowerCase()
|
||||
);
|
||||
return name.substring(name.lastIndexOf("."), name.length).toLowerCase() === suffix.toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -54,10 +51,10 @@ export function image2Base642(file) {
|
|||
const reader = new FileReader();
|
||||
reader.readAsDataURL(file);
|
||||
reader.onload = (e) => {
|
||||
resolve(e.target.result); // 返回 base64
|
||||
resolve(e.target.result);
|
||||
};
|
||||
reader.onerror = (error) => {
|
||||
reject(error); // 处理错误
|
||||
reject(error);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
@ -65,10 +62,10 @@ export function image2Base642(file) {
|
|||
/**
|
||||
base64转File对象
|
||||
*/
|
||||
export function base642File(base64, filename = 'file') {
|
||||
export function base642File(base64, filename = "file") {
|
||||
const arr = base64.split(",");
|
||||
const mime = arr[0].match(/:(.*?);/)[1];
|
||||
const ext = mime.split('/')[1];
|
||||
const ext = mime.split("/")[1];
|
||||
const bstr = atob(arr[1]);
|
||||
let n = bstr.length;
|
||||
const u8arr = new Uint8Array(n);
|
||||
|
|
@ -157,18 +154,15 @@ export function numFormat(num) {
|
|||
const arr = numArr[0].split("").reverse();
|
||||
let res = [];
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
if (i % 3 === 0 && i !== 0) {
|
||||
if (i % 3 === 0 && i !== 0)
|
||||
res.push(",");
|
||||
}
|
||||
res.push(arr[i]);
|
||||
}
|
||||
res.reverse();
|
||||
if (numArr[1]) {
|
||||
if (numArr[1])
|
||||
res = res.join("").concat(`.${numArr[1]}`);
|
||||
}
|
||||
else {
|
||||
else
|
||||
res = res.join("");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
@ -201,12 +195,7 @@ export function getUrlParam(key) {
|
|||
*/
|
||||
export function paging(options) {
|
||||
const { list, currentPage, pageSize } = options;
|
||||
return list.filter((item, index) => {
|
||||
return (
|
||||
index < +currentPage * +pageSize
|
||||
&& index >= (+currentPage - 1) * +pageSize
|
||||
);
|
||||
});
|
||||
return list.filter((item, index) => index < +currentPage * +pageSize && index >= (+currentPage - 1) * +pageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -252,21 +241,19 @@ export function readTxtDocument(filePah) {
|
|||
export function secondConversion(second) {
|
||||
if (!second)
|
||||
return 0;
|
||||
const h = Number.parseInt(second / 60 / 60, 10);
|
||||
const m = Number.parseInt((second / 60) % 60, 10);
|
||||
const s = Number.parseInt(second % 60, 10);
|
||||
const h = Number.parseInt((second / 60 / 60).toString(), 10);
|
||||
const m = Number.parseInt(((second / 60) % 60).toString(), 10);
|
||||
const s = Number.parseInt((second % 60).toString(), 10);
|
||||
if (h) {
|
||||
return `${h}小时${m}分钟${s}秒`;
|
||||
}
|
||||
else {
|
||||
if (m) {
|
||||
if (m)
|
||||
return `${m}分钟${s}秒`;
|
||||
}
|
||||
else {
|
||||
else
|
||||
return `${s}秒`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 附件添加前缀
|
||||
|
|
@ -274,11 +261,7 @@ export function secondConversion(second) {
|
|||
export function addingPrefixToFile(list, options = {}) {
|
||||
if (!list)
|
||||
return [];
|
||||
const {
|
||||
pathKey = "filePath",
|
||||
nameKey = "fileName",
|
||||
idKey = "id",
|
||||
} = options;
|
||||
const { pathKey = "filePath", nameKey = "fileName", idKey = "id" } = options;
|
||||
const FILE_URL = getFileUrl();
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
list[i].url = FILE_URL + list[i][pathKey];
|
||||
|
|
@ -294,20 +277,16 @@ export function addingPrefixToFile(list, options = {}) {
|
|||
export function getLabelName(options) {
|
||||
const { status, list, idKey = "bianma", nameKey = "name" } = options;
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
if (status?.toString() === list[i][idKey]?.toString()) {
|
||||
if (status?.toString() === list[i][idKey]?.toString())
|
||||
return list[i][nameKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算文件大小
|
||||
*/
|
||||
export function calculateFileSize(size) {
|
||||
return size > 1024
|
||||
? `${(`${size / 1024}`).substring(0, (`${size / 1024}`).lastIndexOf(".") + 3)
|
||||
}MB`
|
||||
: `${size}KB`;
|
||||
return size > 1024 ? `${(`${size / 1024}`).substring(0, (`${size / 1024}`).lastIndexOf(".") + 3)}MB` : `${size}KB`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -319,12 +298,7 @@ export function idCardGetDateAndGender(idCard) {
|
|||
if (ID_NUMBER.test(idCard)) {
|
||||
const org_birthday = idCard.substring(6, 14);
|
||||
const org_gender = idCard.substring(16, 17);
|
||||
const birthday
|
||||
= `${org_birthday.substring(0, 4)
|
||||
}-${
|
||||
org_birthday.substring(4, 6)
|
||||
}-${
|
||||
org_birthday.substring(6, 8)}`;
|
||||
const birthday = `${org_birthday.substring(0, 4)}-${org_birthday.substring(4, 6)}-${org_birthday.substring(6, 8)}`;
|
||||
const birthdays = new Date(birthday.replace(/-/g, "/"));
|
||||
const Month = birthdays.getMonth() + 1;
|
||||
let MonthDate;
|
||||
|
|
@ -390,11 +364,7 @@ export function listTransTree(options) {
|
|||
*/
|
||||
export function isEmptyToWhether(value, options = {}) {
|
||||
const { yesText = "是", noText = "否", yesValue = "1" } = options;
|
||||
return !isEmpty(value)
|
||||
? value.toString() === yesValue.toString()
|
||||
? yesText
|
||||
: noText
|
||||
: "";
|
||||
return !isEmpty(value) ? (value.toString() === yesValue.toString() ? yesText : noText) : "";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -448,11 +418,10 @@ export function getTreeNodePaths(options) {
|
|||
path: newPath,
|
||||
isIncludeOneself,
|
||||
});
|
||||
if (result) {
|
||||
if (result)
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
@ -508,9 +477,8 @@ export const processTreeDataForOnlyLastLevel = (options) => {
|
|||
};
|
||||
|
||||
// 递归处理子节点
|
||||
if (hasChildren) {
|
||||
if (hasChildren)
|
||||
processedItem[childrenKey] = processTreeDataForOnlyLastLevel({ data: item[childrenKey], childrenKey, onlyLastLevel });
|
||||
}
|
||||
|
||||
return processedItem;
|
||||
});
|
||||
|
|
@ -522,15 +490,13 @@ export const processTreeDataForOnlyLastLevel = (options) => {
|
|||
export const validatorEndTime = (timeStart, message = "结束时间不能早于开始时间") => {
|
||||
return {
|
||||
validator: (_, value) => {
|
||||
if (value && timeStart && value < timeStart) {
|
||||
if (value && timeStart && value < timeStart)
|
||||
return Promise.reject(message);
|
||||
}
|
||||
else {
|
||||
else
|
||||
return Promise.resolve();
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* 验证时间是否大于等于当前时间
|
||||
|
|
@ -538,15 +504,13 @@ export const validatorEndTime = (timeStart, message = "结束时间不能早于
|
|||
export const validatorTimeGTCurrentDay = (message = "需要大于当前时间") => {
|
||||
return {
|
||||
validator: (_, value) => {
|
||||
if (value && value <= dayjs().format("YYYY-MM-DD HH:mm:ss")) {
|
||||
if (value && value <= dayjs().format("YYYY-MM-DD HH:mm:ss"))
|
||||
return Promise.reject(message);
|
||||
}
|
||||
else {
|
||||
else
|
||||
return Promise.resolve();
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* 动态加载js资源
|
||||
|
|
|
|||
Loading…
Reference in New Issue