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

refactor: prefix unused params with underscores #161

Merged
merged 1 commit into from
Dec 30, 2024
Merged
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
10 changes: 5 additions & 5 deletions example/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@ fastify
})

// every time we have a new message, let's broadcast it
emitter.on('new-message', (message, cb) => {
emitter.on('new-message', (message, _cb) => {
for (const socket of fastify.websocketServer.clients.values()) {
socket.send(message.payload)
}
})

emitter.on('delete-message', (message, cb) => {
emitter.on('delete-message', (message, _cb) => {
for (const socket of fastify.websocketServer.clients.values()) {
socket.send(message.payload)
}
})

// render the initial page and populate it
// with the current content
fastify.get('/', async (req, reply) => {
fastify.get('/', async (_req, reply) => {
const messages = []
for (const [id, message] of db.entries()) {
messages.push({ id, text: message.text, user: message.user })
Expand Down Expand Up @@ -156,12 +156,12 @@ fastify.route({
handler: onAckToast
})

async function onAckToast (req, reply) {
async function onAckToast (_req, reply) {
return reply.turboStream.remove('toast.svelte', 'toast')
}

// websocket handler used by turbo for handling realtime communications
fastify.get('/ws', { websocket: true }, (connection, req) => {
fastify.get('/ws', { websocket: true }, (_connection, req) => {
req.log.info('new websocket connection')
})

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async function fastifyHotwire (fastify, opts) {
return that
}

async function generate (that, action, file, target, data) {
async function generate (_that, action, file, target, data) {
const html = await pool.runTask({ file: join(templates, file), data, fragment: true })
return buildStream(action, target, html).replace(/\n/g, '').trim()
}
Expand Down
6 changes: 3 additions & 3 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test('Should render the entire page', async t => {
filename: join(__dirname, '..', 'example', 'worker.js')
})

fastify.get('/', async (req, reply) => {
fastify.get('/', async (_req, reply) => {
return reply.render('index.svelte', { messages: [], username: 'foobar' })
})

Expand All @@ -34,7 +34,7 @@ function runTurboStream (action) {
filename: join(__dirname, '..', 'example', 'worker.js')
})

fastify.get('/', async (req, reply) => {
fastify.get('/', async (_req, reply) => {
return reply.turboStream[action](
'message.svelte',
'messages',
Expand Down Expand Up @@ -67,7 +67,7 @@ function runTurboGenerate (action) {
filename: join(__dirname, '..', 'example', 'worker.js')
})

fastify.get('/', async (req, reply) => {
fastify.get('/', async (_req, reply) => {
reply.type('text/plain')
return reply.turboGenerate[action](
'message.svelte',
Expand Down
4 changes: 2 additions & 2 deletions types/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ app.register(hotwire, {
filename: join(__dirname, 'example', 'worker.js')
})

app.get('/stream', async (req, reply) => {
app.get('/stream', async (_req, reply) => {
return reply.turboStream.append('file', 'target', { hello: 'world' })
})

app.get('/generate', async (req, reply) => {
app.get('/generate', async (_req, reply) => {
const fragment = await reply.turboGenerate.append('file', 'target', { hello: 'world' })
expectType<string>(fragment)
})
Loading