diff --git a/README.md b/README.md index 8cb10d3..80ed58a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![CI](https://github.com/fastify/fastify-routes/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/fastify/fastify-routes/actions/workflows/ci.yml) [![NPM version](https://img.shields.io/npm/v/@fastify/routes.svg?style=flat)](https://www.npmjs.com/package/@fastify/routes) -[![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) This plugin decorates a Fastify instance with `routes`, which is a [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) of registered routes. Note that you have to await the registration of this plugin before registering any routes so that @fastify/routes can collect them. 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 8d951e5..357d1d4 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "type": "commonjs", "types": "types/index.d.ts", "scripts": { - "lint": "standard | snazzy", + "lint": "eslint", + "lint:fix": "eslint --fix", "test": "npm run test:unit && npm run test:typescript", "test:unit": "c8 --100 node --test", "test:typescript": "tsd" @@ -33,8 +34,7 @@ "@types/node": "^22.0.0", "c8": "^10.1.2", "fastify": "^5.0.0", - "snazzy": "^9.0.0", - "standard": "^17.1.0", + "neostandard": "^0.11.9", "tsd": "^0.31.1" }, "dependencies": { diff --git a/types/index.d.ts b/types/index.d.ts index dc93c16..5977c85 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,19 +1,19 @@ /// -import { RouteOptions, FastifyPluginCallback } from "fastify"; +import { RouteOptions, FastifyPluginCallback } from 'fastify' -declare module "fastify" { +declare module 'fastify' { interface FastifyInstance { routes: fastifyRoutes.FastifyRoutes; } } declare namespace fastifyRoutes { - export type FastifyRoutes = Map; + export type FastifyRoutes = Map export const fastifyRoutes: FastifyPluginCallback export { fastifyRoutes as default } } -declare function fastifyRoutes(...params: Parameters): ReturnType +declare function fastifyRoutes (...params: Parameters): ReturnType export = fastifyRoutes diff --git a/types/index.test-d.ts b/types/index.test-d.ts index e602a01..4cab946 100644 --- a/types/index.test-d.ts +++ b/types/index.test-d.ts @@ -2,28 +2,25 @@ import fastify, { FastifyInstance, FastifyPluginCallback, RouteOptions, -} from "fastify"; -import { expectAssignable, expectError, expectType } from "tsd"; +} from 'fastify' +import { expectAssignable, expectError, expectType } from 'tsd' -import fastifyRoutes, { FastifyRoutes } from ".."; +import fastifyRoutes, { FastifyRoutes } from '..' +const app: FastifyInstance = fastify() +app.register(fastifyRoutes) - -const app: FastifyInstance = fastify(); -app.register(fastifyRoutes); - -expectType(fastifyRoutes); - +expectType(fastifyRoutes) expectError( app.register(fastifyRoutes, { - unknownOption: "this should trigger a typescript error", + unknownOption: 'this should trigger a typescript error', }) -); +) // Plugin property available app.after(() => { - expectType(app.routes); + expectType(app.routes) - expectAssignable(app.routes.get("/rotue")); -}); + expectAssignable(app.routes.get('/rotue')) +})