Skip to content

Commit 3c313ff

Browse files
xrkffggkerm1it
andauthored
fix: lint and use github actions (#288)
* Create react-component-ci.yml * chore: use actions * fix lint * fix lint * fix n * fix: lint Co-authored-by: Kermit <[email protected]>
1 parent 9f1c759 commit 3c313ff

File tree

7 files changed

+144
-48
lines changed

7 files changed

+144
-48
lines changed

.eslintrc.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ module.exports = {
1111
"react/no-string-refs": 0,
1212
"react/no-did-update-set-state": 0,
1313
"react/no-find-dom-node": 0,
14-
"@typescript-eslint/no-explicit-any": 1,
15-
"@typescript-eslint/no-empty-interface": 1,
14+
"@typescript-eslint/no-explicit-any": 0,
15+
"@typescript-eslint/no-empty-interface": 0,
1616
"@typescript-eslint/no-inferrable-types": 0,
1717
"react/require-default-props": 0,
1818
"no-confusing-arrow": 0,
+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
setup:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: checkout
14+
uses: actions/checkout@master
15+
16+
- uses: actions/setup-node@v1
17+
with:
18+
node-version: '12'
19+
20+
- name: cache package-lock.json
21+
uses: actions/cache@v2
22+
with:
23+
path: package-temp-dir
24+
key: lock-${{ github.sha }}
25+
26+
- name: create package-lock.json
27+
run: npm i --package-lock-only
28+
29+
- name: hack for singe file
30+
run: |
31+
if [ ! -d "package-temp-dir" ]; then
32+
mkdir package-temp-dir
33+
fi
34+
cp package-lock.json package-temp-dir
35+
36+
- name: cache node_modules
37+
id: node_modules_cache_id
38+
uses: actions/cache@v2
39+
with:
40+
path: node_modules
41+
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
42+
43+
- name: install
44+
if: steps.node_modules_cache_id.outputs.cache-hit != 'true'
45+
run: npm ci
46+
47+
lint:
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: checkout
51+
uses: actions/checkout@master
52+
53+
- name: restore cache from package-lock.json
54+
uses: actions/cache@v2
55+
with:
56+
path: package-temp-dir
57+
key: lock-${{ github.sha }}
58+
59+
- name: restore cache from node_modules
60+
uses: actions/cache@v2
61+
with:
62+
path: node_modules
63+
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
64+
65+
- name: lint
66+
run: npm run lint
67+
68+
needs: setup
69+
70+
compile:
71+
runs-on: ubuntu-latest
72+
steps:
73+
- name: checkout
74+
uses: actions/checkout@master
75+
76+
- name: restore cache from package-lock.json
77+
uses: actions/cache@v2
78+
with:
79+
path: package-temp-dir
80+
key: lock-${{ github.sha }}
81+
82+
- name: restore cache from node_modules
83+
uses: actions/cache@v2
84+
with:
85+
path: node_modules
86+
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
87+
88+
- name: compile
89+
run: npm run compile
90+
91+
needs: setup
92+
93+
coverage:
94+
runs-on: ubuntu-latest
95+
steps:
96+
- name: checkout
97+
uses: actions/checkout@master
98+
99+
- name: restore cache from package-lock.json
100+
uses: actions/cache@v2
101+
with:
102+
path: package-temp-dir
103+
key: lock-${{ github.sha }}
104+
105+
- name: restore cache from node_modules
106+
uses: actions/cache@v2
107+
with:
108+
path: node_modules
109+
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
110+
111+
- name: coverage
112+
run: npm test -- --coverage && bash <(curl -s https://codecov.io/bash)
113+
114+
needs: setup

.travis.yml

-34
This file was deleted.

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Input number control.
55

66
[![NPM version][npm-image]][npm-url]
7-
[![build status][travis-image]][travis-url]
7+
[![build status][github-actions-image]][github-actions-url]
88
[![Test coverage][coveralls-image]][coveralls-url]
99
[![Dependencies][david-image]][david-url]
1010
[![DevDependencies][david-dev-image]][david-dev-url]
@@ -13,8 +13,8 @@ Input number control.
1313

1414
[npm-image]: http://img.shields.io/npm/v/rc-input-number.svg?style=flat-square
1515
[npm-url]: http://npmjs.org/package/rc-input-number
16-
[travis-image]: https://img.shields.io/travis/react-component/input-number/master?style=flat-square
17-
[travis-url]: https://travis-ci.org/react-component/input-number
16+
[github-actions-image]: https://github.com/react-component/input-number/workflows/CI/badge.svg
17+
[github-actions-url]: https://github.com/react-component/input-number/actions
1818
[circleci-image]: https://img.shields.io/circleci/react-component/input-number/master?style=flat-square
1919
[circleci-url]: https://circleci.com/gh/react-component/input-number
2020
[coveralls-image]: https://img.shields.io/coveralls/react-component/input-number.svg?style=flat-square

src/InputNumber.tsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import React from 'react';
33
import classNames from 'classnames';
44
import KeyCode from 'rc-util/lib/KeyCode';
5-
import { InputNumberProps, InputNumberState } from './interface';
5+
import type { InputNumberProps, InputNumberState } from './interface';
66

77
function noop() {}
88

@@ -574,7 +574,7 @@ class InputNumber extends React.Component<Partial<InputNumberProps>, InputNumber
574574
const precisionFactor = this.getPrecisionFactor(val, rat);
575575
const precision = Math.abs(this.getMaxPrecision(val, rat));
576576
const result = (
577-
(precisionFactor * val + precisionFactor * (step as number) * rat) /
577+
(precisionFactor * val + precisionFactor * (Number(step)) * rat) /
578578
precisionFactor
579579
).toFixed(precision);
580580
return this.toNumber(result);
@@ -585,7 +585,7 @@ class InputNumber extends React.Component<Partial<InputNumberProps>, InputNumber
585585
const precisionFactor = this.getPrecisionFactor(val, rat);
586586
const precision = Math.abs(this.getMaxPrecision(val, rat));
587587
const result = (
588-
(precisionFactor * val - precisionFactor * (step as number) * rat) /
588+
(precisionFactor * val - precisionFactor * (Number(step)) * rat) /
589589
precisionFactor
590590
).toFixed(precision);
591591
return this.toNumber(result);
@@ -737,7 +737,7 @@ class InputNumber extends React.Component<Partial<InputNumberProps>, InputNumber
737737
[`${prefixCls}-handler-down-disabled`]: isDownDisabled,
738738
});
739739

740-
const upEvents = useTouch
740+
const upEvents: any = useTouch
741741
? {
742742
onTouchStart: isUpDisabled ? noop : this.up,
743743
onTouchEnd: this.stop,
@@ -747,7 +747,7 @@ class InputNumber extends React.Component<Partial<InputNumberProps>, InputNumber
747747
onMouseUp: this.stop,
748748
onMouseLeave: this.stop,
749749
};
750-
const downEvents = useTouch
750+
const downEvents: any = useTouch
751751
? {
752752
onTouchStart: isDownDisabled ? noop : this.down,
753753
onTouchEnd: this.stop,
@@ -773,7 +773,7 @@ class InputNumber extends React.Component<Partial<InputNumberProps>, InputNumber
773773
<div className={`${prefixCls}-handler-wrap`}>
774774
<span
775775
unselectable="on"
776-
{...(upEvents as any)}
776+
{...upEvents}
777777
role="button"
778778
aria-label="Increase Value"
779779
aria-disabled={isUpDisabled}
@@ -789,7 +789,7 @@ class InputNumber extends React.Component<Partial<InputNumberProps>, InputNumber
789789
</span>
790790
<span
791791
unselectable="on"
792-
{...(downEvents as any)}
792+
{...downEvents}
793793
role="button"
794794
aria-label="Decrease Value"
795795
aria-disabled={isDownDisabled}

src/interface.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import type React from 'react';
2+
13
type ISize = 'large' | 'middle' | 'small';
24

3-
export interface InputNumberProps {
5+
export type InputNumberProps = {
46
focusOnUpDown: boolean;
57
useTouch: boolean;
68
prefixCls?: string;
@@ -37,7 +39,7 @@ export interface InputNumberProps {
3739
[key: string]: any;
3840
}
3941

40-
export interface InputNumberState {
42+
export type InputNumberState = {
4143
inputValue?: string;
4244
value?: number;
4345
focused?: boolean;

tsconfig.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"compilerOptions": {
3+
"target": "esnext",
4+
"moduleResolution": "node",
5+
"baseUrl": "./",
6+
"jsx": "preserve",
7+
"declaration": true,
8+
"skipLibCheck": true,
9+
"esModuleInterop": true,
10+
"paths": {
11+
"@/*": ["src/*"]
12+
}
13+
}
14+
}

0 commit comments

Comments
 (0)