diff --git a/README.md b/README.md
index 43a6517..20f4462 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
[![CI](https://github.com/fastify/fastify-sensible/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/fastify/fastify-sensible/actions/workflows/ci.yml)
[![NPM version](https://img.shields.io/npm/v/@fastify/sensible.svg?style=flat)](https://www.npmjs.com/package/@fastify/sensible)
-[![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)
Defaults for Fastify that everyone can agree on™.
This plugin adds some useful utilities to your Fastify instance, see the API section to learn more.
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/lib/httpError.d.ts b/lib/httpError.d.ts
index 08649e4..a66a966 100644
--- a/lib/httpError.d.ts
+++ b/lib/httpError.d.ts
@@ -1,14 +1,15 @@
export declare class HttpError extends Error {
- status: N;
- statusCode: N;
- expose: boolean;
+ status: N
+ statusCode: N
+ expose: boolean
headers?: {
[key: string]: string;
};
+
[key: string]: any;
}
-type UnknownError = Error | string | number | { [key: string]: any };
+type UnknownError = Error | string | number | { [key: string]: any }
export type HttpErrorCodes = 400 | '400' // BadRequest
| 401 | '401' // Unauthorized
@@ -92,13 +93,14 @@ export type HttpErrorNames = 'badRequest'
| 'loopDetected'
| 'bandwidthLimitExceeded'
| 'notExtended'
- | 'networkAuthenticationRequired';
+ | 'networkAuthenticationRequired'
export type HttpErrors = {
HttpError: typeof HttpError;
getHttpError: (code: HttpErrorCodes, message?: string) => HttpError;
createError: (...args: UnknownError[]) => HttpError;
-} & Record HttpError>;
+} & Record HttpError>
+// eslint-disable-next-line @typescript-eslint/no-redeclare
declare const HttpErrors: HttpErrors
-export default HttpErrors;
+export default HttpErrors
diff --git a/package.json b/package.json
index 7c8d7ca..6e29cf8 100644
--- a/package.json
+++ b/package.json
@@ -6,8 +6,8 @@
"type": "commonjs",
"types": "types/index.d.ts",
"scripts": {
- "lint": "standard",
- "lint:fix": "standard --fix",
+ "lint": "eslint",
+ "lint:fix": "eslint --fix",
"test": "npm run test:unit && npm run test:typescript",
"test:typescript": "tsd",
"test:unit": "tap"
@@ -31,8 +31,9 @@
"devDependencies": {
"@fastify/pre-commit": "^2.1.0",
"@types/node": "^22.0.0",
+ "eslint": "^9.17.0",
"fastify": "^5.0.0",
- "standard": "^17.1.0",
+ "neostandard": "^0.12.0",
"tap": "^18.7.1",
"tsd": "^0.31.0"
},
diff --git a/types/index.d.ts b/types/index.d.ts
index b4861d9..a656865 100644
--- a/types/index.d.ts
+++ b/types/index.d.ts
@@ -1,5 +1,5 @@
-import { FastifyPluginCallback, FastifyReply } from 'fastify'
-import { HttpErrors, HttpError } from "../lib/httpError"
+import { FastifyPluginCallback, FastifyReply } from 'fastify'
+import { HttpErrors, HttpError } from '../lib/httpError'
import * as Errors from '../lib/httpError'
type FastifySensible = FastifyPluginCallback
@@ -24,7 +24,7 @@ type staleTypes = 'while-revalidate' | 'if-error'
declare module 'fastify' {
namespace SensibleTypes {
- type ToType = [Error, T];
+ type ToType = [Error, T]
}
interface Assert {
@@ -89,11 +89,11 @@ declare namespace fastifySensible {
sharedSchemaId?: string;
}
- export { HttpError };
+ export { HttpError }
- export type HttpErrors = Errors.HttpErrors;
- export type HttpErrorCodes = Errors.HttpErrorCodes;
- export type HttpErrorNames = Errors.HttpErrorNames;
+ export type HttpErrors = Errors.HttpErrors
+ export type HttpErrorCodes = Errors.HttpErrorCodes
+ export type HttpErrorNames = Errors.HttpErrorNames
export const httpErrors: typeof Errors.default
@@ -105,5 +105,5 @@ declare namespace fastifySensible {
export { fastifySensible as default }
}
-declare function fastifySensible(...params: Parameters): ReturnType
+declare function fastifySensible (...params: Parameters): ReturnType
export = fastifySensible
diff --git a/types/index.test-d.ts b/types/index.test-d.ts
index b572d62..6d129ea 100644
--- a/types/index.test-d.ts
+++ b/types/index.test-d.ts
@@ -6,9 +6,9 @@ const app = fastify()
app.register(fastifySensible)
-expectAssignable({});
-expectAssignable({ sharedSchemaId: 'HttpError' });
-expectNotAssignable({ notSharedSchemaId: 'HttpError' });
+expectAssignable({})
+expectAssignable({ sharedSchemaId: 'HttpError' })
+expectNotAssignable({ notSharedSchemaId: 'HttpError' })
app.get('/', (req, reply) => {
expectAssignable(reply.badRequest())
@@ -60,13 +60,12 @@ app.get('/', (req, reply) => {
expectAssignable(app.httpErrors.createError(405, 'Method Not Allowed'))
})
-app.get("/", (req, reply) => {
+app.get('/', (req, reply) => {
expectAssignable(
- app.httpErrors.createError(405, "Method Not Allowed"),
- );
- expectAssignable(app.httpErrors.badRequest());
-});
-
+ app.httpErrors.createError(405, 'Method Not Allowed')
+ )
+ expectAssignable(app.httpErrors.badRequest())
+})
app.get('/', async (req, reply) => {
expectAssignable(app.httpErrors.badRequest())
@@ -158,5 +157,5 @@ app.get('/', async (req, reply) => {
expectType(req.is('foo', 'bar'))
})
-httpErrors.forbidden('This type should be also available');
-httpErrors.createError('MyError');
+httpErrors.forbidden('This type should be also available')
+httpErrors.createError('MyError')