Skip to content

Commit 1abebd3

Browse files
authored
chore: Use father (#104)
* init with father * ignore lock file * clear eslint * test case move for enzyme * more test case * all test * fix lint * update ci * fix cov
1 parent 54e450e commit 1abebd3

File tree

15 files changed

+602
-485
lines changed

15 files changed

+602
-485
lines changed

.eslintrc.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const base = require('@umijs/fabric/dist/eslint');
2+
const path = require('path');
3+
4+
module.exports = {
5+
...base,
6+
rules: {
7+
...base.rules,
8+
'react/require-default-props': 0,
9+
'jsx-a11y/no-noninteractive-tabindex': 0,
10+
},
11+
};

.fatherrc.js

Lines changed: 8 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.storybook
12
*.iml
23
*.log
34
*.log.*
@@ -28,3 +29,4 @@ lib
2829
es
2930
coverage
3031
yarn.lock
32+
package-lock.json

.prettierrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"endOfLine": "lf",
3+
"semi": true,
4+
"singleQuote": true,
5+
"tabWidth": 2,
6+
"trailingComma": "all",
7+
"printWidth": 100
8+
}

.travis.yml

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,17 @@
11
language: node_js
22

3-
sudo: false
4-
5-
notifications:
6-
email:
7-
- yiminghe@gmail.com
8-
- hust2012jiangkai@gmail.com
9-
103
node_js:
11-
- 6
4+
- 12
125

