Skip to content

Commit 2bbb49f

Browse files
authored
chore: refactor father (#256)
* chore: refactor father * feat: add coverage
1 parent 9b85c5d commit 2bbb49f

29 files changed

+947
-798
lines changed

.eslintrc

-14
This file was deleted.

.eslintrc.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const base = require("@umijs/fabric/dist/eslint");
2+
3+
module.exports = {
4+
...base,
5+
rules: {
6+
...base.rules,
7+
"arrow-parens": 0,
8+
"react/no-array-index-key": 0,
9+
"react/sort-comp": 0,
10+
"react/no-access-state-in-setstate": 0,
11+
"react/no-string-refs": 0,
12+
"react/no-did-update-set-state": 0,
13+
"react/no-find-dom-node": 0,
14+
"@typescript-eslint/no-explicit-any": 1,
15+
"@typescript-eslint/no-empty-interface": 1,
16+
"@typescript-eslint/no-inferrable-types": 0,
17+
"react/require-default-props": 0,
18+
"no-confusing-arrow": 0,
19+
"no-restricted-globals": 0,
20+
"import/no-named-as-default-member": 0,
21+
"import/no-extraneous-dependencies": 0,
22+
"jsx-a11y/label-has-for": 0,
23+
"jsx-a11y/label-has-associated-control": 0,
24+
"jsx-a11y/no-autofocus": 0
25+
},
26+
};

.fatherrc.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default {
2+
cjs: "babel",
3+
esm: { type: "babel", importLibToEs: true },
4+
preCommit: {
5+
eslint: true,
6+
prettier: true,
7+
},
8+
};

.gitignore

100644100755
+5-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
.storybook
12
*.iml
23
*.log
3-
*.log.*
4-
.idea/
4+
.idea
55
.ipr
66
.iws
77
*~
@@ -13,21 +13,18 @@
1313
Thumbs.db
1414
.project
1515
.*proj
16-
.svn/
16+
.svn
1717
*.swp
1818
*.swo
1919
*.pyc
2020
*.pyo
21-
.build
2221
node_modules
2322
.cache
24-
dist
25-
assets/**/*.css
23+
*.css
2624
build
2725
lib
2826
es
2927
coverage
30-
/ios/
31-
/android/
3228
yarn.lock
3329
package-lock.json
30+
.doc/

.prettierrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"proseWrap": "never",
5+
"printWidth": 100
6+
}

.travis.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ notifications:
88
99

1010
node_js:
11-
- 6
11+
- 10
1212

1313
before_install:
1414
- |
@@ -22,7 +22,8 @@ before_install:
2222
script:
2323
- |
2424
if [ "$TEST_TYPE" = test ]; then
25-
npm test
25+
npm run test -- --coverage && \
26+
bash <(curl -s https://codecov.io/bash)
2627
else
2728
npm run $TEST_TYPE
2829
fi

examples/combination-key-format.html

-1
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,47 @@
11
/* eslint no-console:0 */
2-
import 'rc-input-number/assets/index.less';
3-
import InputNumber from 'rc-input-number';
42
import React from 'react';
5-
import ReactDOM from 'react-dom';
3+
import InputNumber from '../src';
4+
import '../assets/index.less';
65

76
class Component extends React.Component {
87
state = {
98
disabled: false,
109
readOnly: false,
1110
value: 50000,
1211
};
13-
onChange = (value) => {
12+
13+
onChange = value => {
1414
console.log('onChange:', value);
1515
this.setState({ value });
16-
}
16+
};
17+
1718
toggleDisabled = () => {
1819
this.setState({
1920
disabled: !this.state.disabled,
2021
});
21-
}
22+
};
23+
2224
toggleReadOnly = () => {
2325
this.setState({
2426
readOnly: !this.state.readOnly,
2527
});
26-
}
27-
numberWithCommas = (x) => {
28+
};
29+
30+
numberWithCommas = x => {
2831
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
29-
}
30-
format = (num) => {
32+
};
33+
34+
format = num => {
3135
return `$ ${this.numberWithCommas(num)} boeing737`;
32-
}
33-
parser(num) {
34-
return num.toString().split(' ')[1].replace(/,*/g, '');
35-
}
36+
};
37+
38+
parser = num => {
39+
return num
40+
.toString()
41+
.split(' ')[1]
42+
.replace(/,*/g, '');
43+
};
44+
3645
render() {
3746
return (
3847
<div style={{ margin: 10 }}>
@@ -51,12 +60,16 @@ class Component extends React.Component {
5160
parser={this.parser}
5261
/>
5362
<p>
54-
<button onClick={this.toggleDisabled}>toggle Disabled</button>
55-
<button onClick={this.toggleReadOnly}>toggle readOnly</button>
63+
<button type="button" onClick={this.toggleDisabled}>
64+
toggle Disabled
65+
</button>
66+
<button type="button" onClick={this.toggleReadOnly}>
67+
toggle readOnly
68+
</button>
5669
</p>
5770
</div>
5871
);
5972
}
6073
}
6174

62-
ReactDOM.render(<Component/>, document.getElementById('__react-content'));
75+
export default Component;

examples/custom.html

