Repository navigation
Expand file tree
/
Copy path.eslintrc.js
More file actions
132 lines (123 loc) · 3.62 KB
/
Copy path.eslintrc.js
File metadata and controls
132 lines (123 loc) · 3.62 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
/**
* ESLint Configuration - Enterprise Grade
*
* Strict rules for production-quality code.
* All warnings are errors in CI (--max-warnings 0).
*/
module.exports = {
env: {
browser: true,
es2021: true,
node: true,
},
extends: ['eslint:recommended'],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
rules: {
// ==================== ERRORS (Must Fix) ====================
// Variables
'no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
'no-undef': 'error',
'no-use-before-define': ['error', { functions: false, classes: true }],
'no-shadow': 'error',
'no-redeclare': 'error',
// Best Practices
eqeqeq: ['error', 'always'],
curly: ['error', 'all'],
'no-eval': 'error',
'no-implied-eval': 'error',
'no-extend-native': 'error',
'no-extra-bind': 'error',
'no-floating-decimal': 'error',
'no-implicit-coercion': 'error',
'no-invalid-this': 'error',
'no-lone-blocks': 'error',
'no-multi-spaces': 'error',
'no-new': 'error',
'no-new-func': 'error',
'no-new-wrappers': 'error',
'no-return-assign': 'error',
'no-self-compare': 'error',
'no-sequences': 'error',
'no-throw-literal': 'error',
'no-useless-call': 'error',
'no-useless-concat': 'error',
'no-useless-return': 'error',
'prefer-promise-reject-errors': 'error',
radix: 'error',
// ES6+
'prefer-const': 'error',
'no-var': 'error',
'prefer-template': 'error',
'prefer-spread': 'error',
'prefer-rest-params': 'error',
'no-duplicate-imports': 'error',
'no-useless-constructor': 'error',
'no-useless-rename': 'error',
'object-shorthand': ['error', 'always'],
'prefer-arrow-callback': 'error',
'arrow-body-style': ['error', 'as-needed'],
// ==================== WARNINGS (Fix Before PR) ====================
// Console logging (allowed: warn, error, log for debugging)
'no-console': ['warn', { allow: ['warn', 'error', 'log'] }],
// Complexity
complexity: ['warn', { max: 15 }],
'max-depth': ['warn', { max: 4 }],
'max-lines-per-function': ['warn', { max: 100, skipBlankLines: true, skipComments: true }],
'max-params': ['warn', { max: 5 }],
'max-nested-callbacks': ['warn', { max: 4 }],
// Documentation
'require-jsdoc': [
'warn',
{
require: {
FunctionDeclaration: true,
MethodDefinition: true,
ClassDeclaration: true,
},
},
],
'valid-jsdoc': [
'warn',
{
requireReturn: false,
requireParamDescription: false,
requireReturnDescription: false,
},
],
// Style (enforced by Prettier, but ESLint catches some)
'no-trailing-spaces': 'error',
'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1 }],
'eol-last': ['error', 'always'],
'comma-dangle': ['error', 'always-multiline'],
semi: ['error', 'always'],
quotes: ['error', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
},
overrides: [
// Test files - relaxed rules
{
files: ['**/*.test.js', '**/*.spec.js', 'tests/**/*.js'],
env: {
jest: true,
},
rules: {
'no-magic-numbers': 'off',
'max-lines-per-function': 'off',
'require-jsdoc': 'off',
'valid-jsdoc': 'off',
'no-console': 'off',
},
},
// Config files - relaxed rules
{
files: ['*.config.js', '.eslintrc.js', 'vite.config.js', 'vitest.config.js'],
rules: {
'no-magic-numbers': 'off',
'require-jsdoc': 'off',
'valid-jsdoc': 'off',
},
},
],
};