-
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy path.eslintrc.js
More file actions
175 lines (161 loc) · 4.65 KB
/
Copy path.eslintrc.js
File metadata and controls
175 lines (161 loc) · 4.65 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
module.exports = {
extends: ['eslint:recommended', 'airbnb-base', 'prettier'],
parser: '@babel/eslint-parser',
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
requireConfigFile: true,
babelOptions: {
configFile: `${__dirname}/babel.config.js`,
},
},
env: { es6: true, node: true, commonjs: true },
rules: {
// ===============================
// KEEP EXISTING RELAXED RULES
// ===============================
'global-require': 'off',
'func-names': 'off',
'no-underscore-dangle': 'off',
'no-param-reassign': 'off',
'max-len': 'off',
'no-continue': 'warn',
'no-await-in-loop': 'warn',
'template-curly-spacing': 'off',
indent: 'off',
'linebreak-style': 0,
'no-console': 'warn',
'consistent-return': 'off',
// ===============================
// LIGHT ENTERPRISE ADDITIONS (MOSTLY WARNINGS)
// ===============================
// Critical Error Prevention (errors only for breaking stuff)
'no-undef': 'error',
'no-unused-vars': [
'warn',
{
vars: 'local',
args: 'none',
varsIgnorePattern: '^_',
argsIgnorePattern: '^_',
},
],
'no-unreachable': 'error',
'no-dupe-keys': 'error',
'no-duplicate-case': 'error',
// Security (light - just warnings to start awareness)
'no-eval': 'warn',
'no-implied-eval': 'warn',
'no-new-func': 'warn',
'no-script-url': 'warn',
// Code Quality (warnings only - gradual improvement)
'no-var': 'warn', // Encourage let/const
'prefer-const': 'warn', // Encourage immutability
'no-magic-numbers': [
'warn',
{
ignore: [-1, 0, 1, 2, 100, 200, 201, 400, 401, 403, 404, 500],
ignoreArrayIndexes: true,
},
],
'prefer-template': 'warn',
'no-duplicate-imports': 'warn',
'object-shorthand': 'warn',
// Async/Promise Best Practices (warnings)
'no-return-await': 'warn',
'prefer-promise-reject-errors': 'warn',
'no-async-promise-executor': 'warn',
// Node.js Specific (warnings)
'no-path-concat': 'warn',
'no-process-exit': 'warn',
'handle-callback-err': 'warn',
'new-cap': 'warn',
'no-lonely-if': 'warn',
'no-nested-ternary': 'warn',
camelcase: 'warn',
radix: 'warn',
'no-restricted-syntax': 'warn',
// Light Complexity Control (warnings with high thresholds)
complexity: ['warn', { max: 15 }], // High threshold for lazy devs
'max-depth': ['warn', { max: 5 }],
'max-params': ['warn', { max: 4 }],
'max-lines-per-function': [
'warn',
{
max: 100,
skipBlankLines: true,
skipComments: true,
},
],
// Import Organization (warnings only)
'import/order': [
'warn',
{
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
'newlines-between': 'never', // Keep it simple
},
],
'import/newline-after-import': 'warn',
'import/no-duplicates': 'warn',
// Performance Hints (warnings)
'no-loop-func': 'warn',
// API Design (warnings for better practices)
'no-throw-literal': 'warn',
'prefer-rest-params': 'warn',
'prefer-spread': 'warn',
// Database/Backend Specific (warnings)
'no-eq-null': 'warn', // Encourage strict equality
eqeqeq: ['warn', 'smart'], // Allow == null for lazy devs
// Documentation Encouragement (warnings)
'spaced-comment': [
'warn',
'always',
{
markers: ['/', '!', '*'],
exceptions: ['-', '+', '*'],
},
],
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx'],
},
},
},
overrides: [
// Test Files - More Relaxed
{
files: ['**/*.test.js', '**/*.spec.js', 'src/test/**/*.js', 'src/__tests__/**/*.js'],
env: { jest: true },
rules: {
// Relax rules for test files
'no-magic-numbers': 'off',
'max-lines-per-function': 'off',
complexity: 'off',
'max-params': 'off',
'prefer-promise-reject-errors': 'off',
'no-console': 'off',
'import/no-extraneous-dependencies': 'off',
},
},
// Config Files - Super Relaxed
{
files: ['*.config.js', '.eslintrc.js', 'babel.config.js', 'webpack.config.js'],
rules: {
'no-console': 'off',
'import/no-extraneous-dependencies': 'off',
'global-require': 'off',
},
},
// Migration Files - Relaxed (if using DB migrations)
{
files: ['**/migrations/*.js', '**/seeders/*.js'],
rules: {
'no-console': 'off',
'max-lines-per-function': 'off',
'no-magic-numbers': 'off',
},
},
],
};