Skip to content

Commit 7a054a5

Browse files
authored
Merge pull request #413 from bcgov/feature/eslint
Update backend to eslint v9.x
2 parents fec47a6 + 149d470 commit 7a054a5

File tree

248 files changed

+4518
-6984
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

248 files changed

+4518
-6984
lines changed

app/.eslintrc.js

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

app/.prettierignore

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
1-
# Logs
1+
# Dependencies
2+
/node_modules
3+
4+
# Production
5+
/build
6+
7+
# Generated files
8+
.docusaurus
9+
.cache-loader
10+
/pr-preview/**/.nojekyll
11+
12+
# Misc
13+
.DS_Store
14+
*.local
15+
coverage
16+
dist
17+
dist-ssr
18+
19+
# Log files
220
logs
321
*.log
422
npm-debug.log*
@@ -7,23 +25,15 @@ yarn-error.log*
725
pnpm-debug.log*
826
lerna-debug.log*
927

10-
build
11-
node_modules
12-
.DS_Store
13-
dist
14-
dist-ssr
15-
coverage
16-
*.local
17-
18-
/cypress/videos/
19-
/cypress/screenshots/
20-
2128
# Editor directories and files
22-
.vscode/*
23-
!.vscode/extensions.json
2429
.idea
30+
*.iml
2531
*.suo
2632
*.ntvs*
2733
*.njsproj
2834
*.sln
2935
*.sw?
36+
*.mp4
37+
38+
# Temp Office files
39+
~$*

app/app.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ import helmet from 'helmet';
88
import { join } from 'path';
99
import querystring from 'querystring';
1010

11-
import { version as appVersion } from './package.json';
12-
import { requestSanitizer } from './src/middleware/requestSanitizer';
13-
import router from './src/routes';
14-
import { Problem } from './src/utils';
15-
import { DEFAULTCORS } from './src/utils/constants/application';
16-
import { getLogger, httpLogger } from './src/utils/log';
17-
import { readIdpList } from './src/utils/utils';
18-
import { state } from './state';
11+
import { requestSanitizer } from './src/middleware/requestSanitizer.ts';
12+
import router from './src/routes/index.ts';
13+
import { Problem } from './src/utils/index.ts';
14+
import { DEFAULTCORS } from './src/utils/constants/application.ts';
15+
import { getLogger, httpLogger } from './src/utils/log.ts';
16+
import { readIdpList } from './src/utils/utils.ts';
17+
import { state } from './state.ts';
1918

2019
import type { NextFunction, Request, Response } from 'express';
2120

@@ -81,8 +80,7 @@ appRouter.get('/config', (_req: Request, res: Response, next: NextFunction): voi
8180
features: state.features,
8281
...config.get('frontend'),
8382
gitRev: state.gitRev,
84-
idpList: readIdpList(),
85-
version: appVersion
83+
idpList: readIdpList()
8684
});
8785
} catch (err) {
8886
next(err);

app/deploy-utils.ts

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ try {
4141
console.log(`${TITLE} is present and up to date`);
4242
}
4343
}
44-
} catch (err) {
44+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
45+
} catch (error) {
4546
console.log(`An error occured while managing ${TITLE}`);
4647
process.exit(1);
4748
}
@@ -51,8 +52,7 @@ try {
5152
//
5253

5354
/**
54-
* @function buildComponents
55-
* @description Rebuild `nr-permitting-navigator-service-frontend` library
55+
* Rebuild `nr-permitting-navigator-service-frontend` library
5656
*/
5757
function buildComponents() {
5858
if (!existsSync(`${FRONTEND_DIR}/node_modules`)) {
@@ -65,8 +65,7 @@ function buildComponents() {
6565
}
6666

6767
/**
68-
* @function cleanComponents
69-
* @description Clean `nr-permitting-navigator-service-frontend` library directory
68+
* Clean `nr-permitting-navigator-service-frontend` library directory
7069
*/
7170
function cleanComponents() {
7271
console.log(`Cleaning ${TITLE}...`);
@@ -83,8 +82,7 @@ function copyDocs() {
8382
}
8483

8584
/**
86-
* @function deployComponents
87-
* @description Redeploy `nr-permitting-navigator-service-frontend` library
85+
* Redeploy `nr-permitting-navigator-service-frontend` library
8886
*/
8987
function deployComponents() {
9088
console.log(`Redeploying ${TITLE}...`);
@@ -98,14 +96,12 @@ function deployComponents() {
9896
//
9997

10098
/**
101-
* @function runSync
102-
* @description Execute a single shell command where `cmd` is a string
103-
* @param {string} cmd Shell command to run
104-
* @param {string} [cwd] Working directory of the command to run
99+
* Execute a single shell command where `cmd` is a string
100+
* @param cmd Shell command to run
101+
* @param cwd Working directory of the command to run
105102
*/
106103
export function runSync(cmd: string, cwd: string | undefined) {
107-
// eslint-disable-next-line @typescript-eslint/no-var-requires
108-
const { spawnSync } = require('child_process');
104+
const { spawnSync } = require('child_process'); // eslint-disable-line @typescript-eslint/no-require-imports
109105
const parts = cmd.split(/\s+/g);
110106
const opts = {
111107
cwd: cwd || undefined,
@@ -123,10 +119,9 @@ export function runSync(cmd: string, cwd: string | undefined) {
123119
}
124120

125121
/**
126-
* @function copyFileSync
127-
* @description Copies `source` file to `target` file
128-
* @param {string} source Source file location
129-
* @param {string} target Target file location
122+
* Copies `source` file to `target` file
123+
* @param source Source file location
124+
* @param target Target file location
130125
*/
131126
export function copyFileSync(source: string, target: string) {
132127
let targetFile = target;
@@ -142,10 +137,9 @@ export function copyFileSync(source: string, target: string) {
142137
}
143138

144139
/**
145-
* @function copyDirRecursiveSync
146-
* @description Recursively copies `source` directory contents to `target` directory
147-
* @param {string} source Source directory location
148-
* @param {string} target Target directory location
140+
* Recursively copies `source` directory contents to `target` directory
141+
* @param source Source directory location
142+
* @param target Target directory location
149143
*/
150144
export function copyDirRecursiveSync(source: string, target: string) {
151145
let files = [];

app/eslint.config.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import eslint from '@eslint/js';
2+
import eslintConfigPrettier from 'eslint-config-prettier';
3+
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
4+
import jsdoc from 'eslint-plugin-jsdoc';
5+
import tseslint from 'typescript-eslint';
6+
7+
export default tseslint.config(
8+
{
9+
ignores: ['coverage/**', 'dist/**', 'jest.config.js', 'node_modules/**', 'sbin/**']
10+
},
11+
{
12+
files: ['**/*.{js,ts}'],
13+
extends: [
14+
// Extensions are order dependent - always apply Prettier last
15+
eslint.configs.recommended,
16+
tseslint.configs.recommended,
17+
tseslint.configs.stylistic,
18+
jsdoc.configs['flat/recommended-typescript'],
19+
eslintPluginPrettierRecommended,
20+
eslintConfigPrettier // Drops conflicting rules
21+
],
22+
languageOptions: {
23+
parserOptions: {
24+
projectService: true,
25+
tsconfigRootDir: __dirname //TODO when type:module => import.meta.dirname
26+
}
27+
},
28+
rules: {
29+
'@typescript-eslint/no-require-imports': 'error',
30+
'eol-last': ['error', 'always'],
31+
indent: ['error', 2, { SwitchCase: 1 }],
32+
'linebreak-style': ['error', 'unix'],
33+
'max-len': ['warn', { code: 120, comments: 120, ignoreUrls: true }],
34+
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'warn',
35+
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'warn',
36+
quotes: ['error', 'single'],
37+
'jsdoc/require-jsdoc': 'off', // TODO: Turn this back on later
38+
semi: ['error', 'always']
39+
}
40+
}
41+
);

app/knexfile.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import config from 'config';
22
import { format, parseJSON } from 'date-fns';
3-
import { Knex } from 'knex';
3+
4+
import { type Knex } from 'knex';
45

56
import { getLogger } from './src/utils/log';
67
const log = getLogger(module.filename);

0 commit comments

Comments
 (0)