Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps-dev): replace standard with neostandard #176

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
6 changes: 6 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict'

module.exports = require('neostandard')({
ignores: require('neostandard').resolveIgnoresFromGitignore(),
ts: true
})
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -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"
Expand Down
22 changes: 11 additions & 11 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/bomret>
// Brice BERNARD <https://github.com/brikou>
Expand Down Expand Up @@ -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<fastifyAccepts.FastifyAcceptsOptions>
Expand All @@ -116,5 +116,5 @@ declare namespace fastifyAccepts {
export { fastifyAccepts as default }
}

declare function fastifyAccepts(...params: Parameters<FastifyAccepts>): ReturnType<FastifyAccepts>
declare function fastifyAccepts (...params: Parameters<FastifyAccepts>): ReturnType<FastifyAccepts>
export = fastifyAccepts
113 changes: 56 additions & 57 deletions types/index.test-d.ts
Original file line number Diff line number Diff line change
@@ -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()

Check failure on line 11 in types/index.test-d.ts

View workflow job for this annotation

GitHub Actions / test / Lint Code

'charsets' is assigned a value but never used
const charsetFromEmpty = accept.charset()

Check failure on line 12 in types/index.test-d.ts

View workflow job for this annotation

GitHub Actions / test / Lint Code

'charsetFromEmpty' is assigned a value but never used
const charsetFromParams = accept.charset('json', 'text')

Check failure on line 13 in types/index.test-d.ts

View workflow job for this annotation

GitHub Actions / test / Lint Code

'charsetFromParams' is assigned a value but never used
const charsetFromArray = accept.charset(['json', 'text'])

Check failure on line 14 in types/index.test-d.ts

View workflow job for this annotation

GitHub Actions / test / Lint Code

'charsetFromArray' is assigned a value but never used

const encodings = accept.encodings();
const encodingFromEmpty = accept.encoding();
const encodingFromParams = accept.encoding("json", "text");
const encodingFromArray = accept.encoding(["json", "text"]);
const encodings = accept.encodings()

Check failure on line 16 in types/index.test-d.ts

View workflow job for this annotation

GitHub Actions / test / Lint Code

'encodings' is assigned a value but never used
const encodingFromEmpty = accept.encoding()

Check failure on line 17 in types/index.test-d.ts

View workflow job for this annotation

GitHub Actions / test / Lint Code

'encodingFromEmpty' is assigned a value but never used
const encodingFromParams = accept.encoding('json', 'text')

Check failure on line 18 in types/index.test-d.ts

View workflow job for this annotation

GitHub Actions / test / Lint Code

'encodingFromParams' is assigned a value but never used
const encodingFromArray = accept.encoding(['json', 'text'])

Check failure on line 19 in types/index.test-d.ts

View workflow job for this annotation

GitHub Actions / test / Lint Code

'encodingFromArray' is assigned a value but never used

const languages = accept.languages();
const languageFromEmpty = accept.language();
const languageFromParams = accept.language("json", "text");
const languageFromArray = accept.language(["json", "text"]);
const languages = accept.languages()

Check failure on line 21 in types/index.test-d.ts

View workflow job for this annotation

GitHub Actions / test / Lint Code

'languages' is assigned a value but never used
const languageFromEmpty = accept.language()

Check failure on line 22 in types/index.test-d.ts

View workflow job for this annotation

GitHub Actions / test / Lint Code

'languageFromEmpty' is assigned a value but never used
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()
Expand All @@ -37,23 +37,23 @@
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()

Expand All @@ -66,24 +66,23 @@
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' })
})

Loading