-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.eslintrc.js
More file actions
133 lines (105 loc) · 3.59 KB
/
Copy path.eslintrc.js
File metadata and controls
133 lines (105 loc) · 3.59 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
/**
* ESLint Configuration
*
* Enforces code quality standards with stricter rules for:
* - Type safety
* - Error handling
* - Documentation requirements
*/
module.exports = {
extends: ['expo', 'prettier'],
plugins: ['jest', '@typescript-eslint'],
rules: {
// ============================================================
// Type Safety Rules
// ============================================================
/** Prevent using `any` type - loses type safety */
'@typescript-eslint/no-explicit-any': 'warn',
/** Prevent unsafe argument types */
'@typescript-eslint/no-unsafe-argument': 'warn',
/** Prevent unsafe assignments */
'@typescript-eslint/no-unsafe-assignment': 'warn',
/** Prevent unsafe member access */
'@typescript-eslint/no-unsafe-member-access': 'warn',
/** Prevent unsafe return types */
'@typescript-eslint/no-unsafe-return': 'warn',
/** Prevent unsafe calls */
'@typescript-eslint/no-unsafe-call': 'warn',
// ============================================================
// Code Quality Rules
// ============================================================
/** Prevent unused variables */
'no-unused-vars': 'off', // Use TypeScript version instead
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_', // Allow _prefix for intentionally unused
varsIgnorePattern: '^_',
},
],
/** Prevent console methods in production code */
'no-console': [
'warn',
{
allow: ['warn', 'error'], // Allow warnings and errors
},
],
/** Prevent debugger statements */
'no-debugger': 'error',
// ============================================================
// React/React Native Rules
// ============================================================
/** Prevent missing keys in lists */
'react/jsx-key': 'error',
/** Prevent unused prop types */
'react/no-unused-prop-types': 'warn',
/** Prevent direct state mutation */
'react/no-direct-mutation-state': 'error',
// ============================================================
// Best Practices
// ============================================================
/** Require consistent returns */
'consistent-return': 'warn',
/** Prevent empty blocks */
'no-empty': 'warn',
/** Prevent variable redeclaration */
'no-redeclare': 'error',
/** Prevent self-assignment */
'no-self-assign': 'error',
/** Prevent unnecessary escaping */
'no-useless-escape': 'warn',
// ============================================================
// Jest/Testing Rules
// ============================================================
/** Require test descriptions */
'jest/valid-describe': 'error',
/** Prevent disabled tests */
'jest/no-disabled-tests': 'warn',
/** Prevent focused tests */
'jest/no-focused-tests': 'error',
/** Prevent skipping tests */
'jest/no-skipped-tests': 'warn',
},
// Type-specific overrides
overrides: [
{
// Stricter rules for TypeScript files
files: ['*.ts', '*.tsx'],
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'warn',
},
},
{
// Relaxed rules for test files
files: ['*.test.ts', '*.test.tsx', '*.test.js', '*.test.jsx'],
env: {
jest: true,
},
rules: {
'no-console': 'off', // Allow console.log in tests
},
},
],
};