Skip to content

Commit c335610

Browse files
committed
Housecleaning
1 parent 8ad1f02 commit c335610

16 files changed

Lines changed: 163 additions & 31 deletions

.eslintrc

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
{
22
"rules": {
3-
"indent": [2, 2],
3+
"indent": [2, 2, {"SwitchCase": 1}],
44
"quotes": [2, "single"],
55
"linebreak-style": [2, "unix"],
66
"semi": [2, "always"],
7-
"curly": [2, "all"],
8-
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
7+
"curly": [2, "multi-line"],
98
"handle-callback-err": [2, "^err"],
109
"valid-jsdoc": [2, {
1110
"requireReturn": false,
@@ -14,20 +13,31 @@
1413
"return": "returns"
1514
}
1615
}],
16+
"require-jsdoc": [2, {
17+
"require": {
18+
"FunctionDeclaration": true
19+
}
20+
}],
21+
"no-redeclare": [2, { "builtinGlobals": true }],
22+
"no-shadow": [2, { "builtinGlobals": true, "hoist": "all" }],
23+
"no-use-before-define": [2, "nofunc"],
24+
"no-shadow-restricted-names": 2,
25+
"no-extra-semi": 2,
26+
"no-unused-vars": 2,
27+
"no-undef": 2,
1728
"key-spacing": 0,
1829
"strict": 0,
19-
"no-underscore-dangle": 0,
20-
"no-use-before-define": 0,
2130
"dot-notation": 0,
2231
"eol-last": 0,
2332
"no-new": 0,
2433
"semi-spacing": 0,
2534
"no-multi-spaces": 0,
2635
"eqeqeq": 0,
27-
"no-mixed-requires": 0
36+
"no-mixed-requires": 0,
37+
"no-console": 0
2838
},
2939
"env": {
3040
"node": true,
31-
"browser": true
41+
"browser": false
3242
}
3343
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66

77
sftp-config.json
88

9+
coverage/
910
node_modules/
1011
test/tmp/

.istanbul.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
verbose: false
2+
instrumentation:
3+
root: .
4+
extensions:
5+
- .js
6+
default-excludes: true
7+
excludes: ['browser.js']
8+
reporting:
9+
print: summary
10+
reports:
11+
- lcov
12+
dir: ./coverage
13+
watermarks:
14+
statements: [80, 95]
15+
lines: [80, 95]
16+
functions: [80, 95]
17+
branches: [80, 95]

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
.idea
66
.gitignore
7+
.istanbul.yml
78
.npmignore
89
.travis.yml
910

1011
Makefile
1112
sftp-config.json
1213

14+
coverage/
1315
node_modules/
1416
test/

lib/browser.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
module.exports = FormData;
1+
/* eslint-env browser */
2+
module.exports = FormData;

lib/form_data.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,19 @@ var mime = require('mime-types');
99
var async = require('async');
1010
var populate = require('./populate.js');
1111

12+
// Public API
1213
module.exports = FormData;
14+
15+
// make it a Stream
16+
util.inherits(FormData, CombinedStream);
17+
18+
/**
19+
* Create readable "multipart/form-data" streams.
20+
* Can be used to submit forms
21+
* and file uploads to other web applications.
22+
*
23+
* @constructor
24+
*/
1325
function FormData() {
1426
if (!(this instanceof FormData)) {
1527
throw new TypeError('Failed to construct FormData: Please use the _new_ operator, this object constructor cannot be called as a function.');
@@ -21,7 +33,6 @@ function FormData() {
2133

2234
CombinedStream.call(this);
2335
}
24-
util.inherits(FormData, CombinedStream);
2536

2637
FormData.LINE_BREAK = '\r\n';
2738
FormData.DEFAULT_CONTENT_TYPE = 'application/octet-stream';
@@ -340,9 +351,8 @@ FormData.prototype.getLength = function(cb) {
340351
FormData.prototype.submit = function(params, cb) {
341352
var request
342353
, options
343-
, defaults = {
344-
method : 'post'
345-
};
354+
, defaults = {method: 'post'}
355+
;
346356

347357
// parse provided url if it's string
348358
// or treat it as options object

package.json

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@
1010
"main": "./lib/form_data",
1111
"browser": "./lib/browser",
1212
"scripts": {
13-
"test": "./test/run.js",
14-
"lint": "eslint lib/*.js test/*.js test/**/*.js"
13+
"pretest": "rimraf coverage test/tmp",
14+
"test": "istanbul cover --report none test/run.js && istanbul report",
15+
"lint": "eslint lib/*.js test/*.js test/**/*.js",
16+
"predebug": "rimraf coverage test/tmp",
17+
"debug": "verbose=1 ./test/run.js",
18+
"check": "istanbul check-coverage coverage/coverage*.json"
1519
},
1620
"pre-commit": [
1721
"lint",
18-
"test"
22+
"test",
23+
"check"
1924
],
2025
"engines": {
2126
"node": ">= 0.10"
@@ -27,11 +32,14 @@
2732
},
2833
"license": "MIT",
2934
"devDependencies": {
30-
"eslint": "^0.24.1",
35+
"coveralls": "^2.11.6",
36+
"eslint": "^1.10.3",
3137
"fake": "^0.2.2",
3238
"far": "^0.0.7",
3339
"formidable": "^1.0.17",
40+
"istanbul": "^0.4.1",
3441
"pre-commit": "^1.0.10",
35-
"request": "^2.60.0"
42+
"request": "^2.60.0",
43+
"rimraf": "^2.5.0"
3644
}
3745
}

test/integration/test-custom-content-type.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var FIELDS = {
1616
value: 'my_value',
1717
expectedType: 'image/png',
1818
options: {
19-
contentType: 'image/png'
19+
contentType: 'image/png'
2020
}
2121
},
2222
'default_type': {
@@ -30,7 +30,7 @@ var FIELDS = {
3030
'overridden_type': {
3131
expectedType: 'image/png',
3232
options: {
33-
contentType: 'image/png'
33+
contentType: 'image/png'
3434
},
3535
value: function(){ return fs.createReadStream(common.dir.fixture + '/unicycle.jpg'); }
3636
}

test/integration/test-http-response.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@ var remoteFile = 'http://localhost:' + common.staticPort + '/unicycle.jpg';
1313
var FIELDS;
1414
var server;
1515

16-
var parsedUrl = parseUrl(remoteFile)
17-
, options = {
18-
method: 'get',
19-
port: parsedUrl.port || 80,
20-
path: parsedUrl.pathname,
21-
host: parsedUrl.hostname
22-
}
23-
;
16+
var parsedUrl = parseUrl(remoteFile);
17+
var options = {
18+
method: 'get',
19+
port: parsedUrl.port || 80,
20+
path: parsedUrl.pathname,
21+
host: parsedUrl.hostname
22+
};
2423

2524
// request static file
2625
http.request(options, function(response) {

test/integration/test-last_boundary-line_break.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ var assert = common.assert;
44
var FormData = require(common.dir.lib + '/form_data');
55
var server;
66

7+
/**
8+
* Test submission of proper line ending
9+
*/
710
function submitForm() {
811

912
var form = new FormData();

0 commit comments

Comments
 (0)