diff --git a/README.md b/README.md index 642c030..11b1db0 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![CI](https://github.com/fastify/fastify-basic-auth/workflows/CI/badge.svg?branch=master) [![NPM version](https://img.shields.io/npm/v/@fastify/basic-auth.svg?style=flat)](https://www.npmjs.com/package/@fastify/basic-auth) -[![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) A simple basic auth plugin for Fastify. 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 ba6729c..c8b9797 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "type": "commonjs", "types": "types/index.d.ts", "scripts": { - "lint": "standard", + "lint": "eslint", + "lint:fix": "eslint --fix", "test": "npm run test:unit && npm run test:types", "test:unit": "c8 --100 node --test", "test:types": "tsd" @@ -34,7 +35,7 @@ "@types/node": "^22.0.0", "c8": "^10.1.2", "fastify": "^5.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 8cc9b35..01c307e 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -38,5 +38,5 @@ declare namespace fastifyBasicAuth { export { fastifyBasicAuth as default } } -declare function fastifyBasicAuth(...params: Parameters): ReturnType +declare function fastifyBasicAuth (...params: Parameters): ReturnType export = fastifyBasicAuth diff --git a/types/index.test-d.ts b/types/index.test-d.ts index 09a3b4c..af291fe 100644 --- a/types/index.test-d.ts +++ b/types/index.test-d.ts @@ -11,7 +11,7 @@ import fastifyBasicAuth from '..' const app = fastify() -//validation ok +// validation ok app.register(fastifyBasicAuth, { validate: async function validatePromise (username, password, req, reply) { expectType(username) @@ -23,7 +23,7 @@ app.register(fastifyBasicAuth, { header: 'x-forwarded-authorization' }) -//validation failure +// validation failure app.register(fastifyBasicAuth, { validate: async function validatePromise (username, password, req, reply) { expectType(username) @@ -31,7 +31,7 @@ app.register(fastifyBasicAuth, { expectType(req) expectType(reply) expectType(this) - return new Error("unauthorized") + return new Error('unauthorized') }, header: 'x-forwarded-authorization' }) @@ -47,24 +47,26 @@ app.register(fastifyBasicAuth, { } }) -//authenticate boolean +// authenticate boolean app.register(fastifyBasicAuth, { validate: () => {}, authenticate: true }) -//authenticate with realm +// authenticate with realm app.register(fastifyBasicAuth, { validate: () => {}, authenticate: { realm: 'example' } }) -//authenticate with realm (function) +// authenticate with realm (function) app.register(fastifyBasicAuth, { validate: () => {}, - authenticate: { realm: function realm(req) { - return req.url - }} + authenticate: { + realm: function realm (req) { + return req.url + } + } }) app.register(fastifyBasicAuth, {