diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..17d82f5 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,16 @@ +const base = require('@umijs/fabric/dist/eslint'); + +module.exports = { + ...base, + rules: { + ...base.rules, + 'no-template-curly-in-string': 0, + 'prefer-promise-reject-errors': 0, + 'react/no-array-index-key': 0, + 'react/sort-comp': 0, + '@typescript-eslint/no-explicit-any': 0, + 'jsx-a11y/role-supports-aria-props': 0, + 'jsx-a11y/no-noninteractive-tabindex': 0, + 'import/no-extraneous-dependencies': 0, + }, +}; diff --git a/.fatherrc.js b/.fatherrc.js new file mode 100644 index 0000000..9d8c16b --- /dev/null +++ b/.fatherrc.js @@ -0,0 +1,9 @@ +export default { + cjs: "babel", + esm: { type: "babel", importLibToEs: true }, + preCommit: { + eslint: true, + prettier: true, + }, + runtimeHelpers: true, +}; diff --git a/.gitignore b/.gitignore index 36ad908..4e39e43 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,7 @@ build lib es coverage/ -yarn.lock \ No newline at end of file +yarn.lock +package-lock.json +.storybook +.doc diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..895b8bd --- /dev/null +++ b/.prettierrc @@ -0,0 +1,6 @@ +{ + "singleQuote": true, + "trailingComma": "all", + "proseWrap": "never", + "printWidth": 100 +} diff --git a/.travis.yml b/.travis.yml index d16a491..2fbc8bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,11 +5,9 @@ sudo: false notifications: email: - yiminghe@gmail.com - - afc163@gmail.com - - yesmeck@gmail.com node_js: -- 10 +- 12 script: - | @@ -19,7 +17,10 @@ script: else npm run $TEST_TYPE fi + env: matrix: - TEST_TYPE=lint - TEST_TYPE=test + - TEST_TYPE=coverage + - TEST_TYPE=compile diff --git a/assets/index.less b/assets/index.less deleted file mode 100644 index e69de29..0000000 diff --git a/examples/fast-progress.html b/examples/fast-progress.html deleted file mode 100644 index 48cdce8..0000000 --- a/examples/fast-progress.html +++ /dev/null @@ -1 +0,0 @@ -placeholder diff --git a/examples/fast-progress.js b/examples/fast-progress.tsx similarity index 66% rename from examples/fast-progress.js rename to examples/fast-progress.tsx index 21b1644..7b8d8dd 100644 --- a/examples/fast-progress.js +++ b/examples/fast-progress.tsx @@ -1,11 +1,9 @@ -import 'rc-progress/assets/index.less'; -import React, { Component } from 'react'; -import ReactDOM from 'react-dom'; -import { Line, Circle } from 'rc-progress'; +import * as React from 'react'; +import { Line, Circle, ProgressProps } from '../src'; -class App extends Component { - constructor() { - super(); +class App extends React.Component { + constructor(props) { + super(props); this.state = { percent: 0, }; @@ -13,6 +11,8 @@ class App extends Component { this.restart = this.restart.bind(this); } + private tm: number; + componentDidMount() { this.increase(); } @@ -39,8 +39,8 @@ class App extends Component { const { percent } = this.state; return (
- - + + @@ -49,4 +49,4 @@ class App extends Component { } } -ReactDOM.render(, document.getElementById('__react-content')); +export default App; diff --git a/examples/gap.html b/examples/gap.html deleted file mode 100644 index 48cdce8..0000000 --- a/examples/gap.html +++ /dev/null @@ -1 +0,0 @@ -placeholder diff --git a/examples/gap.js b/examples/gap.tsx similarity index 76% rename from examples/gap.js rename to examples/gap.tsx index 5bc6163..cd752b3 100644 --- a/examples/gap.js +++ b/examples/gap.tsx @@ -1,15 +1,15 @@ -import 'rc-progress/assets/index.less'; -import React, { Component } from 'react'; -import ReactDOM from 'react-dom'; -import { Circle } from 'rc-progress'; +import * as React from 'react'; +import { Circle, ProgressProps } from '../src'; const colorMap = ['#3FC7FA', '#85D262', '#FE8C6A']; + function getColor(index) { return colorMap[(index + colorMap.length) % colorMap.length]; } -class Example extends Component { - constructor() { - super(); + +class Example extends React.Component { + constructor(props) { + super(props); this.state = { percent: 30, colorIndex: 0, @@ -18,8 +18,8 @@ class Example extends Component { } changeState() { - const value = parseInt(Math.random() * 100, 10); - const colorIndex = parseInt(Math.random() * 3, 10); + const value = parseInt((Math.random() * 100).toString(), 10); + const colorIndex = parseInt((Math.random() * 3).toString(), 10); this.setState({ percent: value, colorIndex, @@ -45,7 +45,7 @@ class Example extends Component { percent={percent} gapDegree={70} gapPosition="top" - strokeWidth="6" + strokeWidth={6} strokeLinecap="square" strokeColor={color} /> @@ -55,8 +55,8 @@ class Example extends Component { percent={[percent / 3, percent / 3, percent / 3]} gapDegree={70} gapPosition="bottom" - strokeWidth="6" - trailWidth="6" + strokeWidth={6} + trailWidth={6} strokeLinecap="round" strokeColor={[color, getColor(colorIndex + 1), getColor(colorIndex + 2)]} /> @@ -67,7 +67,7 @@ class Example extends Component { percent={percent} gapDegree={70} gapPosition="left" - strokeWidth="6" + strokeWidth={6} strokeLinecap="square" strokeColor={color} /> @@ -77,7 +77,7 @@ class Example extends Component { percent={percent} gapDegree={70} gapPosition="right" - strokeWidth="6" + strokeWidth={6} strokeLinecap="square" strokeColor={color} /> @@ -87,4 +87,4 @@ class Example extends Component { } } -ReactDOM.render(, document.getElementById('__react-content')); +export default Example; diff --git a/examples/gradient-circle.html b/examples/gradient-circle.html deleted file mode 100644 index b3a4252..0000000 --- a/examples/gradient-circle.html +++ /dev/null @@ -1 +0,0 @@ -placeholder \ No newline at end of file diff --git a/examples/gradient-circle.js b/examples/gradient-circle.tsx similarity index 78% rename from examples/gradient-circle.js rename to examples/gradient-circle.tsx index 9acefee..2b844e8 100644 --- a/examples/gradient-circle.js +++ b/examples/gradient-circle.tsx @@ -1,7 +1,5 @@ -import 'rc-progress/assets/index.less'; -import React from 'react'; -import ReactDOM from 'react-dom'; -import { Circle } from 'rc-progress'; +import * as React from 'react'; +import { Circle } from '../src'; const Example = () => { const circleContainerStyle = { @@ -9,13 +7,14 @@ const Example = () => { height: '250px', display: 'inline-block', }; + return (

Circle Progress {90}%

{
{
{ ); }; -ReactDOM.render(, document.getElementById('__react-content')); +export default Example; diff --git a/examples/simple.html b/examples/simple.html deleted file mode 100644 index b3a4252..0000000 --- a/examples/simple.html +++ /dev/null @@ -1 +0,0 @@ -placeholder \ No newline at end of file diff --git a/examples/simple.js b/examples/simple.tsx similarity index 64% rename from examples/simple.js rename to examples/simple.tsx index 2795052..b09ec41 100644 --- a/examples/simple.js +++ b/examples/simple.tsx @@ -1,11 +1,9 @@ -import 'rc-progress/assets/index.less'; -import React, { Component } from 'react'; -import ReactDOM from 'react-dom'; -import { Line, Circle } from 'rc-progress'; +import * as React from 'react'; +import { Line, Circle, ProgressProps } from '../src'; -class Example extends Component { - constructor() { - super(); +class Example extends React.Component { + constructor(props) { + super(props); this.state = { percent: 30, color: '#3FC7FA', @@ -15,10 +13,10 @@ class Example extends Component { changeState() { const colorMap = ['#3FC7FA', '#85D262', '#FE8C6A']; - const value = parseInt(Math.random() * 100, 10); + const value = parseInt((Math.random() * 100).toString(), 10); this.setState({ percent: value, - color: colorMap[parseInt(Math.random() * 3, 10)], + color: colorMap[parseInt((Math.random() * 3).toString(), 10)], }); } @@ -36,16 +34,16 @@ class Example extends Component {

Line Progress {percent}%

- +

Circle Progress {percent}%

- +