diff --git a/.gitignore b/.gitignore index b3a0333..0b5f0e5 100644 --- a/.gitignore +++ b/.gitignore @@ -124,4 +124,5 @@ dist # yarn.lock !jest.config.js -!rollup.config.js \ No newline at end of file +!rollup.config.js +.tap \ No newline at end of file diff --git a/.taprc b/.taprc index 1939cda..f3978dc 100644 --- a/.taprc +++ b/.taprc @@ -1,9 +1 @@ -ts: true -jsx: false -flow: false -check-coverage: true -coverage: true -lines: 100 -functions: 95 -statements: 100 -branches: 99 +show-full-coverage: true diff --git a/lib/adapter/adapter.ts b/lib/adapter/adapter.ts index debb43c..b4c55da 100644 --- a/lib/adapter/adapter.ts +++ b/lib/adapter/adapter.ts @@ -54,9 +54,9 @@ export class Adapter { async next () { return { value: undefined, done: true } }, + // not able to test but good to have + /* c8 ignore next 3 */ [Symbol.asyncIterator] () { - // not able to test but good to have - /* istanbul ignore next */ return this } } diff --git a/lib/adapter/busboy.ts b/lib/adapter/busboy.ts index 3201bca..07f52a2 100644 --- a/lib/adapter/busboy.ts +++ b/lib/adapter/busboy.ts @@ -7,9 +7,9 @@ import { kIsMultipartParsed, kStorage } from '../symbols' import { Adapter, type AdapterIteratorResult, type AdapterParseReturn } from './adapter' export class BusboyAdapter extends Adapter { - #busboy: Busboy.Busboy - #storage: Storage - #removeFromBody: boolean + readonly #busboy: Busboy.Busboy + readonly #storage: Storage + readonly #removeFromBody: boolean constructor (request: FastifyRequest, option: FastifyMultipartOption) { super(request, option) @@ -77,9 +77,8 @@ export class BusboyAdapter extends Adapter { error = FST_MP_FILE_SIZE_LIMIT(name) }) // safety - /* istanbul ignore next */ + /* c8 ignore next 3 */ value.on('error', function (err) { - /* istanbul ignore next */ error = err }) // we do not consume stream here @@ -132,7 +131,7 @@ export class BusboyAdapter extends Adapter { } }, // not able to test but good to have - /* istanbul ignore next */ + /* c8 ignore next 8 */ async return () { // proper cleanup process onDone() @@ -142,7 +141,7 @@ export class BusboyAdapter extends Adapter { } }, // not able to test but good to have - /* istanbul ignore next */ + /* c8 ignore next 8 */ async throw () { // error cleanup process onDone() diff --git a/lib/adapter/formidable.ts b/lib/adapter/formidable.ts index 72e3b17..19fc923 100644 --- a/lib/adapter/formidable.ts +++ b/lib/adapter/formidable.ts @@ -9,9 +9,9 @@ import { kIsMultipartParsed, kStorage } from '../symbols' import { Adapter, type AdapterIteratorResult, type AdapterParseReturn } from './adapter' export class FormidableAdapter extends Adapter { - #formidable: IncomingForm - #storage: Storage - #removeFromBody: boolean + readonly #formidable: IncomingForm + readonly #storage: Storage + readonly #removeFromBody: boolean constructor (request: FastifyRequest, option: FastifyMultipartOption) { super(request, option) @@ -90,6 +90,8 @@ export class FormidableAdapter extends Adapter { error = FST_MP_FIELDS_LIMIT() break } + // TODO: branch test missing + /* c8 ignore next */ case 1009: case 1016: { // 1009 = max total file size @@ -103,7 +105,7 @@ export class FormidableAdapter extends Adapter { break } // safety - /* istanbul ignore next */ + /* c8 ignore next 6 */ default: { // unknown error error = FST_MP_UNEXPECTED() @@ -150,7 +152,7 @@ export class FormidableAdapter extends Adapter { } }, // not able to test but good to have - /* istanbul ignore next */ + /* c8 ignore next 8 */ async return () { // proper cleanup process onDone() @@ -160,7 +162,7 @@ export class FormidableAdapter extends Adapter { } }, // not able to test but good to have - /* istanbul ignore next */ + /* c8 ignore next 8 */ async throw () { // error cleanup process onDone() diff --git a/lib/index.ts b/lib/index.ts index 9604b37..ce3f784 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -141,7 +141,7 @@ const plugin: FastifyPluginAsync = async function (fasti return await iterator.next() }, // not able to test but good to have - /* istanbul ignore next */ + /* c8 ignore next 7 */ async return () { await iterator?.return?.() return { @@ -150,7 +150,7 @@ const plugin: FastifyPluginAsync = async function (fasti } }, // not able to test but good to have - /* istanbul ignore next */ + /* c8 ignore next 7 */ async throw (err) { await iterator?.throw?.(err) return { diff --git a/package.json b/package.json index 3d6c97a..47f2f57 100644 --- a/package.json +++ b/package.json @@ -86,25 +86,25 @@ "author": "KaKa", "license": "GPL-3.0", "devDependencies": { - "@types/busboy": "^1.5.0", - "@types/formidable": "^3.4.0", - "@types/node": "^20.4.4", - "@types/tap": "^15.0.8", - "@typescript-eslint/eslint-plugin": "5.62.0", - "@typescript-eslint/parser": "5.62.0", + "@types/busboy": "^1.5.3", + "@types/formidable": "^3.4.5", + "@types/node": "^20.10.4", + "@types/tap": "^15.0.11", + "@typescript-eslint/eslint-plugin": "6.13.2", + "@typescript-eslint/parser": "6.13.2", "busboy": "^1.6.0", - "eslint": "^8.45.0", - "eslint-config-standard-with-typescript": "^37.0.0", - "eslint-plugin-import": "^2.27.5", - "eslint-plugin-n": "^16.0.1", + "eslint": "^8.55.0", + "eslint-config-standard-with-typescript": "^42.0.0", + "eslint-plugin-import": "^2.29.0", + "eslint-plugin-n": "^16.4.0", "eslint-plugin-promise": "^6.1.1", - "fastify": "^4.20.0", - "formidable": "^3.5.0", - "tap": "^16.3.7", - "ts-node": "^10.9.1", - "tsc-alias": "^1.8.7", - "typescript": "~5.1.6", - "undici": "^5.22.1" + "fastify": "^4.24.3", + "formidable": "^3.5.1", + "tap": "^18.6.1", + "ts-node": "^10.9.2", + "tsc-alias": "^1.8.8", + "typescript": "~5.3.3", + "undici": "^6.0.1" }, "dependencies": { "fastify-plugin": "^4.5.1"