增加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"
|
"use-antd-resizable-header": "^3.2.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@antfu/eslint-config": "^5.4.1",
|
||||||
"@babel/core": "^7.28.5",
|
"@babel/core": "^7.28.5",
|
||||||
"@babel/preset-react": "^7.28.5",
|
"@babel/preset-react": "^7.28.5",
|
||||||
|
"@eslint-react/eslint-plugin": "^2.2.2",
|
||||||
"@rollup/plugin-babel": "^6.1.0",
|
"@rollup/plugin-babel": "^6.1.0",
|
||||||
"@rollup/plugin-commonjs": "^29.0.0",
|
"@rollup/plugin-commonjs": "^29.0.0",
|
||||||
"@rollup/plugin-image": "^3.0.3",
|
"@rollup/plugin-image": "^3.0.3",
|
||||||
"@rollup/plugin-json": "^6.1.0",
|
"@rollup/plugin-json": "^6.1.0",
|
||||||
"@rollup/plugin-node-resolve": "^16.0.3",
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
||||||
"@rollup/plugin-terser": "^0.4.4",
|
"@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",
|
"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 { FC } from "react";
|
||||||
import type { BasicLeftTreeProps } from "../../Basic";
|
|
||||||
import type { DepartmentSelectTreeProps } from "../../../SelectTree/Department/Gwj";
|
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 {
|
export default class CesiumMap {
|
||||||
viewer;
|
viewer;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ function Page(props) {
|
||||||
contentPadding = "20px",
|
contentPadding = "20px",
|
||||||
customActionButtons,
|
customActionButtons,
|
||||||
extraActionButtons,
|
extraActionButtons,
|
||||||
children
|
children,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const [pageWidth, setPageWidth] = useState(window.innerWidth);
|
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;
|
return;
|
||||||
if (isNeedDepartmentId && (!params.departmentId || typeof params.departmentId !== 'string'))
|
if (isNeedDepartmentId && (!params.departmentId || typeof params.departmentId !== "string"))
|
||||||
return;
|
return;
|
||||||
if (isNeedPostId && (!params.postId || typeof params.postId !== 'string'))
|
if (isNeedPostId && (!params.postId || typeof params.postId !== "string"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const actualExtraParams = { ...defaultExtraParams, ...extraParams };
|
const actualExtraParams = { ...defaultExtraParams, ...extraParams };
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,8 @@ function Signature(props) {
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{base64 && (
|
{base64 && (
|
||||||
<div style={{ border: "1px dashed #d9d9d9", width: '100%', height, marginTop: 16 }}>
|
<div style={{ border: "1px dashed #d9d9d9", width: "100%", height, marginTop: 16 }}>
|
||||||
<Image src={base64} style={{ width: '100%', height, objectFit: "contain" }} />
|
<Image src={base64} style={{ width: "100%", height, objectFit: "contain" }} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<Modal
|
<Modal
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ const AliPlayer = forwardRef(({
|
||||||
await window.base.loadDynamicResource({
|
await window.base.loadDynamicResource({
|
||||||
url: "https://g.alicdn.com/apsara-media-box/imp-web-player/2.16.3/skins/default/aliplayer-min.css",
|
url: "https://g.alicdn.com/apsara-media-box/imp-web-player/2.16.3/skins/default/aliplayer-min.css",
|
||||||
type: "link",
|
type: "link",
|
||||||
attr: { rel: "stylesheet" , type: "text/css" },
|
attr: { rel: "stylesheet", type: "text/css" },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ export default function useImportFile(returnType = "object") {
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
||||||
const { files = [], params = {} } = options;
|
const { files = [], params = {} } = options;
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ function getService(service, getExtraParams = {}, transform, usePermission) {
|
||||||
pageSize,
|
pageSize,
|
||||||
...transformedFormData,
|
...transformedFormData,
|
||||||
...extraParams,
|
...extraParams,
|
||||||
}
|
};
|
||||||
|
|
||||||
if (usePermission)
|
if (usePermission)
|
||||||
params.menuPath = window.location.pathname;
|
params.menuPath = window.location.pathname;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { ID_NUMBER } from "../regular";
|
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
|
import { ID_NUMBER } from "../regular";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算序号
|
* 计算序号
|
||||||
|
|
@ -20,10 +20,7 @@ export function toArrayString(value) {
|
||||||
* 判断文件后缀名是否符合
|
* 判断文件后缀名是否符合
|
||||||
*/
|
*/
|
||||||
export function interceptTheSuffix(name, suffix) {
|
export function interceptTheSuffix(name, suffix) {
|
||||||
return (
|
return name.substring(name.lastIndexOf("."), name.length).toLowerCase() === suffix.toLowerCase();
|
||||||
name.substring(name.lastIndexOf("."), name.length).toLowerCase()
|
|
||||||
=== suffix.toLowerCase()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -54,10 +51,10 @@ export function image2Base642(file) {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.readAsDataURL(file);
|
reader.readAsDataURL(file);
|
||||||
reader.onload = (e) => {
|
reader.onload = (e) => {
|
||||||
resolve(e.target.result); // 返回 base64
|
resolve(e.target.result);
|
||||||
};
|
};
|
||||||
reader.onerror = (error) => {
|
reader.onerror = (error) => {
|
||||||
reject(error); // 处理错误
|
reject(error);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -65,10 +62,10 @@ export function image2Base642(file) {
|
||||||
/**
|
/**
|
||||||
base64转File对象
|
base64转File对象
|
||||||
*/
|
*/
|
||||||
export function base642File(base64, filename = 'file') {
|
export function base642File(base64, filename = "file") {
|
||||||
const arr = base64.split(",");
|
const arr = base64.split(",");
|
||||||
const mime = arr[0].match(/:(.*?);/)[1];
|
const mime = arr[0].match(/:(.*?);/)[1];
|
||||||
const ext = mime.split('/')[1];
|
const ext = mime.split("/")[1];
|
||||||
const bstr = atob(arr[1]);
|
const bstr = atob(arr[1]);
|
||||||
let n = bstr.length;
|
let n = bstr.length;
|
||||||
const u8arr = new Uint8Array(n);
|
const u8arr = new Uint8Array(n);
|
||||||
|
|
@ -157,18 +154,15 @@ export function numFormat(num) {
|
||||||
const arr = numArr[0].split("").reverse();
|
const arr = numArr[0].split("").reverse();
|
||||||
let res = [];
|
let res = [];
|
||||||
for (let i = 0; i < arr.length; i++) {
|
for (let i = 0; i < arr.length; i++) {
|
||||||
if (i % 3 === 0 && i !== 0) {
|
if (i % 3 === 0 && i !== 0)
|
||||||
res.push(",");
|
res.push(",");
|
||||||
}
|
|
||||||
res.push(arr[i]);
|
res.push(arr[i]);
|
||||||
}
|
}
|
||||||
res.reverse();
|
res.reverse();
|
||||||
if (numArr[1]) {
|
if (numArr[1])
|
||||||
res = res.join("").concat(`.${numArr[1]}`);
|
res = res.join("").concat(`.${numArr[1]}`);
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
res = res.join("");
|
res = res.join("");
|
||||||
}
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -201,12 +195,7 @@ export function getUrlParam(key) {
|
||||||
*/
|
*/
|
||||||
export function paging(options) {
|
export function paging(options) {
|
||||||
const { list, currentPage, pageSize } = options;
|
const { list, currentPage, pageSize } = options;
|
||||||
return list.filter((item, index) => {
|
return list.filter((item, index) => index < +currentPage * +pageSize && index >= (+currentPage - 1) * +pageSize);
|
||||||
return (
|
|
||||||
index < +currentPage * +pageSize
|
|
||||||
&& index >= (+currentPage - 1) * +pageSize
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -252,20 +241,18 @@ export function readTxtDocument(filePah) {
|
||||||
export function secondConversion(second) {
|
export function secondConversion(second) {
|
||||||
if (!second)
|
if (!second)
|
||||||
return 0;
|
return 0;
|
||||||
const h = Number.parseInt(second / 60 / 60, 10);
|
const h = Number.parseInt((second / 60 / 60).toString(), 10);
|
||||||
const m = Number.parseInt((second / 60) % 60, 10);
|
const m = Number.parseInt(((second / 60) % 60).toString(), 10);
|
||||||
const s = Number.parseInt(second % 60, 10);
|
const s = Number.parseInt((second % 60).toString(), 10);
|
||||||
if (h) {
|
if (h) {
|
||||||
return `${h}小时${m}分钟${s}秒`;
|
return `${h}小时${m}分钟${s}秒`;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (m) {
|
if (m)
|
||||||
return `${m}分钟${s}秒`;
|
return `${m}分钟${s}秒`;
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
return `${s}秒`;
|
return `${s}秒`;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -274,11 +261,7 @@ export function secondConversion(second) {
|
||||||
export function addingPrefixToFile(list, options = {}) {
|
export function addingPrefixToFile(list, options = {}) {
|
||||||
if (!list)
|
if (!list)
|
||||||
return [];
|
return [];
|
||||||
const {
|
const { pathKey = "filePath", nameKey = "fileName", idKey = "id" } = options;
|
||||||
pathKey = "filePath",
|
|
||||||
nameKey = "fileName",
|
|
||||||
idKey = "id",
|
|
||||||
} = options;
|
|
||||||
const FILE_URL = getFileUrl();
|
const FILE_URL = getFileUrl();
|
||||||
for (let i = 0; i < list.length; i++) {
|
for (let i = 0; i < list.length; i++) {
|
||||||
list[i].url = FILE_URL + list[i][pathKey];
|
list[i].url = FILE_URL + list[i][pathKey];
|
||||||
|
|
@ -294,20 +277,16 @@ export function addingPrefixToFile(list, options = {}) {
|
||||||
export function getLabelName(options) {
|
export function getLabelName(options) {
|
||||||
const { status, list, idKey = "bianma", nameKey = "name" } = options;
|
const { status, list, idKey = "bianma", nameKey = "name" } = options;
|
||||||
for (let i = 0; i < list.length; i++) {
|
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];
|
return list[i][nameKey];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算文件大小
|
* 计算文件大小
|
||||||
*/
|
*/
|
||||||
export function calculateFileSize(size) {
|
export function calculateFileSize(size) {
|
||||||
return size > 1024
|
return size > 1024 ? `${(`${size / 1024}`).substring(0, (`${size / 1024}`).lastIndexOf(".") + 3)}MB` : `${size}KB`;
|
||||||
? `${(`${size / 1024}`).substring(0, (`${size / 1024}`).lastIndexOf(".") + 3)
|
|
||||||
}MB`
|
|
||||||
: `${size}KB`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -319,12 +298,7 @@ export function idCardGetDateAndGender(idCard) {
|
||||||
if (ID_NUMBER.test(idCard)) {
|
if (ID_NUMBER.test(idCard)) {
|
||||||
const org_birthday = idCard.substring(6, 14);
|
const org_birthday = idCard.substring(6, 14);
|
||||||
const org_gender = idCard.substring(16, 17);
|
const org_gender = idCard.substring(16, 17);
|
||||||
const birthday
|
const birthday = `${org_birthday.substring(0, 4)}-${org_birthday.substring(4, 6)}-${org_birthday.substring(6, 8)}`;
|
||||||
= `${org_birthday.substring(0, 4)
|
|
||||||
}-${
|
|
||||||
org_birthday.substring(4, 6)
|
|
||||||
}-${
|
|
||||||
org_birthday.substring(6, 8)}`;
|
|
||||||
const birthdays = new Date(birthday.replace(/-/g, "/"));
|
const birthdays = new Date(birthday.replace(/-/g, "/"));
|
||||||
const Month = birthdays.getMonth() + 1;
|
const Month = birthdays.getMonth() + 1;
|
||||||
let MonthDate;
|
let MonthDate;
|
||||||
|
|
@ -390,11 +364,7 @@ export function listTransTree(options) {
|
||||||
*/
|
*/
|
||||||
export function isEmptyToWhether(value, options = {}) {
|
export function isEmptyToWhether(value, options = {}) {
|
||||||
const { yesText = "是", noText = "否", yesValue = "1" } = options;
|
const { yesText = "是", noText = "否", yesValue = "1" } = options;
|
||||||
return !isEmpty(value)
|
return !isEmpty(value) ? (value.toString() === yesValue.toString() ? yesText : noText) : "";
|
||||||
? value.toString() === yesValue.toString()
|
|
||||||
? yesText
|
|
||||||
: noText
|
|
||||||
: "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -448,11 +418,10 @@ export function getTreeNodePaths(options) {
|
||||||
path: newPath,
|
path: newPath,
|
||||||
isIncludeOneself,
|
isIncludeOneself,
|
||||||
});
|
});
|
||||||
if (result) {
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -508,9 +477,8 @@ export const processTreeDataForOnlyLastLevel = (options) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
// 递归处理子节点
|
// 递归处理子节点
|
||||||
if (hasChildren) {
|
if (hasChildren)
|
||||||
processedItem[childrenKey] = processTreeDataForOnlyLastLevel({ data: item[childrenKey], childrenKey, onlyLastLevel });
|
processedItem[childrenKey] = processTreeDataForOnlyLastLevel({ data: item[childrenKey], childrenKey, onlyLastLevel });
|
||||||
}
|
|
||||||
|
|
||||||
return processedItem;
|
return processedItem;
|
||||||
});
|
});
|
||||||
|
|
@ -522,15 +490,13 @@ export const processTreeDataForOnlyLastLevel = (options) => {
|
||||||
export const validatorEndTime = (timeStart, message = "结束时间不能早于开始时间") => {
|
export const validatorEndTime = (timeStart, message = "结束时间不能早于开始时间") => {
|
||||||
return {
|
return {
|
||||||
validator: (_, value) => {
|
validator: (_, value) => {
|
||||||
if (value && timeStart && value < timeStart) {
|
if (value && timeStart && value < timeStart)
|
||||||
return Promise.reject(message);
|
return Promise.reject(message);
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证时间是否大于等于当前时间
|
* 验证时间是否大于等于当前时间
|
||||||
|
|
@ -538,15 +504,13 @@ export const validatorEndTime = (timeStart, message = "结束时间不能早于
|
||||||
export const validatorTimeGTCurrentDay = (message = "需要大于当前时间") => {
|
export const validatorTimeGTCurrentDay = (message = "需要大于当前时间") => {
|
||||||
return {
|
return {
|
||||||
validator: (_, value) => {
|
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);
|
return Promise.reject(message);
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 动态加载js资源
|
* 动态加载js资源
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue