Skip to content

Commit

Permalink
lint: apply standard 14 style
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Sep 5, 2019
1 parent 51ff9d4 commit bc6effd
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 91 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
"type-is": "~1.6.18"
},
"devDependencies": {
"eslint": "6.1.0",
"eslint-config-standard": "13.0.1",
"eslint": "6.3.0",
"eslint-config-standard": "14.1.0",
"eslint-plugin-import": "2.18.2",
"eslint-plugin-markdown": "1.0.0",
"eslint-plugin-node": "9.1.0",
"eslint-plugin-node": "9.2.0",
"eslint-plugin-promise": "4.2.1",
"eslint-plugin-standard": "4.0.0",
"eslint-plugin-standard": "4.0.1",
"istanbul": "0.4.5",
"methods": "1.1.2",
"mocha": "6.2.0",
Expand Down
16 changes: 10 additions & 6 deletions test/body-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,11 @@ describe('bodyParser()', function () {

describe('with verify option', function () {
it('should apply to json', function (done) {
var server = createServer({ verify: function (req, res, buf) {
if (buf[0] === 0x20) throw new Error('no leading space')
} })
var server = createServer({
verify: function (req, res, buf) {
if (buf[0] === 0x20) throw new Error('no leading space')
}
})

request(server)
.post('/')
Expand All @@ -126,9 +128,11 @@ describe('bodyParser()', function () {
})

it('should apply to urlencoded', function (done) {
var server = createServer({ verify: function (req, res, buf) {
if (buf[0] === 0x20) throw new Error('no leading space')
} })
var server = createServer({
verify: function (req, res, buf) {
if (buf[0] === 0x20) throw new Error('no leading space')
}
})

request(server)
.post('/')
Expand Down
76 changes: 46 additions & 30 deletions test/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,11 @@ describe('bodyParser.json()', function () {
})

it('should error from verify', function (done) {
var server = createServer({ verify: function (req, res, buf) {
if (buf[0] === 0x5b) throw new Error('no arrays')
} })
var server = createServer({
verify: function (req, res, buf) {
if (buf[0] === 0x5b) throw new Error('no arrays')
}
})

request(server)
.post('/')
Expand All @@ -402,9 +404,11 @@ describe('bodyParser.json()', function () {
})

it('should error with type = "entity.verify.failed"', function (done) {
var server = createServer({ verify: function (req, res, buf) {
if (buf[0] === 0x5b) throw new Error('no arrays')
} })
var server = createServer({
verify: function (req, res, buf) {
if (buf[0] === 0x5b) throw new Error('no arrays')
}
})

request(server)
.post('/')
Expand All @@ -415,12 +419,14 @@ describe('bodyParser.json()', function () {
})

it('should allow custom codes', function (done) {
var server = createServer({ verify: function (req, res, buf) {
if (buf[0] !== 0x5b) return
var err = new Error('no arrays')
err.status = 400
throw err
} })
var server = createServer({
verify: function (req, res, buf) {
if (buf[0] !== 0x5b) return
var err = new Error('no arrays')
err.status = 400
throw err
}
})

request(server)
.post('/')
Expand All @@ -430,12 +436,14 @@ describe('bodyParser.json()', function () {
})

it('should allow custom type', function (done) {
var server = createServer({ verify: function (req, res, buf) {
if (buf[0] !== 0x5b) return
var err = new Error('no arrays')
err.type = 'foo.bar'
throw err
} })
var server = createServer({
verify: function (req, res, buf) {
if (buf[0] !== 0x5b) return
var err = new Error('no arrays')
err.type = 'foo.bar'
throw err
}
})

request(server)
.post('/')
Expand All @@ -446,9 +454,11 @@ describe('bodyParser.json()', function () {
})

it('should include original body on error object', function (done) {
var server = createServer({ verify: function (req, res, buf) {
if (buf[0] === 0x5b) throw new Error('no arrays')
} })
var server = createServer({
verify: function (req, res, buf) {
if (buf[0] === 0x5b) throw new Error('no arrays')
}
})

request(server)
.post('/')
Expand All @@ -459,9 +469,11 @@ describe('bodyParser.json()', function () {
})

it('should allow pass-through', function (done) {
var server = createServer({ verify: function (req, res, buf) {
if (buf[0] === 0x5b) throw new Error('no arrays')
} })
var server = createServer({
verify: function (req, res, buf) {
if (buf[0] === 0x5b) throw new Error('no arrays')
}
})

request(server)
.post('/')
Expand All @@ -471,9 +483,11 @@ describe('bodyParser.json()', function () {
})

it('should work with different charsets', function (done) {
var server = createServer({ verify: function (req, res, buf) {
if (buf[0] === 0x5b) throw new Error('no arrays')
} })
var server = createServer({
verify: function (req, res, buf) {
if (buf[0] === 0x5b) throw new Error('no arrays')
}
})

var test = request(server).post('/')
test.set('Content-Type', 'application/json; charset=utf-16')
Expand All @@ -482,9 +496,11 @@ describe('bodyParser.json()', function () {
})

it('should 415 on unknown charset prior to verify', function (done) {
var server = createServer({ verify: function (req, res, buf) {
throw new Error('unexpected verify call')
} })
var server = createServer({
verify: function (req, res, buf) {
throw new Error('unexpected verify call')
}
})

var test = request(server).post('/')
test.set('Content-Type', 'application/json; charset=x-bogus')
Expand Down
30 changes: 18 additions & 12 deletions test/raw.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,11 @@ describe('bodyParser.raw()', function () {
})

it('should error from verify', function (done) {
var server = createServer({ verify: function (req, res, buf) {
if (buf[0] === 0x00) throw new Error('no leading null')
} })
var server = createServer({
verify: function (req, res, buf) {
if (buf[0] === 0x00) throw new Error('no leading null')
}
})

var test = request(server).post('/')
test.set('Content-Type', 'application/octet-stream')
Expand All @@ -259,12 +261,14 @@ describe('bodyParser.raw()', function () {
})

it('should allow custom codes', function (done) {
var server = createServer({ verify: function (req, res, buf) {
if (buf[0] !== 0x00) return
var err = new Error('no leading null')
err.status = 400
throw err
} })
var server = createServer({
verify: function (req, res, buf) {
if (buf[0] !== 0x00) return
var err = new Error('no leading null')
err.status = 400
throw err
}
})

var test = request(server).post('/')
test.set('Content-Type', 'application/octet-stream')
Expand All @@ -273,9 +277,11 @@ describe('bodyParser.raw()', function () {
})

it('should allow pass-through', function (done) {
var server = createServer({ verify: function (req, res, buf) {
if (buf[0] === 0x00) throw new Error('no leading null')
} })
var server = createServer({
verify: function (req, res, buf) {
if (buf[0] === 0x00) throw new Error('no leading null')
}
})

var test = request(server).post('/')
test.set('Content-Type', 'application/octet-stream')
Expand Down
38 changes: 23 additions & 15 deletions test/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,11 @@ describe('bodyParser.text()', function () {
})

it('should error from verify', function (done) {
var server = createServer({ verify: function (req, res, buf) {
if (buf[0] === 0x20) throw new Error('no leading space')
} })
var server = createServer({
verify: function (req, res, buf) {
if (buf[0] === 0x20) throw new Error('no leading space')
}
})

request(server)
.post('/')
Expand All @@ -283,12 +285,14 @@ describe('bodyParser.text()', function () {
})

it('should allow custom codes', function (done) {
var server = createServer({ verify: function (req, res, buf) {
if (buf[0] !== 0x20) return
var err = new Error('no leading space')
err.status = 400
throw err
} })
var server = createServer({
verify: function (req, res, buf) {
if (buf[0] !== 0x20) return
var err = new Error('no leading space')
err.status = 400
throw err
}
})

request(server)
.post('/')
Expand All @@ -298,9 +302,11 @@ describe('bodyParser.text()', function () {
})

it('should allow pass-through', function (done) {
var server = createServer({ verify: function (req, res, buf) {
if (buf[0] === 0x20) throw new Error('no leading space')
} })
var server = createServer({
verify: function (req, res, buf) {
if (buf[0] === 0x20) throw new Error('no leading space')
}
})

request(server)
.post('/')
Expand All @@ -310,9 +316,11 @@ describe('bodyParser.text()', function () {
})

it('should 415 on unknown charset prior to verify', function (done) {
var server = createServer({ verify: function (req, res, buf) {
throw new Error('unexpected verify call')
} })
var server = createServer({
verify: function (req, res, buf) {
throw new Error('unexpected verify call')
}
})

var test = request(server).post('/')
test.set('Content-Type', 'text/plain; charset=x-bogus')
Expand Down
60 changes: 36 additions & 24 deletions test/urlencoded.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,11 @@ describe('bodyParser.urlencoded()', function () {
})

it('should error from verify', function (done) {
var server = createServer({ verify: function (req, res, buf) {
if (buf[0] === 0x20) throw new Error('no leading space')
} })
var server = createServer({
verify: function (req, res, buf) {
if (buf[0] === 0x20) throw new Error('no leading space')
}
})

request(server)
.post('/')
Expand All @@ -531,9 +533,11 @@ describe('bodyParser.urlencoded()', function () {
})

it('should error with type = "entity.verify.failed"', function (done) {
var server = createServer({ verify: function (req, res, buf) {
if (buf[0] === 0x20) throw new Error('no leading space')
} })
var server = createServer({
verify: function (req, res, buf) {
if (buf[0] === 0x20) throw new Error('no leading space')
}
})

request(server)
.post('/')
Expand All @@ -544,12 +548,14 @@ describe('bodyParser.urlencoded()', function () {
})

it('should allow custom codes', function (done) {
var server = createServer({ verify: function (req, res, buf) {
if (buf[0] !== 0x20) return
var err = new Error('no leading space')
err.status = 400
throw err
} })
var server = createServer({
verify: function (req, res, buf) {
if (buf[0] !== 0x20) return
var err = new Error('no leading space')
err.status = 400
throw err
}
})

request(server)
.post('/')
Expand All @@ -559,12 +565,14 @@ describe('bodyParser.urlencoded()', function () {
})

it('should allow custom type', function (done) {
var server = createServer({ verify: function (req, res, buf) {
if (buf[0] !== 0x20) return
var err = new Error('no leading space')
err.type = 'foo.bar'
throw err
} })
var server = createServer({
verify: function (req, res, buf) {
if (buf[0] !== 0x20) return
var err = new Error('no leading space')
err.type = 'foo.bar'
throw err
}
})

request(server)
.post('/')
Expand All @@ -575,9 +583,11 @@ describe('bodyParser.urlencoded()', function () {
})

it('should allow pass-through', function (done) {
var server = createServer({ verify: function (req, res, buf) {
if (buf[0] === 0x5b) throw new Error('no arrays')
} })
var server = createServer({
verify: function (req, res, buf) {
if (buf[0] === 0x5b) throw new Error('no arrays')
}
})

request(server)
.post('/')
Expand All @@ -587,9 +597,11 @@ describe('bodyParser.urlencoded()', function () {
})

it('should 415 on unknown charset prior to verify', function (done) {
var server = createServer({ verify: function (req, res, buf) {
throw new Error('unexpected verify call')
} })
var server = createServer({
verify: function (req, res, buf) {
throw new Error('unexpected verify call')
}
})

var test = request(server).post('/')
test.set('Content-Type', 'application/x-www-form-urlencoded; charset=x-bogus')
Expand Down

0 comments on commit bc6effd

Please sign in to comment.