-
Notifications
You must be signed in to change notification settings - Fork 1
/
.eslintrc.js
143 lines (133 loc) · 4.59 KB
/
.eslintrc.js
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
// https://docs.expo.dev/guides/using-eslint/
module.exports = {
extends: [
// Base configurations
'expo',
'@react-native',
'eslint:recommended',
'prettier',
// React and TypeScript
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/jsx-runtime',
// Accessibility, Localization, and Utility Libraries
'plugin:react-native-a11y/all',
'plugin:lingui/recommended',
'plugin:lodash/recommended',
],
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
'react',
'lodash',
'lingui',
'simple-import-sort',
'prettier',
],
rules: {
// Formatting and style
'prettier/prettier': 'error',
// General JavaScript rules
'no-use-before-define': 'off', // Disabled due to TypeScript rules
'no-var': 'error', // Enforce modern `let` and `const`
'dot-notation': 'warn', // Prefer dot notation where possible
// TypeScript-specific rules
'@typescript-eslint/ban-ts-comment': 'off', // Allow `@ts-ignore` comments
'@typescript-eslint/no-var-requires': 'off', // Allow `require` usage
'@typescript-eslint/explicit-function-return-type': 'off', // Allow function return to not be typed
'@typescript-eslint/no-use-before-define': 'off', // Allow variable declaration before usage
'@typescript-eslint/no-explicit-any': 'warn', // Allow `any` type
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', destructuredArrayIgnorePattern: '^_' },
],
// Enforce consistent type imports
'@typescript-eslint/consistent-type-imports': [
'error',
{ fixStyle: 'inline-type-imports' },
],
// Import/export rules
'import/namespace': ['error', { allowComputed: true }], // Enforces names exist at the time they are dereferenced, but allowing computed namespace member reference
// Enforce consistent import order
'import/order': [
'error',
{
pathGroups: [
{
pattern: '{~*,~*/**}',
group: 'internal',
position: 'after',
},
],
groups: [
['builtin', 'external', 'internal'],
['parent', 'sibling', 'index'],
],
'newlines-between': 'always',
},
],
// React-specific rules
'react/prop-types': 'off', // Not using PropTypes with TypeScript
'react-hooks/rules-of-hooks': 'error', // Enforce correct Hook usage
'react-hooks/exhaustive-deps': 'warn', // Check effect dependencies
// Lodash-specific rules
'lodash/import-scope': 'error', // Enforce scoped imports
'lodash/prefer-lodash-method': 'off', // Prevents forcing Lodash methods over Native methods
'lodash/prefer-lodash-typecheck': 'off', // Prevents forcing Lodash methods over Native methods
'lodash/prefer-constant': 'off', // Prevents forcing Lodash methods over Native methods
'lodash/prefer-noop': 'off', // Prevents forcing Lodash methods over Native methods
'lodash/prop-shorthand': 'off', // Prevents the use of the _ callback shorthand
// Lingui localization rules
'lingui/no-unlocalized-strings': [
// Ensures that all string literals, templates, and JSX text are wrapped using <Trans>, t, or msg for localization
'error',
{
ignore: [
// Ignore strings that don’t match specific patterns
'^(?![A-Z].*|\\w+\\s\\w+).+$', // Non-uppercase or single-word strings
'^[A-Z0-9_-]+$', // Ignore UPPERCASE strings
],
ignoreNames: [
{ regex: { pattern: 'className', flags: 'i' } },
{ regex: { pattern: '^[A-Z0-9_-]+$' } }, // Ignore UPPERCASE names
'targetName',
'styleName',
'src',
'srcSet',
'type',
'id',
'width',
'height',
'displayName',
'Authorization',
],
ignoreFunctions: [
'styled',
'cva',
'cn',
'track',
'Error',
'console.*',
'*headers.set',
'*.addEventListener',
'*.removeEventListener',
'*.postMessage',
'*.getElementById',
'*.dispatch',
'*.commit',
'*.includes',
'*.indexOf',
'*.endsWith',
'*.startsWith',
'require',
'useState',
],
},
],
// Accessibility rules
// Custom accessibility rules for React Native (provided by react-native-a11y plugin)
'react-native-a11y/has-accessibility-hint': 'warn',
},
ignorePatterns: ['/dist/*', '*.d.ts'],
};