Skip to content

Commit

Permalink
test: prefix unused params with underscores (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs authored Jan 3, 2025
1 parent 1bfce16 commit fe70605
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion examples/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const bearerAuthPlugin = require('..')
const keys = new Set(['key'])

fastify.register(bearerAuthPlugin, { keys })
fastify.get('/foo', (req, reply) => {
fastify.get('/foo', (_req, reply) => {
reply.send({ authenticated: true })
})

Expand Down
4 changes: 2 additions & 2 deletions test/decorate-with-logger.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test('verifyBearerAuth with debug log', async (t) => {

const logs = []
const destination = new stream.Writable({
write: function (chunk, encoding, next) {
write: function (chunk, _encoding, next) {
logs.push(JSON.parse(chunk))
next()
}
Expand All @@ -23,7 +23,7 @@ test('verifyBearerAuth with debug log', async (t) => {
onRequest: [
fastify.verifyBearerAuth
]
}, async (request, reply) => {
}, async (_request, _reply) => {
return { message: 'ok' }
})

Expand Down
8 changes: 4 additions & 4 deletions test/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const plugin = require('../')

fastify.register(plugin, { keys: new Set(['123456']) })

fastify.get('/test', (req, res) => {
fastify.get('/test', (_req, res) => {
res.send({ hello: 'world' })
})

Expand Down Expand Up @@ -56,7 +56,7 @@ test('missing header route fails correctly', async (t) => {
t.assert.strictEqual(JSON.parse(response.body).error, 'missing authorization header')
})

test('integration with @fastify/auth', async (t) => {
test('integration with @fastify/auth', async () => {
const fastify = require('fastify')()
await fastify.register(plugin, { addHook: false, keys: new Set(['123456']) })
fastify.decorate('allowAnonymous', function (request, _, done) {
Expand Down Expand Up @@ -115,10 +115,10 @@ test('integration with @fastify/auth', async (t) => {
})
})

test('integration with @fastify/auth; not the last auth option', async (t) => {
test('integration with @fastify/auth; not the last auth option', async () => {
const fastify = require('fastify')()
await fastify.register(plugin, { addHook: false, keys: new Set(['123456']) })
fastify.decorate('alwaysValidAuth', function (request, _, done) {
fastify.decorate('alwaysValidAuth', function (_request, _, done) {
return done()
})
await fastify.register(require('@fastify/auth'))
Expand Down
2 changes: 1 addition & 1 deletion test/spec-compliance-rfc-6749.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const plugin = require('../')

fastify.register(plugin, { keys: new Set(['123456']), specCompliance: 'rfc6749' })

fastify.get('/test', (req, res) => {
fastify.get('/test', (_req, res) => {
res.send({ hello: 'world' })
})

Expand Down
2 changes: 1 addition & 1 deletion test/spec-compliance-rfc-6750.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const plugin = require('../')

fastify.register(plugin, { keys: new Set(['123456']), specCompliance: 'rfc6750' })

fastify.get('/test', (req, res) => {
fastify.get('/test', (_req, res) => {
res.send({ hello: 'world' })
})

Expand Down
4 changes: 2 additions & 2 deletions test/verify-bearer-auth-factory.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ test('hook accepts correct header with auth function (promise)', (t) => {
send
}

function send (body) {
function send (_body) {
t.assert.ifError('should not happen')
}

Expand All @@ -309,7 +309,7 @@ test('hook accepts correct header with auth function (non-promise)', (t) => {
send
}

function send (body) {
function send (_body) {
t.assert.ifError('should not happen')
}

Expand Down
6 changes: 3 additions & 3 deletions types/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import bearerAuth, { FastifyBearerAuthOptions, verifyBearerAuth, verifyBearerAut

const pluginOptions: FastifyBearerAuthOptions = {
keys: new Set(['foo']),
auth: (key: string, req: FastifyRequest) => { return true },
auth: (_key: string, _req: FastifyRequest) => { return true },
errorResponse: (err: Error) => { return { error: err.message } },
contentType: '',
bearerType: '',
Expand All @@ -13,15 +13,15 @@ const pluginOptions: FastifyBearerAuthOptions = {

const pluginOptionsAuthPromise: FastifyBearerAuthOptions = {
keys: new Set(['foo']),
auth: (key: string, req: FastifyRequest) => { return Promise.resolve(true) },
auth: (_key: string, _req: FastifyRequest) => { return Promise.resolve(true) },
errorResponse: (err: Error) => { return { error: err.message } },
contentType: '',
bearerType: ''
}

const pluginOptionsKeyArray: FastifyBearerAuthOptions = {
keys: ['foo'],
auth: (key: string, req: FastifyRequest) => { return Promise.resolve(true) },
auth: (_key: string, _req: FastifyRequest) => { return Promise.resolve(true) },
errorResponse: (err: Error) => { return { error: err.message } },
contentType: '',
bearerType: ''
Expand Down

0 comments on commit fe70605

Please sign in to comment.