Skip to content

Commit 1f6a4eb

Browse files
committed
test
1 parent 7d88240 commit 1f6a4eb

File tree

4 files changed

+136
-477
lines changed

4 files changed

+136
-477
lines changed

package.json

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
"dotenv": "6.2.0",
2222
"dotenv-expand": "4.2.0",
2323
"echarts": "^4.3.0",
24-
"eslint": "^6.6.0",
24+
"eslint": "^6.7.0",
2525
"eslint-config-airbnb": "^18.0.1",
2626
"eslint-config-react-app": "^5.0.0",
2727
"eslint-loader": "2.2.1",
2828
"eslint-plugin-flowtype": "3.13.0",
29-
"eslint-plugin-import": "2.18.2",
29+
"eslint-plugin-import": "^2.18.2",
3030
"eslint-plugin-jsx-a11y": "6.2.3",
3131
"eslint-plugin-react": "7.14.3",
3232
"eslint-plugin-react-hooks": "^1.6.1",
@@ -58,7 +58,6 @@
5858
"react-transition-group": "^4.3.0",
5959
"redux": "^4.0.4",
6060
"redux-logger": "^3.0.6",
61-
"redux-thunk": "^2.3.0",
6261
"reqwest": "^2.0.5",
6362
"resolve": "1.12.0",
6463
"resolve-url-loader": "3.1.0",
@@ -76,24 +75,14 @@
7675
},
7776
"husky": {
7877
"hooks": {
79-
"pre-commit": "lint-staged"
78+
"pre-commit": "npm run lint && pretty-quick --staged"
8079
}
8180
},
82-
"lint-staged": {
83-
"src/*.{js,jsx,mjs,ts,tsx}": [
84-
"node_modules/.bin/prettier --write",
85-
"node_modules/.bin/eslint --fix",
86-
"git add"
87-
],
88-
"src/*.{css,scss,less,json,html,md,markdown}": [
89-
"node_modules/.bin/prettier --write",
90-
"git add"
91-
]
92-
},
9381
"scripts": {
9482
"start": "node scripts/start.js",
9583
"build": "node scripts/build.js",
96-
"test": "node scripts/test.js"
84+
"test": "node scripts/test.js",
85+
"lint": "eslint src"
9786
},
9887
"eslintConfig": {
9988
"extends": "react-app"
@@ -164,13 +153,17 @@
164153
]
165154
},
166155
"devDependencies": {
156+
"babel-plugin-import": "^1.11.0",
157+
"eslint": "5.12.0",
158+
"eslint-config-airbnb": "^17.1.0",
167159
"eslint-config-prettier": "^6.7.0",
160+
"eslint-plugin-import": "^2.16.0",
161+
"eslint-plugin-jsx-a11y": "^6.2.1",
168162
"eslint-plugin-prettier": "^3.1.1",
163+
"eslint-plugin-react": "^7.12.4",
169164
"husky": "^3.1.0",
170-
"lint-staged": "^9.4.3",
171-
"prettier": "^1.19.1",
172-
"react-router-dom": "^5.0.1",
173-
"react-transition-group": "^4.3.0"
165+
"prettier": "1.19.1",
166+
"pretty-quick": "^2.0.1"
174167
},
175168
"proxy": "http://193.112.220.108:8080"
176169
}

src/page/module/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
2-
import React from 'react';
1+
import React from "react";
32

43
class Page extends React.Component {
54
constructor(props) {
65
super(props);
7-
this.state = {
8-
}
6+
this.state = {};
97
}
8+
109
render() {
11-
return;
10+
return 111;
1211
}
1312
}
1413

src/utils/validate.js

Lines changed: 52 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,3 @@
1-
/**
2-
* 校验函数
3-
*/
4-
const fns = {
5-
date: validateDate, // 日期
6-
salary: validateSalary, // 薪水
7-
workingTime: validateWorkingTime, // 工时
8-
remark: validateRemark, // 备注
9-
receive: validateReceive, // 实收金额
10-
borrow: validateBorrow, // 借款
11-
userName: validateUserName, // 人名
12-
workType: validateWorkType, // 工种
13-
phone: validatePhone, // 手机号码
14-
phoneCode: validatePhoneCode, // 短信验证码
15-
userAvt: validateUserAvt, // 用户头像
16-
workerCode: validateWorkerCode, // 工号
17-
bankCardNumber: validateBankCardNumber, // 银行卡号
18-
realNamePics: validateRealNamePics, // 实名图片
19-
groupName: validateGroupName, // 校验考勤组名
20-
teamName: validateTeamName, // 校验考勤组名
21-
projectName: validateProjectName, // 项目名
22-
companyName: validateCompanyName, // 校验公司名
23-
address: validateAddress, // 校验地址
24-
idCard: validateIdCard // 校验身份证
25-
};
26-
27-
/**
28-
* 检验
29-
*/
30-
function validate(options) {
31-
const keys = Object.keys(options);
32-
33-
for (let i = 0; i < keys.length; i += 1) {
34-
const key = keys[i];
35-
const val = options[key];
36-
const fn = fns[key];
37-
38-
if (fn) {
39-
const res = val && val.label ? fn(val.value, val.label) : fn(val);
40-
41-
if (res.msg) {
42-
return res;
43-
}
44-
} else {
45-
return {
46-
msg: `找不到校验函数:${key}`
47-
};
48-
}
49-
}
50-
51-
return true;
52-
}
53-
541
/**
552
* 校验浮点数
563
*/
@@ -480,6 +427,58 @@ function validateIdCard(val, label = "身份证号") {
480427

481428
return true;
482429
}
430+
/**
431+
* 校验函数
432+
*/
433+
const fns = {
434+
date: validateDate, // 日期
435+
salary: validateSalary, // 薪水
436+
workingTime: validateWorkingTime, // 工时
437+
remark: validateRemark, // 备注
438+
receive: validateReceive, // 实收金额
439+
borrow: validateBorrow, // 借款
440+
userName: validateUserName, // 人名
441+
workType: validateWorkType, // 工种
442+
phone: validatePhone, // 手机号码
443+
phoneCode: validatePhoneCode, // 短信验证码
444+
userAvt: validateUserAvt, // 用户头像
445+
workerCode: validateWorkerCode, // 工号
446+
bankCardNumber: validateBankCardNumber, // 银行卡号
447+
realNamePics: validateRealNamePics, // 实名图片
448+
groupName: validateGroupName, // 校验考勤组名
449+
teamName: validateTeamName, // 校验考勤组名
450+
projectName: validateProjectName, // 项目名
451+
companyName: validateCompanyName, // 校验公司名
452+
address: validateAddress, // 校验地址
453+
idCard: validateIdCard // 校验身份证
454+
};
455+
456+
/**
457+
* 检验
458+
*/
459+
function validate(options) {
460+
const keys = Object.keys(options);
461+
462+
for (let i = 0; i < keys.length; i += 1) {
463+
const key = keys[i];
464+
const val = options[key];
465+
const fn = fns[key];
466+
467+
if (fn) {
468+
const res = val && val.label ? fn(val.value, val.label) : fn(val);
469+
470+
if (res.msg) {
471+
return res;
472+
}
473+
} else {
474+
return {
475+
msg: `找不到校验函数:${key}`
476+
};
477+
}
478+
}
479+
480+
return true;
481+
}
483482

484483
module.exports = {
485484
validate

0 commit comments

Comments
 (0)