Skip to content

Commit

Permalink
refactor: prefix unused params with underscores
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Jan 6, 2025
1 parent b72872c commit d08066c
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
14 changes: 7 additions & 7 deletions lib/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function fastifySwagger (fastify, opts, done) {
}

if (typeof staticCSP === 'string' || typeof opts.transformStaticCSP === 'function') {
fastify.addHook('onSend', function (request, reply, payload, done) {
fastify.addHook('onSend', function (_request, reply, _payload, done) {
// set static csp when it is passed
if (typeof staticCSP === 'string') {
reply.header('content-security-policy', staticCSP.trim())
Expand Down Expand Up @@ -62,7 +62,7 @@ function fastifySwagger (fastify, opts, done) {
method: 'GET',
schema: { hide: true },
...hooks,
handler: (req, reply) => {
handler: (_req, reply) => {
reply
.header('content-type', 'text/css; charset=UTF-8')
.send(cssFile.content)
Expand All @@ -78,7 +78,7 @@ function fastifySwagger (fastify, opts, done) {
method: 'GET',
schema: { hide: true },
...hooks,
handler: (req, reply) => {
handler: (_req, reply) => {
reply
.header('content-type', 'application/javascript; charset=utf-8')
.send(jsFile.content)
Expand All @@ -94,7 +94,7 @@ function fastifySwagger (fastify, opts, done) {
method: 'GET',
schema: { hide: true },
...hooks,
handler: (req, reply) => {
handler: (_req, reply) => {
reply
.header('content-type', favicon.type)
.send(favicon.content)
Expand Down Expand Up @@ -135,7 +135,7 @@ function fastifySwagger (fastify, opts, done) {
method: 'GET',
schema: { hide: true },
...hooks,
handler: (req, reply) => {
handler: (_req, reply) => {
reply
.header('content-type', 'application/javascript; charset=utf-8')
.send(swaggerInitializerContent)
Expand All @@ -158,7 +158,7 @@ function fastifySwagger (fastify, opts, done) {
: function (req, reply) {
reply.send(transformSpecification(fastify.swagger(), req, reply))
}
: function (req, reply) {
: function (_req, reply) {
reply.send(fastify.swagger())
}
})
Expand All @@ -180,7 +180,7 @@ function fastifySwagger (fastify, opts, done) {
.type('application/x-yaml')
.send(yaml.stringify(transformSpecification(fastify.swagger(), req, reply)))
}
: function (req, reply) {
: function (_req, reply) {
reply
.type('application/x-yaml')
.send(fastify.swagger({ yaml: true }))
Expand Down
4 changes: 2 additions & 2 deletions test/hooks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const fastifySwaggerUi = require('../index')
const { swaggerOption, schemaBody } = require('../examples/options')

const authOptions = {
validate (username, password, req, reply, done) {
validate (username, password, _req, _reply, done) {
if (username === 'admin' && password === 'admin') {
done()
} else {
Expand Down Expand Up @@ -116,7 +116,7 @@ test('catch all added schema', async t => {
await fastify.register(fastifySwagger, {
openapi: {},
refResolver: {
buildLocalReference: (json, baseUri, fragment, i) => {
buildLocalReference: (json, _baseUri, _fragment, i) => {
return json.$id || `def-${i}`
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test('fastify will response swagger csp', async (t) => {
})

// route for testing CSP headers
fastify.get('/', (req, reply) => {
fastify.get('/', (_req, reply) => {
reply.send({
foo: 'bar'
})
Expand Down
6 changes: 3 additions & 3 deletions test/route.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ test('/v1/foobar should display index html', async (t) => {
t.plan(4)
const fastify = Fastify()

fastify.register(async function (fastify, options) {
fastify.register(async function (fastify) {
await fastify.register(fastifySwagger, swaggerOption)
await fastify.register(fastifySwaggerUi, { routePrefix: '/foobar', noRedirect: true })

Expand All @@ -223,7 +223,7 @@ test('/v1/foobar/ should display index html', async (t) => {
t.plan(4)
const fastify = Fastify()

fastify.register(async function (fastify, options) {
fastify.register(async function (fastify) {
await fastify.register(fastifySwagger, swaggerOption)
await fastify.register(fastifySwaggerUi, { routePrefix: '/foobar' })

Expand Down Expand Up @@ -476,7 +476,7 @@ test('/documentation/:myfile should return 404 in dynamic mode', async (t) => {
test('/documentation/:myfile should run custom NotFoundHandler in dynamic mode', async (t) => {
t.plan(1)
const fastify = Fastify()
const notFoundHandler = function (req, reply) {
const notFoundHandler = function (_req, reply) {
reply.code(410).send()
}
fastify.setNotFoundHandler(notFoundHandler)
Expand Down
2 changes: 1 addition & 1 deletion test/static.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ test('/documentation/non-existing-file calls custom NotFoundHandler', async (t)
const fastify = Fastify()
await fastify.register(fastifySwagger, config)
await fastify.register(fastifySwaggerUi)
fastify.setNotFoundHandler((request, reply) => {
fastify.setNotFoundHandler((_request, reply) => {
reply.code(410).send()
})

Expand Down
4 changes: 2 additions & 2 deletions types/http2-types.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ app.put('/some-route/:id', {
summary: 'qwerty',
security: [{ apiKey: [] }]
}
}, (req, reply) => {})
}, () => {})

app.get('/public/route', {
schema: {
description: 'returns 200 OK',
summary: 'qwerty',
security: []
}
}, (_req, _reply) => {})
}, () => {})

app
.register(fastifySwaggerUi, {
Expand Down
12 changes: 6 additions & 6 deletions types/types.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const initOAuth: FastifySwaggerInitOAuthOptions = {
scopes: ['openid', 'profile', 'email', 'offline_access'],
}
const uiHooks: FastifySwaggerUiHooksOptions = {
onRequest: (request, reply, done) => { done() },
preHandler: (request, reply, done) => { done() },
onRequest: (_request, _reply, done) => { done() },
preHandler: (_request, _reply, done) => { done() },
}

app.register(fastifySwaggerUi)
Expand All @@ -43,7 +43,7 @@ app.get('/deprecated', {
deprecated: true,
hide: true
}
}, (req, reply) => {})
}, () => {})

app.put('/some-route/:id', {
schema: {
Expand All @@ -58,7 +58,7 @@ app.put('/some-route/:id', {
description: 'Find more info here'
},
}
}, (req, reply) => {})
}, () => {})

app.put('/image.png', {
schema: {
Expand All @@ -73,7 +73,7 @@ app.put('/image.png', {
}
}
}
}, async (req, reply) => {
}, async (_req, reply) => {
reply
.type('image/png')
.send(Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAIAAAACDbGyAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAAgSURBVBhXY/iPCkB8BgYkEiSIBICiCCEoB0SBwf///wGHRzXLSklJLQAAAABJRU5ErkJggg==', 'base64'))
Expand All @@ -89,7 +89,7 @@ app.get('/public/route', {
links: {
200: { 'some-route': { operationId: 'opeId' } }
}
}, (req, reply) => {})
}, () => {})

app
.register(fastifySwaggerUi, {
Expand Down

0 comments on commit d08066c

Please sign in to comment.