Skip to content

Commit 745dcf2

Browse files
committed
chore: update backend eslint to v9
1 parent 8e2842a commit 745dcf2

File tree

4 files changed

+127
-96
lines changed

4 files changed

+127
-96
lines changed

apps/backend/.eslintignore

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

apps/backend/.eslintrc

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

apps/backend/eslint.config.js

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
import eslint from '@eslint/js';
2+
import tsParser from '@typescript-eslint/parser';
3+
import { defineConfig } from 'eslint/config';
4+
import importPlugin from 'eslint-plugin-import';
5+
import jest from 'eslint-plugin-jest';
6+
import prettier from 'eslint-plugin-prettier';
7+
import unusedImports from 'eslint-plugin-unused-imports';
8+
import globals from 'globals';
9+
import tseslint from 'typescript-eslint';
10+
11+
export default defineConfig(
12+
eslint.configs.recommended,
13+
tseslint.configs.recommended,
14+
importPlugin.flatConfigs.recommended,
15+
importPlugin.flatConfigs.typescript,
16+
{
17+
files: ['**/*.{ts,js}'],
18+
ignores: [
19+
'build/*',
20+
'coverage/*',
21+
'**/*.d.ts', // data definition files
22+
'src/public/', //3rd party libs
23+
'src/types/',
24+
'openapi.yaml', //# auto-generated REST client for the STFC UserOfficeWebService
25+
'generated/',
26+
// node_modules is ignored by default
27+
],
28+
languageOptions: {
29+
parser: tsParser,
30+
parserOptions: {
31+
ecmaVersion: 'es2018',
32+
sourceType: 'module',
33+
},
34+
globals: { ...globals.node },
35+
},
36+
// settings: {
37+
// node: {
38+
// extensions: ['.js', '.ts'],
39+
// }
40+
// },
41+
plugins: {
42+
'unused-imports': unusedImports,
43+
prettier,
44+
jest
45+
},
46+
rules: {
47+
semi: ['error', 'always'],
48+
quotes: ['error', 'single'],
49+
'no-console': 'error', // prefer `duo-logger` over console
50+
51+
'import/order': [
52+
'error',
53+
{
54+
groups: [
55+
'builtin',
56+
'external',
57+
'internal',
58+
['parent', 'sibling'],
59+
'index',
60+
],
61+
// distinctGroup: true,
62+
pathGroups: [
63+
{
64+
pattern: '@src/**',
65+
group: 'internal',
66+
position: 'after',
67+
},
68+
],
69+
pathGroupsExcludedImportTypes: ['builtin'],
70+
'newlines-between': 'always',
71+
alphabetize: {
72+
order: 'asc',
73+
caseInsensitive: true,
74+
},
75+
},
76+
],
77+
78+
// TypeScript rules
79+
'@typescript-eslint/explicit-module-boundary-types': 'off',
80+
'@typescript-eslint/naming-convention': [
81+
'error',
82+
{
83+
selector: 'variable',
84+
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
85+
leadingUnderscore: 'allow',
86+
trailingUnderscore: 'allow',
87+
},
88+
{
89+
selector: 'function',
90+
format: ['PascalCase', 'camelCase'],
91+
},
92+
],
93+
'@typescript-eslint/no-explicit-any': 'warn',
94+
'@typescript-eslint/no-inferrable-types': [
95+
'warn',
96+
{
97+
ignoreParameters: true,
98+
},
99+
],
100+
'@typescript-eslint/no-unused-vars': 'warn',
101+
'@typescript-eslint/ban-ts-comment': 'warn',
102+
103+
// Other style rules
104+
'padding-line-between-statements': [
105+
'error',
106+
{ blankLine: 'always', prev: '*', next: 'return' },
107+
],
108+
109+
// Handle unused imports
110+
'unused-imports/no-unused-imports': 'error',
111+
//TS already handles undef variables
112+
'no-undef': 'off',
113+
'no-unused-vars': 'off',
114+
'no-prototype-builtins': 'off',
115+
116+
},
117+
},
118+
);

apps/backend/package.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,23 +108,25 @@
108108
"@types/simple-oauth2": "^4.1.1",
109109
"@types/sinon": "^9.0.11",
110110
"@types/yup": "^0.29.13",
111-
"@typescript-eslint/eslint-plugin": "^7.7.0",
112-
"@typescript-eslint/parser": "^7.7.0",
111+
"@typescript-eslint/parser": "^8.46.2",
113112
"@user-office-software/uows_client_generator": "^3.1.0",
114-
"eslint": "^8.57.0",
113+
"eslint": "^9.0.0",
115114
"eslint-config-prettier": "^9.1.0",
116-
"eslint-plugin-import": "^2.26.0",
117-
"eslint-plugin-jest": "^28.2.0",
115+
"eslint-plugin-import": "^2.32.0",
116+
"eslint-plugin-jest": "^29.0.1",
118117
"eslint-plugin-prettier": "^5.1.3",
119-
"eslint-plugin-unused-imports": "^3.1.0",
118+
"eslint-plugin-unused-imports": "^4.3.0",
119+
"globals": "^16.5.0",
120120
"jest": "^29.7.0",
121121
"prettier": "3.2.4",
122122
"sinon": "^17.0.1",
123123
"ts-jest": "^29.1.1",
124124
"ts-node-dev": "^2.0.0",
125125
"tsconfig-paths": "^4.2.0",
126-
"typescript": "^5.3.3"
126+
"typescript": "^5.3.3",
127+
"typescript-eslint": "^8.46.3"
127128
},
129+
"type": "module",
128130
"engines": {
129131
"npm": ">=10.9.2",
130132
"node": ">=22.0.0"

0 commit comments

Comments
 (0)