Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: refactor father #256

Merged
merged 2 commits into from Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 0 additions & 14 deletions .eslintrc

This file was deleted.

26 changes: 26 additions & 0 deletions .eslintrc.js
@@ -0,0 +1,26 @@
const base = require("@umijs/fabric/dist/eslint");

module.exports = {
...base,
rules: {
...base.rules,
"arrow-parens": 0,
"react/no-array-index-key": 0,
"react/sort-comp": 0,
"react/no-access-state-in-setstate": 0,
"react/no-string-refs": 0,
"react/no-did-update-set-state": 0,
"react/no-find-dom-node": 0,
"@typescript-eslint/no-explicit-any": 1,
"@typescript-eslint/no-empty-interface": 1,
"@typescript-eslint/no-inferrable-types": 0,
"react/require-default-props": 0,
"no-confusing-arrow": 0,
"no-restricted-globals": 0,
"import/no-named-as-default-member": 0,
"import/no-extraneous-dependencies": 0,
"jsx-a11y/label-has-for": 0,
"jsx-a11y/label-has-associated-control": 0,
"jsx-a11y/no-autofocus": 0
},
};
8 changes: 8 additions & 0 deletions .fatherrc.js
@@ -0,0 +1,8 @@
export default {
cjs: "babel",
esm: { type: "babel", importLibToEs: true },
preCommit: {
eslint: true,
prettier: true,
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我重新开个pr把这个补一下,好像还是没看到 CI 覆盖率出来。。。

};
13 changes: 5 additions & 8 deletions .gitignore 100644 → 100755
@@ -1,7 +1,7 @@
.storybook
*.iml
*.log
*.log.*
.idea/
.idea
.ipr
.iws
*~
Expand All @@ -13,21 +13,18 @@
Thumbs.db
.project
.*proj
.svn/
.svn
*.swp
*.swo
*.pyc
*.pyo
.build
node_modules
.cache
dist
assets/**/*.css
*.css
build
lib
es
coverage
/ios/
/android/
yarn.lock
package-lock.json
.doc/
6 changes: 6 additions & 0 deletions .prettierrc
@@ -0,0 +1,6 @@
{
"singleQuote": true,
"trailingComma": "all",
"proseWrap": "never",
"printWidth": 100
}
5 changes: 3 additions & 2 deletions .travis.yml
Expand Up @@ -8,7 +8,7 @@ notifications:
- hust2012jiangkai@gmail.com

node_js:
- 6
- 10

before_install:
- |
Expand All @@ -22,7 +22,8 @@ before_install:
script:
- |
if [ "$TEST_TYPE" = test ]; then
npm test
npm run test -- --coverage && \
bash <(curl -s https://codecov.io/bash)
else
npm run $TEST_TYPE
fi
Expand Down
1 change: 0 additions & 1 deletion examples/combination-key-format.html

This file was deleted.

@@ -1,38 +1,47 @@
/* eslint no-console:0 */
import 'rc-input-number/assets/index.less';
import InputNumber from 'rc-input-number';
import React from 'react';
import ReactDOM from 'react-dom';
import InputNumber from '../src';
import '../assets/index.less';

class Component extends React.Component {
state = {
disabled: false,
readOnly: false,
value: 50000,
};
onChange = (value) => {

onChange = value => {
console.log('onChange:', value);
this.setState({ value });
}
};

toggleDisabled = () => {
this.setState({
disabled: !this.state.disabled,
});
}
};

toggleReadOnly = () => {
this.setState({
readOnly: !this.state.readOnly,
});
}
numberWithCommas = (x) => {
};

numberWithCommas = x => {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
format = (num) => {
};

format = num => {
return `$ ${this.numberWithCommas(num)} boeing737`;
}
parser(num) {
return num.toString().split(' ')[1].replace(/,*/g, '');
}
};

parser = num => {
return num
.toString()
.split(' ')[1]
.replace(/,*/g, '');
};

render() {
return (
<div style={{ margin: 10 }}>
Expand All @@ -51,12 +60,16 @@ class Component extends React.Component {
parser={this.parser}
/>
<p>
<button onClick={this.toggleDisabled}>toggle Disabled</button>
<button onClick={this.toggleReadOnly}>toggle readOnly</button>
<button type="button" onClick={this.toggleDisabled}>
toggle Disabled
</button>
<button type="button" onClick={this.toggleReadOnly}>
toggle readOnly
</button>
</p>
</div>
);
}
}

ReactDOM.render(<Component/>, document.getElementById('__react-content'));
export default Component;
1 change: 0 additions & 1 deletion examples/custom.html

This file was deleted.

23 changes: 13 additions & 10 deletions examples/custom.js → examples/custom.tsx
@@ -1,32 +1,35 @@
/* eslint no-console:0 */
import 'rc-input-number/assets/index.less';
import InputNumber from 'rc-input-number';
import React from 'react';
import ReactDOM from 'react-dom';
import InputNumber from '../src';
import '../assets/index.less';

class Component extends React.Component {
state = {
disabled: false,
readOnly: false,
value: 5,
};
onChange = (value) => {

onChange = value => {
console.log('onChange:', value);
this.setState({ value });
}
};

toggleDisabled = () => {
this.setState({
disabled: !this.state.disabled,
});
}
};

toggleReadOnly = () => {
this.setState({
readOnly: !this.state.readOnly,
});
}
};

render() {
const upHandler = (<div style={{ color: 'blue' }}>x</div>);
const downHandler = (<div style={{ color: 'red' }}>V</div>);
const upHandler = <div style={{ color: 'blue' }}>x</div>;
const downHandler = <div style={{ color: 'red' }}>V</div>;
return (
<div style={{ margin: 10 }}>
<InputNumber
Expand All @@ -46,4 +49,4 @@ class Component extends React.Component {
}
}

ReactDOM.render(<Component/>, document.getElementById('__react-content'));
export default Component;
1 change: 0 additions & 1 deletion examples/decimal.html

This file was deleted.

29 changes: 17 additions & 12 deletions examples/decimal.js → examples/decimal.tsx
@@ -1,31 +1,34 @@
/* eslint no-console:0 */
import 'rc-input-number/assets/index.less';
import InputNumber from 'rc-input-number';
import React from 'react';
import ReactDOM from 'react-dom';
import InputNumber from '../src';
import '../assets/index.less';

class Demo extends React.Component {
export default class Demo extends React.Component {
state = {
disabled: false,
readOnly: false,
value: 8,
};
onChange = (v) => {

onChange = v => {
console.log('onChange:', v);
this.setState({
value: v,
});
}
};

toggleDisabled = () => {
this.setState({
disabled: !this.state.disabled,
});
}
};

toggleReadOnly = () => {
this.setState({
readOnly: !this.state.readOnly,
});
}
};

render() {
return (
<div style={{ margin: 10 }}>
Expand All @@ -41,12 +44,14 @@ class Demo extends React.Component {
disabled={this.state.disabled}
/>
<p>
<button onClick={this.toggleDisabled}>toggle Disabled</button>
<button onClick={this.toggleReadOnly}>toggle readOnly</button>
<button type="button" onClick={this.toggleDisabled}>
toggle Disabled
</button>
<button type="button" onClick={this.toggleReadOnly}>
toggle readOnly
</button>
</p>
</div>
);
}
}

ReactDOM.render(<Demo/>, document.getElementById('__react-content'));
Empty file removed examples/formatter.html
Empty file.
19 changes: 9 additions & 10 deletions examples/formatter.js → examples/formatter.tsx
@@ -1,15 +1,14 @@
/* eslint no-console:0 */
import 'rc-input-number/assets/index.less';
import InputNumber from 'rc-input-number';
import React from 'react';
import ReactDOM from 'react-dom';
import InputNumber from '../src';
import '../assets/index.less';

function getSum(str) {
let total = 0;
str.split('').forEach((c) => {
str.split('').forEach(c => {
const num = Number(c);

if (!isNaN(num)) {
if (!Number.isNaN(num)) {
total += num;
}
});
Expand Down Expand Up @@ -39,17 +38,17 @@ class App extends React.Component {
<InputNumber
aria-label="Controlled number input demonstrating a custom format to add commas"
style={{ width: 100 }}
formatter={value =>
`${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
}
formatter={value => `${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')}
/>

<div>
<h1>In Control</h1>
<InputNumber
aria-label="Controlled number input demonstrating a custom format"
value={this.state.value}
onChange={(value) => { this.setState({ value }); }}
onChange={value => {
this.setState({ value });
}}
formatter={value => `$ ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')}
/>
</div>
Expand All @@ -68,4 +67,4 @@ class App extends React.Component {
}
}

ReactDOM.render(<App />, document.getElementById('__react-content'));
export default App;
Empty file removed examples/precision.html
Empty file.