Skip to content

Commit e4810cb

Browse files
authored
chore: upgrade eslint backend to 9.0 (#1259)
1 parent e05db51 commit e4810cb

175 files changed

Lines changed: 6392 additions & 3593 deletions

File tree

Some content is hidden

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

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

0 commit comments

Comments
 (0)