Skip to content

Commit

Permalink
refactor: prefix unused params with underscores (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs authored Jan 10, 2025
1 parent 099313f commit 398ba40
Show file tree
Hide file tree
Showing 37 changed files with 351 additions and 351 deletions.
2 changes: 1 addition & 1 deletion benchmark/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const app = express()

app.set('view engine', 'ejs')

app.get('/', (req, res) => {
app.get('/', (_req, res) => {
res.render('../../templates/index.ejs', { text: 'text' })
})

Expand Down
2 changes: 1 addition & 1 deletion benchmark/fastify-art.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

require('./setup.js')({
engine: { 'art-template': require('art-template') },
route: (req, reply) => { reply.view('index.art', { text: 'text' }) }
route: (_req, reply) => { reply.view('index.art', { text: 'text' }) }
})
2 changes: 1 addition & 1 deletion benchmark/fastify-dot.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

require('./setup.js')({
engine: { dot: require('dot') },
route: (req, reply) => { reply.view('testdot', { text: 'text' }) }
route: (_req, reply) => { reply.view('testdot', { text: 'text' }) }
})
2 changes: 1 addition & 1 deletion benchmark/fastify-ejs-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

require('./setup.js')({
engine: { ejs: require('ejs') },
route: (req, reply) => { reply.view('ejs-async.ejs', { text: 'text' }) },
route: (_req, reply) => { reply.view('ejs-async.ejs', { text: 'text' }) },
options: { async: true }
})
2 changes: 1 addition & 1 deletion benchmark/fastify-ejs-global-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require('./setup.js')({
engine: { ejs: require('ejs') },
route: (req, reply) => { reply.view('index-for-layout.ejs', { text: 'text' }) },
route: (_req, reply) => { reply.view('index-for-layout.ejs', { text: 'text' }) },
pluginOptions: {
layout: 'layout.html'
}
Expand Down
2 changes: 1 addition & 1 deletion benchmark/fastify-ejs-local-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

require('./setup.js')({
engine: { ejs: require('ejs') },
route: (req, reply) => { reply.view('index-for-layout.ejs', { text: 'text' }, { layout: 'layout.html' }) }
route: (_req, reply) => { reply.view('index-for-layout.ejs', { text: 'text' }, { layout: 'layout.html' }) }
})
2 changes: 1 addition & 1 deletion benchmark/fastify-ejs-minify.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require('./setup.js')({
engine: { ejs: require('ejs') },
route: (req, reply) => { reply.view('index.ejs', { text: 'text' }) },
route: (_req, reply) => { reply.view('index.ejs', { text: 'text' }) },
options: {
useHtmlMinifier: require('html-minifier-terser'),
htmlMinifierOptions: {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/fastify-eta.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ const eta = new Eta()

require('./setup.js')({
engine: { eta },
route: (req, reply) => { reply.view('index.eta', { text: 'text' }) }
route: (_req, reply) => { reply.view('index.eta', { text: 'text' }) }
})
2 changes: 1 addition & 1 deletion benchmark/fastify-handlebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

require('./setup.js')({
engine: { handlebars: require('handlebars') },
route: (req, reply) => { reply.view('index.html', { text: 'text' }) }
route: (_req, reply) => { reply.view('index.html', { text: 'text' }) }
})
2 changes: 1 addition & 1 deletion benchmark/fastify-liquid.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ const liquid = new Liquid()

require('./setup.js')({
engine: { liquid },
route: (req, reply) => { reply.view('index.liquid', { text: 'text' }) }
route: (_req, reply) => { reply.view('index.liquid', { text: 'text' }) }
})
2 changes: 1 addition & 1 deletion benchmark/fastify-mustache.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

require('./setup.js')({
engine: { mustache: require('mustache') },
route: (req, reply) => { reply.view('index.html', { text: 'text' }) }
route: (_req, reply) => { reply.view('index.html', { text: 'text' }) }
})
2 changes: 1 addition & 1 deletion benchmark/fastify-nunjucks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

require('./setup.js')({
engine: { nunjucks: require('nunjucks') },
route: (req, reply) => { reply.view('index.njk', { text: 'text' }) }
route: (_req, reply) => { reply.view('index.njk', { text: 'text' }) }
})
2 changes: 1 addition & 1 deletion benchmark/fastify-pug.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

require('./setup.js')({
engine: { pug: require('pug') },
route: (req, reply) => { reply.view('index.pug', { text: 'text' }) }
route: (_req, reply) => { reply.view('index.pug', { text: 'text' }) }
})
2 changes: 1 addition & 1 deletion benchmark/fastify-twig.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

require('./setup.js')({
engine: { twig: require('twig') },
route: (req, reply) => { reply.view('index.twig', { title: 'fastify', text: 'text' }) }
route: (_req, reply) => { reply.view('index.twig', { title: 'fastify', text: 'text' }) }
})
2 changes: 1 addition & 1 deletion benchmark/fastify-viewAsync.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

require('./setup.js')({
engine: { ejs: require('ejs') },
route: (req, reply) => { return reply.viewAsync('index.ejs', { text: 'text' }) }
route: (_req, reply) => { return reply.viewAsync('index.ejs', { text: 'text' }) }
})
2 changes: 1 addition & 1 deletion benchmark/fastify.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

require('./setup.js')({
engine: { ejs: require('ejs') },
route: (req, reply) => { reply.view('index.ejs', { text: 'text' }) }
route: (_req, reply) => { reply.view('index.ejs', { text: 'text' }) }
})
2 changes: 1 addition & 1 deletion examples/example-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function something () {
return new Date()
}

fastify.get('/', async (req, reply) => {
fastify.get('/', async (_req, reply) => {
const t = await something()
return reply.view('/index.njk', { text: t })
})
Expand Down
8 changes: 4 additions & 4 deletions examples/example-ejs-with-some-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ fastify.register(require('..'), {
charset: 'utf-8' // sample usage, but specifying the same value already used as default
})

fastify.get('/', (req, reply) => {
fastify.get('/', (_req, reply) => {
// reply.type('text/html; charset=utf-8').view('index-linking-other-pages', data) // sample for specifying with type
reply.view('index-linking-other-pages', data)
})

fastify.get('/include-test', (req, reply) => {
fastify.get('/include-test', (_req, reply) => {
reply.view('index-with-includes', data)
})

fastify.get('/include-one-include-missing-test', (req, reply) => {
fastify.get('/include-one-include-missing-test', (_req, reply) => {
reply.view('index-with-includes-one-missing', data)
})

fastify.get('/include-one-attribute-missing-test', (req, reply) => {
fastify.get('/include-one-attribute-missing-test', (_req, reply) => {
reply.view('index-with-includes-and-attribute-missing', data)
})

Expand Down
2 changes: 1 addition & 1 deletion examples/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fastify.register(require('..'), {
}
})

fastify.get('/', (req, reply) => {
fastify.get('/', (_req, reply) => {
reply.view('/templates/index.ejs', { text: 'text' })
})

Expand Down
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ async function fastifyView (fastify, opts) {
return result
}

function viewDecorator (page) {
function viewDecorator () {
const args = Array.from(arguments)

let done
Expand Down Expand Up @@ -165,7 +165,7 @@ async function fastifyView (fastify, opts) {
if (!fastify.hasReplyDecorator('locals')) {
fastify.decorateReply('locals', null)

fastify.addHook('onRequest', (req, reply, done) => {
fastify.addHook('onRequest', (_req, reply, done) => {
reply.locals = {}
done()
})
Expand Down Expand Up @@ -302,7 +302,7 @@ async function fastifyView (fastify, opts) {
return compiledPage
}

function readCallback (page, data, localOptions, html) {
function readCallback (page, _data, localOptions, html) {
globalOptions.filename = join(templatesDir, page)
return readCallbackParser(page, html, localOptions)
}
Expand Down Expand Up @@ -512,7 +512,7 @@ async function fastifyView (fastify, opts) {
return html
}

async function viewTwig (page, data, opts) {
async function viewTwig (page, data) {
data = Object.assign({}, defaultCtx, globalOptions, this.locals, data)
let render
if (typeof page === 'string') {
Expand Down Expand Up @@ -663,7 +663,7 @@ async function fastifyView (fastify, opts) {
try {
accessSync(join(templatesDir, getPage(fileName, ext)))
result = true
} catch (e) {
} catch {
result = false
}

Expand Down
26 changes: 13 additions & 13 deletions test/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module.exports.dotHtmlMinifierTests = function (t, compileOptions, withMinifierO
}
})

fastify.get('/', (req, reply) => {
fastify.get('/', (_req, reply) => {
reply.view('testdot', data)
})

Expand Down Expand Up @@ -79,7 +79,7 @@ module.exports.dotHtmlMinifierTests = function (t, compileOptions, withMinifierO
}
})

fastify.get('/test', (req, reply) => {
fastify.get('/test', (_req, reply) => {
reply.view('testdot', data)
})

Expand Down Expand Up @@ -122,7 +122,7 @@ module.exports.etaHtmlMinifierTests = function (t, withMinifierOptions) {
}
})

fastify.get('/', (req, reply) => {
fastify.get('/', (_req, reply) => {
reply.view('templates/index.eta', data)
})

Expand Down Expand Up @@ -158,7 +158,7 @@ module.exports.etaHtmlMinifierTests = function (t, withMinifierOptions) {
}
})

fastify.get('/', (req, reply) => {
fastify.get('/', (_req, reply) => {
reply.view('templates/index.eta', data)
})

Expand Down Expand Up @@ -193,7 +193,7 @@ module.exports.etaHtmlMinifierTests = function (t, withMinifierOptions) {
}
})

fastify.get('/test', (req, reply) => {
fastify.get('/test', (_req, reply) => {
reply.view('templates/index.eta', data)
})

Expand Down Expand Up @@ -264,7 +264,7 @@ module.exports.liquidHtmlMinifierTests = function (t, withMinifierOptions) {
}
})

fastify.get('/', (req, reply) => {
fastify.get('/', (_req, reply) => {
reply.view('./templates/index.liquid', data)
})

Expand Down Expand Up @@ -304,7 +304,7 @@ module.exports.liquidHtmlMinifierTests = function (t, withMinifierOptions) {
}
})

fastify.get('/test', (req, reply) => {
fastify.get('/test', (_req, reply) => {
reply.view('./templates/index.liquid', data)
})

Expand Down Expand Up @@ -349,7 +349,7 @@ module.exports.nunjucksHtmlMinifierTests = function (t, withMinifierOptions) {
}
})

fastify.get('/', (req, reply) => {
fastify.get('/', (_req, reply) => {
reply.view('./index.njk', data)
})

Expand Down Expand Up @@ -386,7 +386,7 @@ module.exports.nunjucksHtmlMinifierTests = function (t, withMinifierOptions) {
}
})

fastify.get('/test', (req, reply) => {
fastify.get('/test', (_req, reply) => {
reply.view('./index.njk', data)
})

Expand Down Expand Up @@ -427,7 +427,7 @@ module.exports.pugHtmlMinifierTests = function (t, withMinifierOptions) {
}
})

fastify.get('/', (req, reply) => {
fastify.get('/', (_req, reply) => {
reply.view('./templates/index.pug', data)
})

Expand Down Expand Up @@ -462,7 +462,7 @@ module.exports.pugHtmlMinifierTests = function (t, withMinifierOptions) {
}
})

fastify.get('/test', (req, reply) => {
fastify.get('/test', (_req, reply) => {
reply.view('./templates/index.pug', data)
})

Expand Down Expand Up @@ -502,7 +502,7 @@ module.exports.twigHtmlMinifierTests = function (t, withMinifierOptions) {
}
})

fastify.get('/', (req, reply) => {
fastify.get('/', (_req, reply) => {
reply.view('./templates/index.twig', data)
})

Expand Down Expand Up @@ -540,7 +540,7 @@ module.exports.twigHtmlMinifierTests = function (t, withMinifierOptions) {
}
})

fastify.get('/test', (req, reply) => {
fastify.get('/test', (_req, reply) => {
reply.view('./templates/index.twig', data)
})

Expand Down
10 changes: 5 additions & 5 deletions test/snap/test-ejs-with-snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test('reply.view with ejs engine, template folder specified, include files (ejs
options
})

fastify.get('/', (req, reply) => {
fastify.get('/', (_req, reply) => {
reply.type('text/html; charset=utf-8').view('index-linking-other-pages', data) // sample for specifying with type
})

Expand Down Expand Up @@ -71,7 +71,7 @@ test('reply.view with ejs engine, templates with folder specified, include files
options
})

fastify.get('/', (req, reply) => {
fastify.get('/', (_req, reply) => {
reply.type('text/html; charset=utf-8').view('index', data)
})

Expand Down Expand Up @@ -115,7 +115,7 @@ test('reply.view with ejs engine, templates with folder specified, include files
options
})

fastify.get('/include-test', (req, reply) => {
fastify.get('/include-test', (_req, reply) => {
reply.type('text/html; charset=utf-8').view('index-with-includes', data)
})

Expand Down Expand Up @@ -159,7 +159,7 @@ test('reply.view with ejs engine, templates with folder specified, include files
options
})

fastify.get('/include-one-include-missing-test', (req, reply) => {
fastify.get('/include-one-include-missing-test', (_req, reply) => {
reply.type('text/html; charset=utf-8').view('index-with-includes-one-missing', data)
})

Expand Down Expand Up @@ -203,7 +203,7 @@ test('reply.view with ejs engine, templates with folder specified, include files
options
})

fastify.get('/include-one-attribute-missing-test', (req, reply) => {
fastify.get('/include-one-attribute-missing-test', (_req, reply) => {
reply.type('text/html; charset=utf-8').view('index-with-includes-and-attribute-missing', data)
})

Expand Down
Loading

0 comments on commit 398ba40

Please sign in to comment.