-
Notifications
You must be signed in to change notification settings - Fork 625
Expand file tree
/
Copy patheslint.config.mjs
More file actions
165 lines (153 loc) · 4.52 KB
/
eslint.config.mjs
File metadata and controls
165 lines (153 loc) · 4.52 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
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import antfu from '@antfu/eslint-config';
import betterTailwindcss from 'eslint-plugin-better-tailwindcss';
import i18nJsonPlugin from 'eslint-plugin-i18n-json';
import reactCompiler from 'eslint-plugin-react-compiler';
import testingLibrary from 'eslint-plugin-testing-library';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
export default antfu(
{
// Enable React and TypeScript support
react: true,
typescript: true,
// Disable JSON processing for translation files (handled by i18n-json plugin)
jsonc: false,
// Use ESLint Stylistic for formatting
stylistic: {
indent: 2,
quotes: 'single',
semi: true,
},
// Global ignores
ignores: [
'dist/*',
'node_modules',
'__tests__/',
'coverage',
'.expo',
'.expo-shared',
'android',
'ios',
'.vscode',
'docs/',
'cli/',
'expo-env.d.ts',
'migration/*',
],
},
// Custom rules
{
rules: {
'max-params': ['error', 3],
'max-lines-per-function': ['error', 110],
'react/display-name': 'off',
'react/no-inline-styles': 'off',
'react/destructuring-assignment': 'off',
'react/require-default-props': 'off',
'react-refresh/only-export-components': 'warn', // Too strict for React Native
'unicorn/filename-case': [
'error',
{
case: 'kebabCase',
ignore: [
'/android',
'/ios',
'README.md',
'README-project.md',
'ISSUE_TEMPLATE.md',
'PULL_REQUEST_TEMPLATE.md',
],
},
],
'node/prefer-global/process': 'off', // process is commonly used in React Native configs
'ts/no-require-imports': 'off', // Sometimes needed for mocks
'ts/no-use-before-define': 'off', // Allow forward references in React components
'no-console': 'off', // Console is useful for debugging
'no-cond-assign': 'off', // Allow assignment in conditions when intentional
'regexp/no-super-linear-backtracking': 'off', // Relax regex performance rules
'regexp/no-unused-capturing-group': 'off', // Allow unused capturing groups
},
},
// TypeScript-specific rules
{
files: ['**/*.ts', '**/*.tsx'],
rules: {
'ts/consistent-type-definitions': ['error', 'type'], // Prefer type over interface
'react-hooks/refs': 'off', // Allow useRef without exhaustive-deps
'ts/consistent-type-imports': [
'warn',
{
prefer: 'type-imports',
fixStyle: 'inline-type-imports',
disallowTypeAnnotations: true,
},
],
},
},
// Better TailwindCSS plugin
{
files: ['**/*.{js,jsx,ts,tsx}'],
...betterTailwindcss.configs.recommended,
settings: {
'better-tailwindcss': {
entryPoint: path.resolve(__dirname, './src/global.css'),
},
},
rules: {
...betterTailwindcss.configs.recommended.rules,
'better-tailwindcss/no-unnecessary-whitespace': 'warn',
'better-tailwindcss/no-unknown-classes': 'warn',
'better-tailwindcss/enforce-consistent-line-wrapping': 'off', // Can be too strict for some cases
},
},
// React Compiler plugin
{
plugins: {
'react-compiler': reactCompiler,
},
rules: {
'react-compiler/react-compiler': 'error',
},
},
// i18n JSON validation
{
files: ['src/translations/*.json'],
plugins: { 'i18n-json': i18nJsonPlugin },
processor: {
meta: { name: '.json' },
...i18nJsonPlugin.processors['.json'],
},
rules: {
...i18nJsonPlugin.configs.recommended.rules,
'i18n-json/valid-message-syntax': [
2,
{
syntax: path.resolve(
__dirname,
'./scripts/i18next-syntax-validation.js',
),
},
],
'i18n-json/valid-json': 2,
'i18n-json/sorted-keys': [2, { order: 'asc', indentSpaces: 2 }],
'i18n-json/identical-keys': [
2,
{ filePath: path.resolve(__dirname, './src/translations/en.json') },
],
// Disable conflicting rules for i18n JSON files
'style/semi': 'off',
'style/comma-dangle': 'off',
'style/quotes': 'off',
'unused-imports/no-unused-vars': 'off',
},
},
// Testing Library rules
{
files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
plugins: { 'testing-library': testingLibrary },
rules: {
...testingLibrary.configs.react.rules,
},
},
);