Skip to content

Commit 2094191

Browse files
committed
[eslint] fix some spacing issues
1 parent 4066fd6 commit 2094191

32 files changed

+268
-313
lines changed

.eslintrc

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
{
22
"rules": {
3-
"indent": [2, 2, {"SwitchCase": 1}],
4-
"quotes": [2, "single"],
5-
"linebreak-style": [2, "unix"],
6-
"semi": [2, "always"],
3+
"indent": [2, 2, {"SwitchCase": 2}],
74
"curly": [2, "multi-line"],
85
"handle-callback-err": [2, "^err"],
96
"valid-jsdoc": [2, {
@@ -25,24 +22,50 @@
2522
"no-extra-semi": 2,
2623
"no-unused-vars": 2,
2724
"no-undef": 2,
28-
"no-irregular-whitespace": 2,
29-
"no-console": 2,
30-
"key-spacing": 0,
3125
"strict": 0,
3226
"dot-notation": 0,
33-
"eol-last": 0,
3427
"no-new": 0,
35-
"semi-spacing": 0,
36-
"no-multi-spaces": 0,
3728
"eqeqeq": 0,
38-
"no-mixed-requires": 0
29+
30+
"object-curly-spacing": [2, "always"],
31+
"linebreak-style": [2, "unix"],
32+
"no-mixed-requires": 0,
33+
"no-console": 2,
34+
"space-before-function-paren": [2, { "anonymous": "always", "named": "never", "asyncArrow": "always" }],
35+
"space-before-blocks": [2, { "functions": "always", "keywords": "always", "classes": "always" }],
36+
"space-in-parens": [2, "never"],
37+
"space-infix-ops": [2],
38+
"space-unary-ops": [2, { "words": true, "nonwords": false }],
39+
"spaced-comment": [2, "always", { "markers": ["!"] }],
40+
"no-irregular-whitespace": 2,
41+
"no-mixed-spaces-and-tabs": [2, false],
42+
"semi-spacing": [2, { "before": false, "after": true }],
43+
"no-multi-spaces": [2, { "ignoreEOLComments": false }],
44+
"no-regex-spaces": [2],
45+
"no-spaced-func": [2],
46+
"no-trailing-spaces": [2, {
47+
"skipBlankLines": false,
48+
"ignoreComments": false
49+
}],
50+
"no-whitespace-before-property": [2],
51+
// "semi-style": [2, "last"],
52+
"key-spacing": [2, {
53+
"beforeColon": false,
54+
"afterColon": true,
55+
"mode": "strict"
56+
}],
57+
"quotes": [2, "single", "avoid-escape"],
58+
"semi": [2, "always"],
59+
"eol-last": [2, "always"],
3960
},
61+
4062
"env": {
4163
"node": true
4264
},
65+
4366
"ignorePatterns": [
4467
"node_modules/*",
4568
"index.d.ts",
4669
"coverage",
47-
]
70+
],
4871
}

Readme.md

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var http = require('http');
4242

4343
var form = new FormData();
4444

45-
http.request('http://nodejs.org/images/logo.png', function(response) {
45+
http.request('http://nodejs.org/images/logo.png', function (response) {
4646
form.append('my_field', 'my value');
4747
form.append('my_buffer', new Buffer(10));
4848
form.append('my_logo', response);
@@ -65,7 +65,7 @@ form.append('my_logo', request('http://nodejs.org/images/logo.png'));
6565
In order to submit this form to a web application, call ```submit(url, [callback])``` method:
6666

6767
``` javascript
68-
form.submit('http://example.org/', function(err, res) {
68+
form.submit('http://example.org/', function (err, res) {
6969
// res – response object (http.IncomingMessage) //
7070
res.resume();
7171
});
@@ -104,15 +104,15 @@ var request = http.request({
104104

105105
form.pipe(request);
106106

107-
request.on('response', function(res) {
107+
request.on('response', function (res) {
108108
console.log(res.statusCode);
109109
});
110110
```
111111

112112
Or if you would prefer the `'Content-Length'` header to be set for you:
113113

114114
``` javascript
115-
form.submit('example.org/upload', function(err, res) {
115+
form.submit('example.org/upload', function (err, res) {
116116
console.log(res.statusCode);
117117
});
118118
```
@@ -130,7 +130,7 @@ var options = {
130130

131131
form.append('my_buffer', buffer, options);
132132

133-
form.submit('http://example.com/', function(err, res) {
133+
form.submit('http://example.com/', function (err, res) {
134134
if (err) throw err;
135135
console.log('Done');
136136
});
@@ -139,7 +139,7 @@ form.submit('http://example.com/', function(err, res) {
139139
Form-Data can recognize and fetch all the required information from common types of streams (```fs.readStream```, ```http.response``` and ```mikeal's request```), for some other types of streams you'd need to provide "file"-related information manually:
140140

141141
``` javascript
142-
someModule.stream(function(err, stdout, stderr) {
142+
someModule.stream(function (err, stdout, stderr) {
143143
if (err) throw err;
144144

145145
var form = new FormData();
@@ -151,7 +151,7 @@ someModule.stream(function(err, stdout, stderr) {
151151
knownLength: 19806
152152
});
153153

154-
form.submit('http://example.com/', function(err, res) {
154+
form.submit('http://example.com/', function (err, res) {
155155
if (err) throw err;
156156
console.log('Done');
157157
});
@@ -167,7 +167,7 @@ form.submit({
167167
host: 'example.com',
168168
path: '/probably.php?extra=params',
169169
auth: 'username:password'
170-
}, function(err, res) {
170+
}, function (err, res) {
171171
console.log(res.statusCode);
172172
});
173173
```
@@ -178,8 +178,8 @@ In case you need to also send custom HTTP headers with the POST request, you can
178178
form.submit({
179179
host: 'example.com',
180180
path: '/surelynot.php',
181-
headers: {'x-test-header': 'test-header-value'}
182-
}, function(err, res) {
181+
headers: { 'x-test-header': 'test-header-value' }
182+
}, function (err, res) {
183183
console.log(res.statusCode);
184184
});
185185
```
@@ -201,20 +201,20 @@ form.submit({
201201
Append data to the form. You can submit about any format (string, integer, boolean, buffer, etc.). However, Arrays are not supported and need to be turned into strings by the user.
202202
```javascript
203203
var form = new FormData();
204-
form.append( 'my_string', 'my value' );
205-
form.append( 'my_integer', 1 );
206-
form.append( 'my_boolean', true );
207-
form.append( 'my_buffer', new Buffer(10) );
208-
form.append( 'my_array_as_json', JSON.stringify( ['bird','cute'] ) )
204+
form.append('my_string', 'my value');
205+
form.append('my_integer', 1);
206+
form.append('my_boolean', true);
207+
form.append('my_buffer', new Buffer(10));
208+
form.append('my_array_as_json', JSON.stringify(['bird', 'cute']));
209209
```
210210

211211
You may provide a string for options, or an object.
212212
```javascript
213213
// Set filename by providing a string for options
214-
form.append( 'my_file', fs.createReadStream('/foo/bar.jpg'), 'bar.jpg' );
214+
form.append('my_file', fs.createReadStream('/foo/bar.jpg'), 'bar.jpg');
215215

216216
// provide an object.
217-
form.append( 'my_file', fs.createReadStream('/foo/bar.jpg'), {filename: 'bar.jpg', contentType: 'image/jpeg', knownLength: 19806} );
217+
form.append('my_file', fs.createReadStream('/foo/bar.jpg'), { filename: 'bar.jpg', contentType: 'image/jpeg', knownLength: 19806 });
218218
```
219219

220220
#### _Headers_ getHeaders( [**Headers** _userHeaders_] )
@@ -236,13 +236,10 @@ _Note: The boundary must be unique and may not appear in the data._
236236
Return the full formdata request package, as a Buffer. You can insert this Buffer in e.g. Axios to send multipart data.
237237
```javascript
238238
var form = new FormData();
239-
form.append( 'my_buffer', Buffer.from([0x4a,0x42,0x20,0x52,0x6f,0x63,0x6b,0x73]) );
240-
form.append( 'my_file', fs.readFileSync('/foo/bar.jpg') );
239+
form.append('my_buffer', Buffer.from([0x4a,0x42,0x20,0x52,0x6f,0x63,0x6b,0x73]));
240+
form.append('my_file', fs.readFileSync('/foo/bar.jpg'));
241241

242-
axios.post( 'https://example.com/path/to/api',
243-
form.getBuffer(),
244-
form.getHeaders()
245-
)
242+
axios.post('https://example.com/path/to/api', form.getBuffer(), form.getHeaders());
246243
```
247244
**Note:** Because the output is of type Buffer, you can only append types that are accepted by Buffer: *string, Buffer, ArrayBuffer, Array, or Array-like Object*. A ReadStream for example will result in an error.
248245

@@ -251,10 +248,10 @@ Same as `getLength` but synchronous.
251248

252249
_Note: getLengthSync __doesn't__ calculate streams length._
253250

254-
#### _Integer_ getLength( **function** _callback_ )
251+
#### _Integer_ getLength(**function** _callback_ )
255252
Returns the `Content-Length` async. The callback is used to handle errors and continue once the length has been calculated
256253
```javascript
257-
this.getLength(function(err, length) {
254+
this.getLength(function (err, length) {
258255
if (err) {
259256
this._error(err);
260257
return;
@@ -270,13 +267,13 @@ this.getLength(function(err, length) {
270267
#### _Boolean_ hasKnownLength()
271268
Checks if the length of added values is known.
272269

273-
#### _Request_ submit( _params_, **function** _callback_ )
270+
#### _Request_ submit(_params_, **function** _callback_ )
274271
Submit the form to a web application.
275272
```javascript
276273
var form = new FormData();
277-
form.append( 'my_string', 'Hello World' );
274+
form.append('my_string', 'Hello World');
278275

279-
form.submit( 'http://example.com/', function(err, res) {
276+
form.submit('http://example.com/', function (err, res) {
280277
// res – response object (http.IncomingMessage) //
281278
res.resume();
282279
} );
@@ -297,7 +294,7 @@ var formData = {
297294
my_file: fs.createReadStream(__dirname + '/unicycle.jpg'),
298295
};
299296

300-
request.post({url:'http://service.com/upload', formData: formData}, function(err, httpResponse, body) {
297+
request.post({url:'http://service.com/upload', formData: formData}, function (err, httpResponse, body) {
301298
if (err) {
302299
return console.error('upload failed:', err);
303300
}
@@ -317,9 +314,9 @@ var form = new FormData();
317314
form.append('a', 1);
318315

319316
fetch('http://example.com', { method: 'POST', body: form })
320-
.then(function(res) {
317+
.then(function (res) {
321318
return res.json();
322-
}).then(function(json) {
319+
}).then(function (json) {
323320
console.log(json);
324321
});
325322
```
@@ -341,8 +338,8 @@ axios.post('http://example.com', form, {
341338
...formHeaders,
342339
},
343340
})
344-
.then(response => response)
345-
.catch(error => error)
341+
.then(response => response)
342+
.catch(error => error)
346343
```
347344

348345
## Notes

0 commit comments

Comments
 (0)