13-
before_install:
14-
- |
15-
if ! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(\.md$)|(^(docs|examples))/'
16-
then
17-
echo "Only docs were updated, stopping build process."
18-
exit
19-
fi
20-
npm install npm@3.x -g
21-
phantomjs --version
226
script:
237
- |
248
if [ "$TEST_TYPE" = test ]; then
25-
npm test
9+
npm run test -- --coverage && \
10+
bash <(curl -s https://codecov.io/bash)
2611
else
2712
npm run $TEST_TYPE
2813
fi
2914
env:
3015
matrix:
3116
- TEST_TYPE=lint
32-
- TEST_TYPE=test
33-
- TEST_TYPE=coverage
34-
35-
36-
matrix:
37-
allow_failures:
38-
- env: "TEST_TYPE=saucelabs"
17+
- TEST_TYPE=test

examples/simple.html

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/simple.js

Lines changed: 53 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
/* eslint-disable no-console */
2-
import 'rc-notification/assets/index.less';
3-
import Notification from 'rc-notification';
42
import React from 'react';
5-
import ReactDOM from 'react-dom';
3+
import Notification from '../src';
4+
import '../assets/index.less';
5+
66
let notification = null;
7-
Notification.newInstance({}, (n) => notification = n);
7+
Notification.newInstance({}, n => {
8+
notification = n;
9+
});
810

911
function simpleFn() {
1012
notification.notice({
@@ -43,10 +45,14 @@ function close(key) {
4345
function manualClose() {
4446
const key = Date.now();
4547
notification.notice({
46-
content: <div>
47-
<p>click below button to close</p>
48-
<button onClick={close.bind(null, key)}>close</button>
49-
</div>,
48+
content: (
49+
<div>
50+
<p>click below button to close</p>
51+
<button type="button" onClick={close.bind(null, key)}>
52+
close
53+
</button>
54+
</div>
55+
),
5056
key,
5157
duration: null,
5258
});
@@ -73,31 +79,31 @@ function updatableFn() {
7379

7480
notification.notice(initialProps);
7581
intervalKey = setInterval(() => {
76-
notification.notice({ ...initialProps, content: `Timer: ${++counter}s` });
82+
counter += 1;
83+
notification.notice({ ...initialProps, content: `Timer: ${counter}s` });
7784
}, 1000);
7885
}
7986

80-
const clearPath = 'M793 242H366v-74c0-6.7-7.7-10.4-12.9' +
87+
const clearPath =
88+
'M793 242H366v-74c0-6.7-7.7-10.4-12.9' +
8189
'-6.3l-142 112c-4.1 3.2-4.1 9.4 0 12.6l142 112c' +
8290
'5.2 4.1 12.9 0.4 12.9-6.3v-74h415v470H175c-4.4' +
8391
' 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h618c35.3 0 64-' +
8492
'28.7 64-64V306c0-35.3-28.7-64-64-64z';
8593

86-
const getSvg = (path, props = {}, align = false) => {
87-
return (
88-
<i {...props}>
89-
<svg
90-
viewBox="0 0 1024 1024"
91-
width="1em"
92-
height="1em"
93-
fill="currentColor"
94-
style={align ? { verticalAlign: '-.125em ' } : {}}
95-
>
96-
<path d={path} />
97-
</svg>
98-
</i>
99-
);
100-
};
94+
const getSvg = (path, props = {}, align = false) => (
95+
<i {...props}>
96+
<svg
97+
viewBox="0 0 1024 1024"
98+
width="1em"
99+
height="1em"
100+
fill="currentColor"
101+
style={align ? { verticalAlign: '-.125em ' } : {}}
102+
>
103+
<path d={path} />
104+
</svg>
105+
</i>
106+
);
101107

102108
function customCloseIconFn() {
103109
notification.notice({
@@ -108,15 +114,27 @@ function customCloseIconFn() {
108114
});
109115
}
110116

111-
ReactDOM.render(<div>
117+
const Demo = () => (
112118
<div>
113-
<button onClick={simpleFn}>simple show</button>
114-
<button onClick={durationFn}>duration=0</button>
115-
<button onClick={closableFn}>closable</button>
116-
<button onClick={manualClose}>controlled close</button>
117-
<button onClick={updatableFn}>updatable</button>
118-
<div>
119-
<button onClick={customCloseIconFn}>custom close icon</button>
120-
</div>
119+
<button type="button" onClick={simpleFn}>
120+
simple show
121+
</button>
122+
<button type="button" onClick={durationFn}>
123+
duration=0
124+
</button>
125+
<button type="button" onClick={closableFn}>
126+
closable
127+
</button>
128+
<button type="button" onClick={manualClose}>
129+
controlled close
130+
</button>
131+
<button type="button" onClick={updatableFn}>
132+
updatable
133+
</button>
134+
<button type="button" onClick={customCloseIconFn}>
135+
custom close icon
136+
</button>
121137
</div>
122-
</div>, document.getElementById('__react-content'));
138+
);
139+
140+
export default Demo;

jest.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
snapshotSerializers: [require.resolve("enzyme-to-json/serializer")]
3+
};

now.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"version": 2,
3+
"name": "rc-notification",
4+
"builds": [
5+
{
6+
"src": "package.json",
7+
"use": "@now/static-build",
8+
"config": { "distDir": ".doc" }
9+
}
10+
]
11+
}

package.json

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"name": "rc-notification",
33
"version": "3.3.1",
44
"description": "notification ui component for react",
5+
"engines": {
6+
"node": ">=8.x"
7+
},
58
"keywords": [
69
"react",
710
"react-component",
@@ -15,10 +18,10 @@
1518
"hust2012jiangkai@gmail.com"
1619
],
1720
"files": [
18-
"dist",
19-
"lib",
21+
"assets/*.css",
22+
"assets/*.less",
2023
"es",
21-
"assets/*.css"
24+
"lib"
2225
],
2326
"repository": {
2427
"type": "git",
@@ -30,49 +33,35 @@
3033
"license": "MIT",
3134
"main": "lib/index",
3235
"module": "es/index",
33-
"config": {
34-
"port": 8000,
35-
"entry": {
36-
"rc-notification": [
37-
"./assets/index.less",
38-
"./src/index.js"
39-
]
40-
}
41-
},
4236
"scripts": {
43-
"build": "rc-tools run build",
44-
"gh-pages": "rc-tools run gh-pages",
45-
"start": "rc-tools run server",
46-
"compile": "rc-tools run compile --babel-runtime",
47-
"pub": "rc-tools run pub --babel-runtime",
48-
"lint": "rc-tools run lint",
49-
"karma": "rc-test run karma",
50-
"saucelabs": "rc-test run saucelabs",
51-
"test": "rc-test run test",
52-
"chrome-test": "rc-test run chrome-test",
53-
"coverage": "rc-test run coverage",
54-
"prepublish": "rc-tools run guard"
37+
"start": "cross-env NODE_ENV=development father doc dev --storybook",
38+
"build": "father doc build --storybook",
39+
"compile": "father build",
40+
"prepublishOnly": "npm run compile && np --no-cleanup --yolo --no-publish",
41+
"lint": "eslint src/ examples/ --ext .tsx,.ts,.jsx,.js",
42+
"test": "father test",
43+
"now-build": "npm run build"
44+
},
45+
"peerDependencies": {
46+
"react": "*",
47+
"react-dom": "*"
5548
},
5649
"devDependencies": {
57-
"core-js": "^2.5.1",
58-
"expect.js": "~0.3.1",
59-
"pre-commit": "1.x",
60-
"rc-test": "^6.0.8",
61-
"rc-tools": "^6.3.6",
50+
"@types/jest": "^25.1.0",
51+
"@types/react": "^16.8.19",
52+
"@types/react-dom": "^16.8.4",
53+
"cross-env": "^7.0.0",
54+
"enzyme": "^3.3.0",
55+
"enzyme-to-json": "^3.4.0",
56+
"father": "^2.13.2",
57+
"np": "^5.0.3",
6258
"react": "^16.0.0",
6359
"react-dom": "^16.0.0"
6460
},
65-
"precommit": [
66-
"lint"
67-
],
6861
"dependencies": {
69-
"babel-runtime": "6.x",
7062
"classnames": "2.x",
7163
"prop-types": "^15.5.8",
7264
"rc-animate": "2.x",
7365
"rc-util": "^4.0.4"
74-
},
75-
"pre-commit": [
76-
"lint"
77-
]
66+
}
7867
}

0 commit comments

Comments
 (0)