forked from rinafcode/teachLink_backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.eslintrc.js
More file actions
133 lines (118 loc) · 3.42 KB
/
Copy path.eslintrc.js
File metadata and controls
133 lines (118 loc) · 3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
'use strict';
/**
* ESLint configuration for TeachLink Backend
*
* Philosophy:
* - `eslint:recommended` + `@typescript-eslint/recommended` as the base.
* - `plugin:prettier/recommended` is always last so formatting rules win.
* - Type-aware rules (`@typescript-eslint/recommended-requiring-type-checking`)
* are NOT enabled globally because they slow linting in CI. They can be run
* locally via `npm run lint:typed`.
* - Rules that are correct in principle but noisy are set to 'warn' for now.
* Once the codebase is clean, bump them to 'error'.
*/
module.exports = {
root: true,
env: {
node: true,
jest: true,
es2021: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
ecmaVersion: 2021,
tsconfigRootDir: __dirname,
project: undefined, // type-aware linting opt-in only
},
plugins: ['@typescript-eslint', 'prettier'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended', // must be last
],
ignorePatterns: [
'dist/**',
'node_modules/**',
'coverage/**',
'.eslintrc.js',
'jest.config.js',
'lint-staged.config.js',
],
rules: {
// ── Prettier formatting ──
'prettier/prettier': 'error',
// ── Strict TypeScript rules ──
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
// ── Variables ──
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
// ── Potential bugs & Logging Enforcements ──
'no-console': 'error', // Enforce zero unindexed console logging by default
'no-debugger': 'error',
'no-duplicate-imports': 'error',
'@typescript-eslint/no-shadow': 'warn',
// ── Code quality ──
'prefer-const': 'error',
'no-var': 'error',
'object-shorthand': ['warn', 'always'],
'prefer-template': 'warn',
'prefer-arrow-callback': 'warn',
'@typescript-eslint/no-useless-constructor': 'warn',
// ── Naming convention ──
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'variable',
modifiers: ['const'],
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
filter: {
regex: '^_',
match: false,
},
},
],
// ── Formatting ──
semi: ['error', 'always'],
quotes: ['error', 'single', { avoidEscape: true }],
},
overrides: [
{
files: ['**/*.spec.ts', '**/*.e2e-spec.ts', 'test/**/*.ts'],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'no-console': 'off',
},
},
{
files: ['src/migrations/**/*.ts'],
rules: {
'no-console': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
},
{
files: [
'src/**/*.config.ts',
'src/**/*.seed.ts',
'src/cli/**/*.ts',
'src/scripts/**/*.ts',
],
rules: {
'no-console': 'off', // Exempt CLI, seed scripts, and configuration setups
},
},
],
};