forked from Mentra-Community/MentraOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.mjs
More file actions
176 lines (164 loc) · 5.16 KB
/
eslint.config.mjs
File metadata and controls
176 lines (164 loc) · 5.16 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
166
167
168
169
170
171
172
173
174
175
176
import js from "@eslint/js"
import globals from "globals"
import tseslint from "typescript-eslint"
import pluginReact from "eslint-plugin-react"
import pluginReactNative from "eslint-plugin-react-native"
import pluginReactotron from "eslint-plugin-reactotron"
import pluginPrettier from "eslint-plugin-prettier"
import prettierConfig from "eslint-config-prettier"
import expoConfig from "eslint-config-expo/flat.js"
import {defineConfig} from "eslint/config"
export default defineConfig([
// Recommended configs
expoConfig,
js.configs.recommended,
...tseslint.configs.recommended,
pluginReact.configs.flat.recommended,
pluginReact.configs.flat["jsx-runtime"],
prettierConfig,
// custom config:
{
files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"],
ignores: ["eslint.config.mjs", "metro.config.js"],
plugins: {
"@typescript-eslint": tseslint.plugin,
"react": pluginReact,
"react-native": pluginReactNative,
"reactotron": pluginReactotron,
"prettier": pluginPrettier,
},
languageOptions: {
globals: {
...globals.node,
...globals.browser,
__DEV__: "readonly", // React Native global
},
parser: tseslint.parser,
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
settings: {
"react": {
version: "detect", // Automatically detect the React version
},
"import/resolver": {
typescript: {
project: ["./mobile/tsconfig.json", "./cloud/tsconfig.json"],
},
},
},
rules: {
// Prettier
"prettier/prettier": "error",
// TypeScript
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
},
],
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-empty-object-type": "warn",
"@typescript-eslint/no-require-imports": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/array-type": "off",
// React
"react/prop-types": "off",
// React Native rules are scoped to RN files via an overrides block below
// Reactotron
"reactotron/no-tron-in-production": "error",
// Core ESLint
"prefer-const": "off",
"no-use-before-define": "off",
"comma-dangle": "off",
"no-global-assign": "off",
"quotes": "off",
"space-before-function-paren": "off",
"no-case-declarations": "warn",
"no-restricted-imports": [
"error",
{
paths: [
{
name: "react",
importNames: ["default"],
message: "Import named exports from 'react' instead / don't import React.",
},
{
name: "react-native",
importNames: ["StyleSheet"],
message: "Do not import StyleSheet from 'react-native'. Use ThemedStyles / the useTheme() hook instead.",
},
{
name: "expo-router",
importNames: ["useRouter"],
message: "Do not use useRouter from expo-router. Use our useNavigationHistory hook instead.",
},
{
name: "react-native",
importNames: ["Text"],
message: "Do not import Text from 'react-native'. Use the Ignite component with the tx prop instead.",
},
],
patterns: [
{
group: ["../*"],
message: "Use @/ path aliases instead of relative imports",
},
],
},
],
// Disabled: import/order causes mass file changes across PRs
// "import/order": "off",
},
},
// Jest setup files configuration
{
files: ["**/jest.setup.js", "**/jest.config.js", "**/*.test.{js,ts,jsx,tsx}", "**/*.spec.{js,ts,jsx,tsx}"],
languageOptions: {
globals: {
...globals.jest,
},
},
},
// React Native-only rules (scoped override)
// NOTE: eslint-plugin-react-native rules were being applied to web code (e.g., the console),
// triggering RN-only checks like react-native/no-raw-text in regular React. The plugin does not
// auto-detect platform, so we explicitly scope these rules to RN files and paths.
{
files: ["mobile/**/*.{js,ts,jsx,tsx}", "**/*.native.{js,ts,jsx,tsx}"],
rules: {
"react-native/no-unused-styles": "error",
"react-native/split-platform-components": "warn",
"react-native/no-inline-styles": "warn",
"react-native/no-color-literals": "off",
"react-native/no-raw-text": "error",
},
},
// Ignore patterns
{
ignores: [
// Global ignores
"**/node_modules/**",
"**/dist/**",
"**/build/**",
"**/coverage/**",
"**/.vscode/**",
// Mobile-specific ignores
"mobile/ios/**",
"mobile/android/**",
"mobile/.expo/**",
"mobile/ignite/ignite.json",
"mobile/package.json",
// You might also want to add these common RN ignores
"mobile/**/*.gradle",
"mobile/**/*.ipa",
"mobile/**/*.apk",
"mobile/**/*.aab",
],
},
])