diff --git a/README.md b/README.md index c38ed06..402b706 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![CI](https://github.com/fastify/fastify-compress/workflows/CI/badge.svg) [![NPM version](https://img.shields.io/npm/v/@fastify/compress.svg?style=flat)](https://www.npmjs.com/package/@fastify/compress) -[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/) +[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard) Adds compression utils to [the Fastify `reply` object](https://fastify.dev/docs/latest/Reference/Reply/#reply) and a hook to decompress requests payloads. Supports `gzip`, `deflate`, and `brotli`. diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..89fd678 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,6 @@ +'use strict' + +module.exports = require('neostandard')({ + ignores: require('neostandard').resolveIgnoresFromGitignore(), + ts: true +}) diff --git a/package.json b/package.json index 8db8794..54e6bd0 100644 --- a/package.json +++ b/package.json @@ -18,20 +18,17 @@ "devDependencies": { "@fastify/pre-commit": "^2.1.0", "@types/node": "^22.0.0", - "@typescript-eslint/eslint-plugin": "^7.6.0", - "@typescript-eslint/parser": "^7.6.0", "adm-zip": "^0.5.12", "c8": "^10.1.2", "fastify": "^5.0.0", "jsonstream": "^1.0.3", - "standard": "^17.1.0", + "neostandard": "^0.11.9", "tsd": "^0.31.0", "typescript": "~5.7.2" }, "scripts": { - "lint": "standard", - "lint:fix": "npm run lint -- --fix", - "lint:fix:typescript": "npm run lint:fix -- --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin \"**/*.d.ts\"", + "lint": "eslint", + "lint:fix": "eslint --fix", "test": "npm run test:unit && npm run test:typescript", "test:typescript": "tsd", "test:unit": "node --test", diff --git a/types/index.d.ts b/types/index.d.ts index 24bcbe0..ad871df 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -5,9 +5,9 @@ import { RouteOptions as FastifyRouteOptions, RawServerBase, RawServerDefault -} from 'fastify'; -import { Stream } from 'stream'; -import { BrotliOptions, ZlibOptions } from 'zlib'; +} from 'fastify' +import { Stream } from 'stream' +import { BrotliOptions, ZlibOptions } from 'zlib' declare module 'fastify' { export interface FastifyContextConfig { @@ -18,6 +18,7 @@ declare module 'fastify' { } export interface RouteShorthandOptions< + // eslint-disable-next-line @typescript-eslint/no-unused-vars RawServer extends RawServerBase = RawServerDefault > { compress?: RouteCompressOptions | false; @@ -56,9 +57,9 @@ type RouteDecompressOptions = Pick -type EncodingToken = 'br' | 'deflate' | 'gzip' | 'identity'; +type EncodingToken = 'br' | 'deflate' | 'gzip' | 'identity' -type CompressibleContentTypeFunction = (contentType: string) => boolean; +type CompressibleContentTypeFunction = (contentType: string) => boolean type Input = | Buffer @@ -66,7 +67,7 @@ type Input = | ArrayBuffer | string | Iterable - | AsyncIterable; + | AsyncIterable declare namespace fastifyCompress { @@ -105,5 +106,5 @@ declare namespace fastifyCompress { export { fastifyCompress as default } } -declare function fastifyCompress(...params: Parameters): ReturnType +declare function fastifyCompress (...params: Parameters): ReturnType export = fastifyCompress diff --git a/types/index.test-d.ts b/types/index.test-d.ts index 959709e..38384e1 100644 --- a/types/index.test-d.ts +++ b/types/index.test-d.ts @@ -9,7 +9,7 @@ const stream = createReadStream('./package.json') const withGlobalOptions: FastifyCompressOptions = { global: true, threshold: 10, - zlib: zlib, + zlib, brotliOptions: { params: { [zlib.constants.BROTLI_PARAM_MODE]: zlib.constants.BROTLI_MODE_TEXT,