-1
This file was deleted.

examples/custom.js examples/custom.tsx

+13-10
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,35 @@
11
/* eslint no-console:0 */
2-
import 'rc-input-number/assets/index.less';
3-
import InputNumber from 'rc-input-number';
42
import React from 'react';
5-
import ReactDOM from 'react-dom';
3+
import InputNumber from '../src';
4+
import '../assets/index.less';
65

76
class Component extends React.Component {
87
state = {
98
disabled: false,
109
readOnly: false,
1110
value: 5,
1211
};
13-
onChange = (value) => {
12+
13+
onChange = value => {
1414
console.log('onChange:', value);
1515
this.setState({ value });
16-
}
16+
};
17+
1718
toggleDisabled = () => {
1819
this.setState({
1920
disabled: !this.state.disabled,
2021
});
21-
}
22+
};
23+
2224
toggleReadOnly = () => {
2325
this.setState({
2426
readOnly: !this.state.readOnly,
2527
});
26-
}
28+
};
29+
2730
render() {
28-
const upHandler = (<div style={{ color: 'blue' }}>x</div>);
29-
const downHandler = (<div style={{ color: 'red' }}>V</div>);
31+
const upHandler = <div style={{ color: 'blue' }}>x</div>;
32+
const downHandler = <div style={{ color: 'red' }}>V</div>;
3033
return (
3134
<div style={{ margin: 10 }}>
3235
<InputNumber
@@ -46,4 +49,4 @@ class Component extends React.Component {
4649
}
4750
}
4851

49-
ReactDOM.render(<Component/>, document.getElementById('__react-content'));
52+
export default Component;

examples/decimal.html

-1
This file was deleted.

examples/decimal.js examples/decimal.tsx

+17-12
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,34 @@
11
/* eslint no-console:0 */
2-
import 'rc-input-number/assets/index.less';
3-
import InputNumber from 'rc-input-number';
42
import React from 'react';
5-
import ReactDOM from 'react-dom';
3+
import InputNumber from '../src';
4+
import '../assets/index.less';
65

7-
class Demo extends React.Component {
6+
export default class Demo extends React.Component {
87
state = {
98
disabled: false,
109
readOnly: false,
1110
value: 8,
1211
};
13-
onChange = (v) => {
12+
13+
onChange = v => {
1414
console.log('onChange:', v);
1515
this.setState({
1616
value: v,
1717
});
18-
}
18+
};
19+
1920
toggleDisabled = () => {
2021
this.setState({
2122
disabled: !this.state.disabled,
2223
});
23-
}
24+
};
25+
2426
toggleReadOnly = () => {
2527
this.setState({
2628
readOnly: !this.state.readOnly,
2729
});
28-
}
30+
};
31+
2932
render() {
3033
return (
3134
<div style={{ margin: 10 }}>
@@ -41,12 +44,14 @@ class Demo extends React.Component {
4144
disabled={this.state.disabled}
4245
/>
4346
<p>
44-
<button onClick={this.toggleDisabled}>toggle Disabled</button>
45-
<button onClick={this.toggleReadOnly}>toggle readOnly</button>
47+
<button type="button" onClick={this.toggleDisabled}>
48+
toggle Disabled
49+
</button>
50+
<button type="button" onClick={this.toggleReadOnly}>
51+
toggle readOnly
52+
</button>
4653
</p>
4754
</div>
4855
);
4956
}
5057
}
51-
52-
ReactDOM.render(<Demo/>, document.getElementById('__react-content'));

examples/formatter.html

Whitespace-only changes.

examples/formatter.js examples/formatter.tsx

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
/* eslint no-console:0 */
2-
import 'rc-input-number/assets/index.less';
3-
import InputNumber from 'rc-input-number';
42
import React from 'react';
5-
import ReactDOM from 'react-dom';
3+
import InputNumber from '../src';
4+
import '../assets/index.less';
65

76
function getSum(str) {
87
let total = 0;
9-
str.split('').forEach((c) => {
8+
str.split('').forEach(c => {
109
const num = Number(c);
1110

12-
if (!isNaN(num)) {
11+
if (!Number.isNaN(num)) {
1312
total += num;
1413
}
1514
});
@@ -39,17 +38,17 @@ class App extends React.Component {
3938
<InputNumber
4039
aria-label="Controlled number input demonstrating a custom format to add commas"
4140
style={{ width: 100 }}
42-
formatter={value =>
43-
`${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
44-
}
41+
formatter={value => `${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')}
4542
/>
4643

4744
<div>
4845
<h1>In Control</h1>
4946
<InputNumber
5047
aria-label="Controlled number input demonstrating a custom format"
5148
value={this.state.value}
52-
onChange={(value) => { this.setState({ value }); }}
49+
onChange={value => {
50+
this.setState({ value });
51+
}}
5352
formatter={value => `$ ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')}
5453
/>
5554
</div>
@@ -68,4 +67,4 @@ class App extends React.Component {
6867
}
6968
}
7069

71-
ReactDOM.render(<App />, document.getElementById('__react-content'));
70+
export default App;

examples/precision.html

Whitespace-only changes.

0 commit comments

Comments
 (0)