diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 62562b74..00000000 --- a/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -coverage -node_modules diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index 3c0a49d9..00000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,12 +0,0 @@ -root: true -extends: - - standard - - plugin:markdown/recommended -plugins: - - markdown -overrides: - - files: '**/*.md' - processor: 'markdown/markdown' -rules: - no-param-reassign: error - no-var: error diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000..64ff479d --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,3 @@ +import neostandard from 'neostandard' + +export default [...neostandard({ ignores: ['coverage'] })] diff --git a/lib/read.js b/lib/read.js index 7683ae4c..76adb086 100644 --- a/lib/read.js +++ b/lib/read.js @@ -144,7 +144,7 @@ function read (req, res, next, parse, debug, options) { verify(req, res, body, encoding) } catch (err) { next(createError(403, err, { - body: body, + body, type: err.type || 'entity.verify.failed' })) return @@ -188,7 +188,7 @@ function contentstream (req, debug, inflate) { if (inflate === false && encoding !== 'identity') { throw createError(415, 'content encoding unsupported', { - encoding: encoding, + encoding, type: 'encoding.unsupported' }) } @@ -223,7 +223,7 @@ function createDecompressionStream (encoding, debug) { return zlib.createBrotliDecompress() default: throw createError(415, 'unsupported content encoding "' + encoding + '"', { - encoding: encoding, + encoding, type: 'encoding.unsupported' }) } diff --git a/lib/types/urlencoded.js b/lib/types/urlencoded.js index 1db964cb..d462225b 100644 --- a/lib/types/urlencoded.js +++ b/lib/types/urlencoded.js @@ -98,12 +98,12 @@ function createQueryParser (options) { try { return qs.parse(body, { allowPrototypes: true, - arrayLimit: arrayLimit, - depth: depth, - charsetSentinel: charsetSentinel, - interpretNumericEntities: interpretNumericEntities, + arrayLimit, + depth, + charsetSentinel, + interpretNumericEntities, charset: encoding, - parameterLimit: parameterLimit, + parameterLimit, strictDepth: true }) } catch (err) { diff --git a/package.json b/package.json index 842cfbdb..2171237a 100644 --- a/package.json +++ b/package.json @@ -37,14 +37,9 @@ "type-is": "^2.1.0" }, "devDependencies": { - "eslint": "^8.57.1", - "eslint-config-standard": "^14.1.1", - "eslint-plugin-import": "^2.32.0", - "eslint-plugin-markdown": "^3.0.1", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^6.6.0", - "eslint-plugin-standard": "^4.1.0", + "eslint": "^9.39.5", "mocha": "^11.7.6", + "neostandard": "^0.13.0", "nyc": "^17.1.0", "supertest": "^7.2.2" }, diff --git a/test/body-parser.js b/test/body-parser.js index 32438081..09ef0def 100644 --- a/test/body-parser.js +++ b/test/body-parser.js @@ -1,5 +1,6 @@ 'use strict' +const { describe, it } = require('mocha') const assert = require('node:assert') const bodyParser = require('..') diff --git a/test/json.js b/test/json.js index b2a9e149..2ca8a2ce 100644 --- a/test/json.js +++ b/test/json.js @@ -1,5 +1,6 @@ 'use strict' +const { describe, it, before } = require('mocha') const assert = require('node:assert') const AsyncLocalStorage = require('node:async_hooks').AsyncLocalStorage const http = require('node:http') diff --git a/test/raw.js b/test/raw.js index da952a8c..51ec3a0a 100644 --- a/test/raw.js +++ b/test/raw.js @@ -1,5 +1,6 @@ 'use strict' +const { describe, it, before } = require('mocha') const assert = require('node:assert') const AsyncLocalStorage = require('node:async_hooks').AsyncLocalStorage const http = require('node:http') diff --git a/test/text.js b/test/text.js index f2a151d0..1e9561c0 100644 --- a/test/text.js +++ b/test/text.js @@ -1,5 +1,6 @@ 'use strict' +const { describe, it, before } = require('mocha') const assert = require('node:assert') const AsyncLocalStorage = require('node:async_hooks').AsyncLocalStorage const http = require('node:http') diff --git a/test/urlencoded.js b/test/urlencoded.js index 50ff747c..52c7c129 100644 --- a/test/urlencoded.js +++ b/test/urlencoded.js @@ -1,5 +1,6 @@ 'use strict' +const { describe, it, before } = require('mocha') const assert = require('node:assert') const AsyncLocalStorage = require('node:async_hooks').AsyncLocalStorage const http = require('node:http') @@ -51,7 +52,7 @@ describe('bodyParser.urlencoded()', function () { extendedValues.forEach(function (extended) { describe('in ' + (extended ? 'extended' : 'simple') + ' mode', function () { it('should parse x-www-form-urlencoded with an explicit iso-8859-1 encoding', function (done) { - const server = createServer({ extended: extended }) + const server = createServer({ extended }) request(server) .post('/') .set('Content-Type', 'application/x-www-form-urlencoded; charset=iso-8859-1') @@ -60,7 +61,7 @@ describe('bodyParser.urlencoded()', function () { }) it('should parse x-www-form-urlencoded with unspecified iso-8859-1 encoding when the defaultCharset is set to iso-8859-1', function (done) { - const server = createServer({ defaultCharset: 'iso-8859-1', extended: extended }) + const server = createServer({ defaultCharset: 'iso-8859-1', extended }) request(server) .post('/') .set('Content-Type', 'application/x-www-form-urlencoded') @@ -69,7 +70,7 @@ describe('bodyParser.urlencoded()', function () { }) it('should parse x-www-form-urlencoded with an unspecified iso-8859-1 encoding when the utf8 sentinel has a value of %26%2310003%3B', function (done) { - const server = createServer({ charsetSentinel: true, extended: extended }) + const server = createServer({ charsetSentinel: true, extended }) request(server) .post('/') .set('Content-Type', 'application/x-www-form-urlencoded') @@ -78,7 +79,7 @@ describe('bodyParser.urlencoded()', function () { }) it('should parse x-www-form-urlencoded with an unspecified utf-8 encoding when the utf8 sentinel has a value of %E2%9C%93 and the defaultCharset is iso-8859-1', function (done) { - const server = createServer({ charsetSentinel: true, extended: extended }) + const server = createServer({ charsetSentinel: true, extended }) request(server) .post('/') .set('Content-Type', 'application/x-www-form-urlencoded') @@ -87,7 +88,7 @@ describe('bodyParser.urlencoded()', function () { }) it('should not leave an empty string parameter when removing the utf8 sentinel from the start of the string', function (done) { - const server = createServer({ charsetSentinel: true, extended: extended }) + const server = createServer({ charsetSentinel: true, extended }) request(server) .post('/') .set('Content-Type', 'application/x-www-form-urlencoded') @@ -96,7 +97,7 @@ describe('bodyParser.urlencoded()', function () { }) it('should not leave an empty string parameter when removing the utf8 sentinel from the middle of the string', function (done) { - const server = createServer({ charsetSentinel: true, extended: extended }) + const server = createServer({ charsetSentinel: true, extended }) request(server) .post('/') .set('Content-Type', 'application/x-www-form-urlencoded') @@ -105,7 +106,7 @@ describe('bodyParser.urlencoded()', function () { }) it('should not leave an empty string parameter when removing the utf8 sentinel from the end of the string', function (done) { - const server = createServer({ charsetSentinel: true, extended: extended }) + const server = createServer({ charsetSentinel: true, extended }) request(server) .post('/') .set('Content-Type', 'application/x-www-form-urlencoded') diff --git a/test/utils.js b/test/utils.js index 62b9b1e6..068ec06d 100644 --- a/test/utils.js +++ b/test/utils.js @@ -1,5 +1,6 @@ 'use strict' +const { describe, it } = require('mocha') const assert = require('node:assert') const { normalizeOptions } = require('../lib/utils.js')