-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy patheslint.config.mjs
More file actions
140 lines (133 loc) · 4.27 KB
/
eslint.config.mjs
File metadata and controls
140 lines (133 loc) · 4.27 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
// @ts-check
import path from 'node:path';
import {fileURLToPath} from 'node:url';
import pluginReact from '@eslint-react/eslint-plugin';
import {fixupPluginRules, includeIgnoreFile} from '@eslint/compat';
import pluginJs from '@eslint/js';
import pluginQuery from '@tanstack/eslint-plugin-query';
import * as tsParser from '@typescript-eslint/parser';
import pluginJest from 'eslint-plugin-jest';
import pluginReactNative from 'eslint-plugin-react-native';
import pluginTestingLibrary from 'eslint-plugin-testing-library';
import pluginReactHooks from 'eslint-plugin-react-hooks';
import pluginReactCompiler from 'eslint-plugin-react-compiler';
import globals from 'globals';
import pluginTs from 'typescript-eslint';
const gitignorePath = path.join(
path.dirname(fileURLToPath(import.meta.url)),
'.gitignore',
);
const gitExcludePath = path.join(
path.dirname(fileURLToPath(import.meta.url)),
'.git',
'info',
'exclude',
);
const toolingConfig = pluginTs.config({
name: 'tooling',
files: [
'*.config.{js,mjs,cjs}',
'scripts/*.{js,mjs,cjs}',
'expo-config-plugins/*.{js,mjs,cjs}',
'expo-config-plugins/**/*.{js,mjs,cjs}',
],
languageOptions: {
globals: {
...globals.node,
...globals.nodeBuiltin,
...globals.worker,
},
},
});
const backendConfig = pluginTs.config({
name: 'backend',
files: ['src/backend/**/*.{js,ts}'],
extends: [pluginTs.configs.recommended],
languageOptions: {
globals: {
...globals.node,
...globals.nodeBuiltin,
...globals.worker,
},
},
});
const frontendConfig = pluginTs.config(
{
name: 'frontend',
files: ['src/frontend/**/*.{js,jsx,ts,tsx}'],
extends: [
pluginTs.configs.recommended,
pluginQuery.configs['flat/recommended'],
pluginReact.configs['recommended-typescript'],
pluginReact.configs['disable-dom'],
pluginReactCompiler.configs['recommended'],
pluginReactHooks.configs.flat['recommended-latest'],
// https://github.com/facebook/react-native/issues/42996#issuecomment-2275994981
{
name: 'eslint-plugin-react-native',
plugins: {
'react-native': fixupPluginRules({
// @ts-expect-error Incorrect typing from dep
rules: pluginReactNative.rules,
}),
},
rules: pluginReactNative.configs.all.rules,
},
],
rules: {
// More noise than signal
'@eslint-react/hooks-extra/no-direct-set-state-in-use-effect': 'off',
// Some React Native libraries use the subscription return approach
'@eslint-react/web-api/no-leaked-event-listener': 'off',
// Not relevant for React Native
'@eslint-react/web-api/no-leaked-resize-observer': 'off',
// useContext is still valid
'@eslint-react/no-use-context': 'off',
// There are some cases in app code when it's needed
'@typescript-eslint/no-require-imports': 'off',
// We want to strictly adhere
'react-hooks/exhaustive-deps': 'error',
// We want to strictly adhere
'react-hooks/rules-of-hooks': 'error',
// Doesn't work well with custom components that wrap Text component
'react-native/no-raw-text': 'off',
// We only work on Android for now
'react-native/split-platform-components': 'off',
// Relatively harmless
'react-native/no-color-literals': 'off',
// Relatively harmless
'react-native/no-inline-styles': 'off',
// Relatively harmless
'react-native/sort-styles': 'off',
},
languageOptions: {
parser: tsParser,
},
},
{
name: 'tests',
files: [
'src/frontend/**/*.test.{js,jsx,mts,ts,tsx}',
'src/frontend/**/__mocks__/**',
],
extends: [
pluginJest.configs['flat/recommended'],
pluginTestingLibrary.configs['flat/react'],
],
rules: {
// Mostly conventional and doesn't have significant impact on how tests work
'testing-library/render-result-naming-convention': 'off',
'@eslint-react/hooks-extra/no-unnecessary-use-prefix': 'off',
'@eslint-react/hooks-extra/no-useless-custom-hooks': 'off',
},
},
);
export default pluginTs.config(
{ignores: ['e2e/**/*']},
includeIgnoreFile(gitignorePath),
includeIgnoreFile(gitExcludePath),
pluginJs.configs.recommended,
toolingConfig,
backendConfig,
frontendConfig,
);