Skip to content

Commit cf923ee

Browse files
committed
fix eslint
1 parent b188996 commit cf923ee

File tree

11 files changed

+50
-52
lines changed

11 files changed

+50
-52
lines changed

examples/customRequest.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const uploadProps = {
3535
withCredentials,
3636
}) {
3737
// EXAMPLE: post form-data with 'axios'
38+
// eslint-disable-next-line no-undef
3839
const formData = new FormData();
3940
if (data) {
4041
Object.keys(data).forEach(key => {

examples/directoryUpload.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class Test extends React.Component {
1919
},
2020
onStart: (file) => {
2121
console.log('onStart', file.name);
22-
// this.refs.inner.abort(file);
2322
},
2423
onSuccess(file) {
2524
console.log('onSuccess', file);
@@ -40,7 +39,7 @@ class Test extends React.Component {
4039
>
4140

4241
<div>
43-
<Upload {...this.uploaderProps} ref="inner"><a>开始上传</a></Upload>
42+
<Upload {...this.uploaderProps}><a>开始上传</a></Upload>
4443
</div>
4544

4645
</div>);

examples/drag.js

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,27 @@ import React from 'react';
44
import ReactDOM from 'react-dom';
55
import Upload from 'rc-upload';
66

7-
class Test extends React.Component {
8-
render() {
9-
const props = {
10-
action: '/upload.do',
11-
type: 'drag',
12-
accept: '.png',
13-
beforeUpload(file) {
14-
console.log('beforeUpload', file.name);
15-
},
16-
onStart: (file) => {
17-
console.log('onStart', file.name);
18-
},
19-
onSuccess(file) {
20-
console.log('onSuccess', file);
21-
},
22-
onProgress(step, file) {
23-
console.log('onProgress', Math.round(step.percent), file.name);
24-
},
25-
onError(err) {
26-
console.log('onError', err);
27-
},
28-
style: { display: 'inline-block', width: 200, height: 200, background: '#eee' },
29-
// openFileDialogOnClick: false
30-
};
31-
return <Upload {...props} />;
32-
}
33-
}
7+
const props = {
8+
action: '/upload.do',
9+
type: 'drag',
10+
accept: '.png',
11+
beforeUpload(file) {
12+
console.log('beforeUpload', file.name);
13+
},
14+
onStart: (file) => {
15+
console.log('onStart', file.name);
16+
},
17+
onSuccess(file) {
18+
console.log('onSuccess', file);
19+
},
20+
onProgress(step, file) {
21+
console.log('onProgress', Math.round(step.percent), file.name);
22+
},
23+
onError(err) {
24+
console.log('onError', err);
25+
},
26+
style: { display: 'inline-block', width: 200, height: 200, background: '#eee' },
27+
// openFileDialogOnClick: false
28+
};
3429

35-
ReactDOM.render(<Test />, document.getElementById('__react-content'));
30+
ReactDOM.render(<Upload {...props} />, document.getElementById('__react-content'));

examples/simple.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class Test extends React.Component {
2424
},
2525
onStart: (file) => {
2626
console.log('onStart', file.name);
27-
// this.refs.inner.abort(file);
2827
},
2928
onSuccess(file) {
3029
console.log('onSuccess', file);
@@ -61,7 +60,7 @@ class Test extends React.Component {
6160
</style>
6261

6362
<div>
64-
<Upload {...this.uploaderProps} ref="inner"><a>开始上传</a></Upload>
63+
<Upload {...this.uploaderProps}><a>开始上传</a></Upload>
6564
</div>
6665

6766
<h2>滚动</h2>

examples/transformFile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const uploadProps = {
2424
},
2525
transformFile(file) {
2626
return new Promise((resolve) => {
27+
// eslint-disable-next-line no-undef
2728
const reader = new FileReader();
2829
reader.readAsDataURL(file);
2930
reader.onload = () => {

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
"build": "rc-tools run build",
3131
"gh-pages": "rc-tools run gh-pages",
3232
"start": "node server",
33-
"compile": "rc-tools run compile --babel-runtime",
34-
"pub": "rc-tools run pub --babel-runtime",
33+
"compile": "rc-tools run compile",
34+
"pub": "rc-tools run pub",
3535
"lint": "rc-tools run lint",
3636
"test": "jest --setupTestFrameworkScriptFile=raf/polyfill",
3737
"coverage": "jest --coverage && cat ./coverage/lcov.info | coveralls"
@@ -46,17 +46,16 @@
4646
"jest": "^20.0.1",
4747
"pre-commit": "1.x",
4848
"raf": "^3.4.0",
49-
"rc-tools": "6.x",
49+
"rc-tools": "8.x",
5050
"react": "^16.0.0",
5151
"react-dom": "^16.0.0",
52-
"sinon": "9.0.2",
52+
"sinon": "^9.0.2",
5353
"vinyl-fs": "^3.0.3"
5454
},
5555
"pre-commit": [
5656
"lint"
5757
],
5858
"dependencies": {
59-
"babel-runtime": "6.x",
6059
"classnames": "^2.2.5"
6160
},
6261
"jest": {

src/AjaxUploader.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,13 @@ class AjaxUploader extends Component {
113113
}
114114
return this.post(file);
115115
}).catch(e => {
116-
console && console.log(e); // eslint-disable-line
116+
// eslint-disable-next-line no-console
117+
console.log(e);
117118
});
118119
} else if (before !== false) {
119120
setTimeout(() => this.post(file), 0);
120121
}
122+
return undefined;
121123
}
122124

123125
post(file) {
@@ -209,7 +211,7 @@ class AjaxUploader extends Component {
209211
const {
210212
component: Tag, prefixCls, className, disabled, id,
211213
style, multiple, accept, children, directory, openFileDialogOnClick,
212-
...otherProps,
214+
...otherProps
213215
} = this.props;
214216
const cls = classNames({
215217
[prefixCls]: true,

src/request.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ function getBody(xhr) {
3232
// headers: Object,
3333
// }
3434
export default function upload(option) {
35+
// eslint-disable-next-line no-undef
3536
const xhr = new XMLHttpRequest();
3637

3738
if (option.onProgress && xhr.upload) {
@@ -43,6 +44,7 @@ export default function upload(option) {
4344
};
4445
}
4546

47+
// eslint-disable-next-line no-undef
4648
const formData = new FormData();
4749

4850
if (option.data) {
@@ -62,6 +64,7 @@ export default function upload(option) {
6264
});
6365
}
6466

67+
// eslint-disable-next-line no-undef
6568
if (option.file instanceof Blob) {
6669
formData.append(option.filename, option.file, option.file.name);
6770
} else {
@@ -79,10 +82,9 @@ export default function upload(option) {
7982
return option.onError(getError(option, xhr), getBody(xhr));
8083
}
8184

82-
option.onSuccess(getBody(xhr), xhr);
85+
return option.onSuccess(getBody(xhr), xhr);
8386
};
8487

85-
8688
xhr.open(option.method, option.action, true);
8789

8890
// Has to be after `.open()`. See https://github.com/enyo/dropzone/issues/179
@@ -98,11 +100,12 @@ export default function upload(option) {
98100
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
99101
}
100102

101-
for (const h in headers) {
102-
if (headers.hasOwnProperty(h) && headers[h] !== null) {
103+
Object.keys(headers).forEach(h => {
104+
if (headers[h] !== null) {
103105
xhr.setRequestHeader(h, headers[h]);
104-
}
105-
}
106+
}
107+
});
108+
106109
xhr.send(formData);
107110

108111
return {

src/traverseFileTree.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ const traverseFileTree = (files, callback, isAccepted) => {
5252
});
5353
}
5454
};
55-
for (const file of files) {
55+
files.forEach(file => {
5656
_traverseFileTree(file.webkitGetAsEntry());
57-
}
57+
});
5858
};
5959

6060
export default traverseFileTree;

tests/request.spec.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/* eslint no-console:0 */
2-
32
import expect from 'expect.js';
4-
import request from '../src/request';
53
import sinon from 'sinon';
4+
import request from '../src/request';
65

76
let xhr;
87
let requests;

0 commit comments

Comments
 (0)