Skip to content

Commit 24d773c

Browse files
Use eslint-config-pa11y for linting (#342)
* Use ESLint 9 and `eslint-config-pa11y`; rename config * Ignore `public/js`, loosen rules for tests * Allow free `max-len` in `data/*` * Destructure more * Fix whitespace and trailing commas * Allow `fetch` in tests * Use `path.join` instead of plain strings * Remove obsolete `.eslintignore`
1 parent cef0c33 commit 24d773c

File tree

9 files changed

+795
-521
lines changed

9 files changed

+795
-521
lines changed

.eslintignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

app.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const hbs = require('express-hbs');
2323
const morgan = require('morgan');
2424
const {nanoid} = require('nanoid');
2525
const http = require('http');
26+
const path = require('path');
2627
const pkg = require('./package.json');
2728

2829
module.exports = initApp;
@@ -85,7 +86,7 @@ function loadMiddleware(app) {
8586
app.express.use(morgan(endLog));
8687

8788
// Public files
88-
app.express.use(express.static(`${__dirname}/public`, {
89+
app.express.use(express.static(path.join(__dirname, 'public'), {
8990
maxAge: (process.env.NODE_ENV === 'production' ? 604800000 : 0)
9091
}));
9192

@@ -100,11 +101,11 @@ function loadViewEngine(app, config) {
100101
app.express.engine('html', hbs.express4({
101102
extname: '.html',
102103
contentHelperName: 'content',
103-
layoutsDir: `${__dirname}/view/layout`,
104-
partialsDir: `${__dirname}/view/partial`,
105-
defaultLayout: `${__dirname}/view/layout/default`
104+
layoutsDir: path.join(__dirname, 'view', 'layout'),
105+
partialsDir: path.join(__dirname, 'view', 'partial'),
106+
defaultLayout: path.join(__dirname, 'view', 'layout', 'default')
106107
}));
107-
app.express.set('views', `${__dirname}/view`);
108+
app.express.set('views', path.join(__dirname, 'view'));
108109
app.express.set('view engine', 'html');
109110

110111
// View helpers

data/.eslintrc.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

eslint.config.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
'use strict';
2+
3+
const {defineConfig} = require('eslint/config');
4+
5+
const configPa11y = require('eslint-config-pa11y');
6+
7+
module.exports = defineConfig([
8+
configPa11y,
9+
{
10+
ignores: [
11+
'public/js/*'
12+
]
13+
},
14+
{
15+
files: ['test/**/*.js', 'test/**/*.cjs'],
16+
rules: {
17+
'prefer-arrow-callback': 'off',
18+
'no-invalid-this': 'off',
19+
'n/no-unsupported-features/node-builtins': ['error', {
20+
ignores: ['fetch']
21+
}]
22+
}
23+
},
24+
{
25+
files: ['data/*'],
26+
rules: {
27+
'max-len': 'off'
28+
}
29+
}
30+
]);

0 commit comments

Comments
 (0)