diff --git a/app.js b/app.js index 62123470..9ddd307a 100644 --- a/app.js +++ b/app.js @@ -44,7 +44,7 @@ app.set('view engine', 'jade'); app.use(logger('dev')); app.use(cookieParser()); app.use(cachify); -app.use((req, res, next) => { +app.use((_req, res, next) => { cachify.helpers().then(fns => { res.locals.cachify = fns.cachify; next(); diff --git a/biome.json b/biome.json index 4618d9ed..da8fbb90 100644 --- a/biome.json +++ b/biome.json @@ -30,6 +30,9 @@ "enabled": true, "rules": { "recommended": true, + "correctness": { + "all": true + }, "complexity": { "noForEach": "off", "useLiteralKeys": "off" @@ -44,5 +47,24 @@ "noAssignInExpressions": "off" } } - } + }, + "overrides": [ + { + "include": [ + "**/sw.template.js" + ], + "linter": { + "rules": { + "correctness": { + "noUndeclaredVariables": "off" + } + } + }, + "javascript": { + "globals": [ + "options" + ] + } + } + ] } diff --git a/lib/cli/fetch.js b/lib/cli/fetch.js index 67780bf2..35603b2f 100644 --- a/lib/cli/fetch.js +++ b/lib/cli/fetch.js @@ -10,7 +10,7 @@ function fetchExample(resortId) { resort = require(`../resorts/${resortId}/resort.json`); curl(resort.dataUrl || resort.api || resort.url, resortId); done = true; - } catch (e) { + } catch { console.error(resortId, 'is not a valid resort ID'); process.exit(1); } diff --git a/lib/cli/generate.js b/lib/cli/generate.js index 28f7778d..7a852404 100644 --- a/lib/cli/generate.js +++ b/lib/cli/generate.js @@ -114,7 +114,7 @@ function write(dst, json) { function copy(src, dst, params) { console.log('Generating %s...', dst); - fs.readFile(src, 'utf8', (err, data) => { + fs.readFile(src, 'utf8', (_err, data) => { data = template(data)(params); fs.writeFileSync(dst, data); }); diff --git a/lib/cli/noaa.js b/lib/cli/noaa.js index cd5cab0f..bb439f3a 100644 --- a/lib/cli/noaa.js +++ b/lib/cli/noaa.js @@ -61,7 +61,7 @@ function writeDescriptor(resortId, descriptor) { function readDescriptor(resortId) { try { return require(`../resorts/${resortId}/resort.json`); - } catch (e) { + } catch { console.error(resortId, 'is not a valid resort ID'); process.exit(1); } diff --git a/lib/lifts/index.js b/lib/lifts/index.js index b1d39f1e..49bb9c11 100644 --- a/lib/lifts/index.js +++ b/lib/lifts/index.js @@ -48,7 +48,7 @@ function fetch(resort, fn) { } debug("Fetch lift status for %s", resort.id); const rfau = resort._rfau; - rfau.fn(rfau.url, resort._parseFn, (err, data) => { + rfau.fn(rfau.url, resort._parseFn, (_err, data) => { Promise.resolve(data).then((data, err) => { if (err || !data) { data = {}; diff --git a/lib/loaders.js b/lib/loaders.js index fe281c94..500d7e99 100644 --- a/lib/loaders.js +++ b/lib/loaders.js @@ -23,7 +23,7 @@ function appendResorts(data, resorts) { function load(fn) { debug('Loading resorts...'); - async.parallel(loaders, (err, results) => { + async.parallel(loaders, (_err, results) => { const data = results.reduce(appendResorts, Object.create(null)); debug('Loaded %d resorts.', Object.keys(data).length); fn(null, data); diff --git a/lib/routes/data.js b/lib/routes/data.js index 9eb84f6e..368cabe8 100644 --- a/lib/routes/data.js +++ b/lib/routes/data.js @@ -155,7 +155,7 @@ function data() { function init(fn) { // all loaders - loaders.load((err, data) => { + loaders.load((_err, data) => { initCache(data); my.tags = tags(data); my.all = Object.keys(cache); diff --git a/lib/routes/headers.js b/lib/routes/headers.js index 7868c60d..8722dc12 100644 --- a/lib/routes/headers.js +++ b/lib/routes/headers.js @@ -34,7 +34,7 @@ const reportTo = JSON.stringify({ ] }); -function csp(req, res, next) { +function csp(_req, res, next) { const cspNonce = crypto.randomBytes(16).toString('base64'); res.locals.cspNonce = cspNonce; res.header(CSP_HEADER_NAME, cspPolicy.replace('$random', cspNonce)); @@ -44,18 +44,18 @@ function csp(req, res, next) { next(); } -function referrer(req, res, next) { +function referrer(_req, res, next) { res.header('Referrer-Policy', 'no-referrer-when-downgrade'); next(); } -function feature(req, res, next) { +function feature(_req, res, next) { res.header('Feature-Policy', `fullscreen 'self'`); next(); } -function link(req, res, next) { +function link(_req, res, next) { const preloadLinks = [{ path: '/stylesheets/fonts/lift-status.woff2', as: 'font', diff --git a/lib/routes/index.js b/lib/routes/index.js index 8303152c..a2581d51 100644 --- a/lib/routes/index.js +++ b/lib/routes/index.js @@ -50,7 +50,7 @@ function renderResorts(req, res, next) { * /resort/ - display a specific resort * /?resorts=,... - display resorts on the list */ -function index(req, res, next) { +function index(req, _res, next) { req.requested = req.params.resort || req.query.resorts; req.opts = { openSingle: true @@ -92,7 +92,7 @@ function tag(req, res, next) { next(); } -function about(req, res) { +function about(_req, res) { res.render('about', { title: title('About') }); @@ -162,7 +162,7 @@ function meta(req, res, next) { function routes(app) { - function reqData(req, res, next) { + function reqData(req, _res, next) { req.data = app.data; next(); } diff --git a/lib/routes/service-worker.js b/lib/routes/service-worker.js index 78c11469..14b8a06a 100644 --- a/lib/routes/service-worker.js +++ b/lib/routes/service-worker.js @@ -11,7 +11,7 @@ const { const DEBUG = NODE_ENV !== 'production'; -function renderServiceWorker(req, res) { +function renderServiceWorker(_req, res) { createServiceWorkerScript(res.locals).then(serviceWorkerScript => { // do not cache service worker res.header('Cache-Control', 'no-cache, max-age=0, must-revalidate'); diff --git a/test/lifts/index.js b/test/lifts/index.js index 91ddef97..cf27db34 100644 --- a/test/lifts/index.js +++ b/test/lifts/index.js @@ -13,7 +13,7 @@ function testResort(name, ext, expected, opts = {}) { const parse = makeParse(name); - function testHTML(t, done) { + function testHTML(_t, done) { const stream = createReadStream(filename); stream.on('error', done); @@ -24,7 +24,7 @@ function testResort(name, ext, expected, opts = {}) { })); } - function testJSON(t, done) { + function testJSON(_t, done) { const asyncParse = parse.isAsync ? parse : (data, fn) => process.nextTick(fn, null, parse(data)); diff --git a/test/opening.js b/test/opening.js index 9c29efa7..875bff15 100644 --- a/test/opening.js +++ b/test/opening.js @@ -14,14 +14,14 @@ const today = iso(now); const future = iso(now + 2 * day); const past = iso(now - 2 * day); -test('opening should be empty for missing dates', (t, done) => { +test('opening should be empty for missing dates', (_t, done) => { opening({}, (err, od) => { assert.ok(!od); done(err); }); }); -test('opening should be empty for invalid dates', (t, done) => { +test('opening should be empty for invalid dates', (_t, done) => { opening({ opening: 'abc' }, (err, od) => { @@ -30,7 +30,7 @@ test('opening should be empty for invalid dates', (t, done) => { }); }); -test('opening should be empty for past dates', (t, done) => { +test('opening should be empty for past dates', (_t, done) => { opening({ opening: past }, (err, od) => { @@ -39,7 +39,7 @@ test('opening should be empty for past dates', (t, done) => { }); }); -test('opening should be empty for today', (t, done) => { +test('opening should be empty for today', (_t, done) => { opening({ opening: today }, (err, od) => { @@ -48,7 +48,7 @@ test('opening should be empty for today', (t, done) => { }); }); -test('opening should be present for future dates', (t, done) => { +test('opening should be present for future dates', (_t, done) => { opening({ opening: future }, (err, od) => { diff --git a/test/weather/noaa.js b/test/weather/noaa.js index 3877977c..dce39dda 100644 --- a/test/weather/noaa.js +++ b/test/weather/noaa.js @@ -4,7 +4,7 @@ const noaa = require('../../lib/weather/noaa'); require('../replay'); -test('noaa should return empty forecast if location is missing', (t, done) => { +test('noaa should return empty forecast if location is missing', (_t, done) => { noaa({ ll: [0, 0] }, (err, forecast) => { @@ -14,7 +14,7 @@ test('noaa should return empty forecast if location is missing', (t, done) => { }); }); -test('noaa should return forecast for valid location', (t, done) => { +test('noaa should return forecast for valid location', (_t, done) => { noaa({ // Killington, VT noaa: 'BTV/107,21', diff --git a/test/weather/openweather.js b/test/weather/openweather.js index 39b531bd..b921ab97 100644 --- a/test/weather/openweather.js +++ b/test/weather/openweather.js @@ -4,7 +4,7 @@ const openweather = require('../../lib/weather/openweather'); require('../replay'); -test('openweather should return forecast', (t, done) => { +test('openweather should return forecast', (_t, done) => { openweather({ // Killington, VT ll: [-72.7933, 43.6647] diff --git a/test/webcams.js b/test/webcams.js index 87cc19e5..5be76f3c 100644 --- a/test/webcams.js +++ b/test/webcams.js @@ -8,7 +8,7 @@ if (process.env.REPLAY !== 'record') { process.env.WEBCAMS_API_KEY = 'TEST_KEY'; } -test('webcams should return no webcams if location is missing', (t, done) => { +test('webcams should return no webcams if location is missing', (_t, done) => { webcams({}, (err, webcams) => { assert.ifError(err); assert.ok(!webcams); @@ -16,7 +16,7 @@ test('webcams should return no webcams if location is missing', (t, done) => { }); }); -test('webcams should return webcams for valid location', (t, done) => { +test('webcams should return webcams for valid location', (_t, done) => { webcams({ counter: 1, ll: [7.98, 46.54] // from API examples https://windy.com/webcams/1697038975'