From f242ace5d7342d631fc5401632fcee8a5735a7a4 Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Thu, 28 Nov 2024 15:38:23 +0000 Subject: [PATCH] build(deps-dev): replace standard with neostandard --- README.md | 2 +- eslint.config.js | 6 +++ package.json | 6 +-- types/index.d.ts | 22 ++++---- types/index.test-d.ts | 113 +++++++++++++++++++++--------------------- 5 files changed, 77 insertions(+), 72 deletions(-) create mode 100644 eslint.config.js diff --git a/README.md b/README.md index dbfaad5..70942ff 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![CI](https://github.com/fastify/fastify-accepts/workflows/CI/badge.svg) [![NPM version](https://img.shields.io/npm/v/@fastify/accepts.svg?style=flat)](https://www.npmjs.com/package/@fastify/accepts) -[![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) Add an accepts parser to 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 347c88c..7dd4e7d 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,8 @@ "@fastify/pre-commit": "^2.1.0", "@types/node": "^22.0.0", "fastify": "^5.0.0", + "neostandard": "^0.11.9", "request": "^2.88.0", - "snazzy": "^9.0.0", - "standard": "^17.1.0", "tap": "^20.0.1", "tsd": "^0.31.1" }, @@ -20,7 +19,8 @@ "fastify-plugin": "^5.0.0" }, "scripts": { - "lint": "standard | snazzy", + "lint": "eslint", + "lint:fix": "eslint --fix", "test": "npm run test:unit && npm run test:typescript", "test:typescript": "tsd", "test:unit": "tap" diff --git a/types/index.d.ts b/types/index.d.ts index 7c59dce..c3258f1 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,6 +1,6 @@ -import { FastifyPluginCallback } from "fastify" +import { FastifyPluginCallback } from 'fastify' -declare module "fastify" { +declare module 'fastify' { // Copied from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/accepts/index.d.ts // Definitions by: Stefan Reichel // Brice BERNARD @@ -95,14 +95,14 @@ declare module "fastify" { interface FastifyReply { requestAccepts(): Accepts - requestCharset: Accepts["charset"] - requestCharsets: Accepts["charsets"] - requestEncoding: Accepts["encoding"] - requestEncodings: Accepts["charsets"] - requestLanguage: Accepts["language"] - requestLanguages: Accepts["languages"] - requestType: Accepts["type"] - requestTypes: Accepts["types"] + requestCharset: Accepts['charset'] + requestCharsets: Accepts['charsets'] + requestEncoding: Accepts['encoding'] + requestEncodings: Accepts['charsets'] + requestLanguage: Accepts['language'] + requestLanguages: Accepts['languages'] + requestType: Accepts['type'] + requestTypes: Accepts['types'] } } type FastifyAccepts = FastifyPluginCallback @@ -116,5 +116,5 @@ declare namespace fastifyAccepts { export { fastifyAccepts as default } } -declare function fastifyAccepts(...params: Parameters): ReturnType +declare function fastifyAccepts (...params: Parameters): ReturnType export = fastifyAccepts diff --git a/types/index.test-d.ts b/types/index.test-d.ts index 32f97a6..3cc353d 100644 --- a/types/index.test-d.ts +++ b/types/index.test-d.ts @@ -1,32 +1,32 @@ -import fastify from "fastify" -import accepts from ".." +import fastify from 'fastify' +import accepts from '..' const app = fastify() app.register(accepts) -app.get("/", (request, reply) => { - const accept = request.accepts(); +app.get('/', (request, reply) => { + const accept = request.accepts() - const charsets = accept.charsets(); - const charsetFromEmpty = accept.charset(); - const charsetFromParams = accept.charset("json", "text"); - const charsetFromArray = accept.charset(["json", "text"]); + const charsets = accept.charsets() + const charsetFromEmpty = accept.charset() + const charsetFromParams = accept.charset('json', 'text') + const charsetFromArray = accept.charset(['json', 'text']) - const encodings = accept.encodings(); - const encodingFromEmpty = accept.encoding(); - const encodingFromParams = accept.encoding("json", "text"); - const encodingFromArray = accept.encoding(["json", "text"]); + const encodings = accept.encodings() + const encodingFromEmpty = accept.encoding() + const encodingFromParams = accept.encoding('json', 'text') + const encodingFromArray = accept.encoding(['json', 'text']) - const languages = accept.languages(); - const languageFromEmpty = accept.language(); - const languageFromParams = accept.language("json", "text"); - const languageFromArray = accept.language(["json", "text"]); + const languages = accept.languages() + const languageFromEmpty = accept.language() + const languageFromParams = accept.language('json', 'text') + const languageFromArray = accept.language(['json', 'text']) - const types = accept.types(); - const typeFromEmpty = accept.type(); - const typeFromParams = accept.type("json", "text"); - const typeFromArray = accept.type(["json", "text"]); + const types = accept.types() + const typeFromEmpty = accept.type() + const typeFromParams = accept.type('json', 'text') + const typeFromArray = accept.type(['json', 'text']) request.charset() request.charsets() @@ -37,23 +37,23 @@ app.get("/", (request, reply) => { request.type() request.types() - request.charset(["aa", "aa"]) - request.charsets(["aa", "aa"]) - request.encoding(["aa", "aa"]) - request.encodings(["aa", "aa"]) - request.language(["aa", "aa"]) - request.languages(["aa", "aa"]) - request.type(["aa", "aa"]) - request.types(["aa", "aa"]) - - request.charset("aa", "aa") - request.charsets("aa", "aa") - request.encoding("aa", "aa") - request.encodings("aa", "aa") - request.language("aa", "aa") - request.languages("aa", "aa") - request.type("aa", "aa") - request.types("aa", "aa") + request.charset(['aa', 'aa']) + request.charsets(['aa', 'aa']) + request.encoding(['aa', 'aa']) + request.encodings(['aa', 'aa']) + request.language(['aa', 'aa']) + request.languages(['aa', 'aa']) + request.type(['aa', 'aa']) + request.types(['aa', 'aa']) + + request.charset('aa', 'aa') + request.charsets('aa', 'aa') + request.encoding('aa', 'aa') + request.encodings('aa', 'aa') + request.language('aa', 'aa') + request.languages('aa', 'aa') + request.type('aa', 'aa') + request.types('aa', 'aa') reply.requestAccepts() @@ -66,24 +66,23 @@ app.get("/", (request, reply) => { reply.requestType() reply.requestTypes() - reply.requestCharset(["aa", "aa"]) - reply.requestCharsets(["aa", "aa"]) - reply.requestEncoding(["aa", "aa"]) - reply.requestEncodings(["aa", "aa"]) - reply.requestLanguage(["aa", "aa"]) - reply.requestLanguages(["aa", "aa"]) - reply.requestType(["aa", "aa"]) - reply.requestTypes(["aa", "aa"]) - - reply.requestCharset("aa", "aa") - reply.requestCharsets("aa", "aa") - reply.requestEncoding("aa", "aa") - reply.requestEncodings("aa", "aa") - reply.requestLanguage("aa", "aa") - reply.requestLanguages("aa", "aa") - reply.requestType("aa", "aa") - reply.requestTypes("aa", "aa") - - reply.send({ hello: "world" }) + reply.requestCharset(['aa', 'aa']) + reply.requestCharsets(['aa', 'aa']) + reply.requestEncoding(['aa', 'aa']) + reply.requestEncodings(['aa', 'aa']) + reply.requestLanguage(['aa', 'aa']) + reply.requestLanguages(['aa', 'aa']) + reply.requestType(['aa', 'aa']) + reply.requestTypes(['aa', 'aa']) + + reply.requestCharset('aa', 'aa') + reply.requestCharsets('aa', 'aa') + reply.requestEncoding('aa', 'aa') + reply.requestEncodings('aa', 'aa') + reply.requestLanguage('aa', 'aa') + reply.requestLanguages('aa', 'aa') + reply.requestType('aa', 'aa') + reply.requestTypes('aa', 'aa') + + reply.send({ hello: 'world' }) }) -