-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Expand file tree
/
Copy pathoxlint.config.ts
More file actions
1382 lines (1343 loc) Β· 55.2 KB
/
Copy pathoxlint.config.ts
File metadata and controls
1382 lines (1343 loc) Β· 55.2 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { defineConfig } from 'oxlint'
export const isFastLint = process.env.ENABLE_FAST_LINT === 'true'
// Absolute path required: relative jsPlugin paths don't resolve when the config
// is loaded from a different working directory.
const rootDir = new URL('.', import.meta.url).pathname
export const rootIgnorePatterns = [
'oxlint.config.ts',
'tsconfig.json',
'*.tsbuildinfo',
'.bun/**',
'.tamagui/**',
'@types/**',
'types/**',
'**/lcov-report/**',
'**/coverage/**',
'**/node_modules/**',
'**/dist/**',
'**/build/**',
'**/bin/**',
'**/scripts/**',
'**/__generated__/**',
'**/__mocks__/**',
'**/.next/**',
'**/.react-router/**',
'**/.source/**',
'**/.maestro/**',
'**/.storybook/storybook.requires.ts',
'**/babel.*',
'**/vite.*',
'**/vitest.config*',
'**/vitest-setup*',
'**/vitest-package-mocks*',
'**/jest-setup*',
'**/jest-package-mocks*',
'**/webpack.*',
'**/webpack-plugins/**',
'**/.wxt/**',
'**/wxt.config.*',
'**/tailwind-config.*',
// ββ apps/mobile ββ
'apps/mobile/metro.config.js',
'apps/mobile/ReactotronConfig.ts',
'apps/mobile/index.js',
'apps/mobile/.storybook/**',
'apps/mobile/src/polyfills/**',
// ββ apps/web ββ
'apps/web/src/setupTests.ts',
'apps/web/playwright/**',
'apps/web/cypress/**',
'apps/web/public/**',
'apps/web/functions/**',
'apps/web/vite/**',
'apps/web/twist-configs/**',
'apps/web/test-results/**',
'apps/web/.storybook/**',
'apps/web/**/test-utils/**/*',
'apps/web/**/*.config.*',
'apps/web/**/*.d.ts',
// ββ apps/extension ββ
'apps/extension/dev/**',
'apps/extension/webpack*.js',
'apps/extension/jest*.js',
'apps/extension/babel*.js',
// ββ apps/dev-portal ββ
'apps/dev-portal/functions/**',
// ββ apps/mission-control ββ
'apps/mission-control/vite*.ts',
// ββ packages/uniswap ββ
'packages/uniswap/src/abis/types/**',
'packages/uniswap/vite/**',
'packages/uniswap/vitest*.ts',
'packages/uniswap/jest*.js',
'packages/uniswap/babel*.js',
// ββ packages/wallet ββ
'packages/wallet/jest*.js',
'packages/wallet/babel*.js',
// ββ packages/ui ββ
'packages/ui/src/components/icons/**',
'packages/ui/src/components/logos/**',
// ββ packages/api ββ
'packages/api/codegen.ts',
// ββ tools/uniswap-nx ββ
'tools/uniswap-nx/src/generators/**/files/**',
]
// ββ Shared no-restricted-imports definitions ββββββββββββββββββββββββββ
// Used in per-project overrides that customize no-restricted-imports.
// When a project override redefines no-restricted-imports, oxlint replaces the
// root definition entirely β so the override must spread these arrays.
export const sharedRestrictedImportPaths = [
{
name: 'utilities/src/telemetry/analytics/analytics',
message:
'Please only use this for initialization, tests, flushing, and internal usage. Otherwise use `packages/uniswap/src/features/telemetry`',
},
{
name: 'utilities/src/telemetry/trace/Trace',
message: "Please use the Trace in 'uniswap/src/features/telemetry/Trace' for app level usage!",
},
{
name: 'ui/src/components/modal/AdaptiveWebModal',
message:
'Please import Modal from `uniswap/src/components/modals/Modal` instead. Modal uses AdaptiveWebModal under the hood but has extra logic for handling animation, mounting, and dismounting.',
},
{
name: 'react-native',
importNames: ['Switch', 'Keyboard'],
message:
'Use our custom Switch component instead of Switch. Please use dismissNativeKeyboard() for keyboard dismissals.',
},
{
name: 'ui/src/hooks/useDeviceInsets',
importNames: ['useDeviceInsets'],
message: 'Use `useAppInsets` instead.',
},
{
name: 'react-native-safe-area-context',
importNames: ['useSafeAreaInsets'],
message: 'Use our internal useAppInsets hook instead.',
},
{
name: 'react-native-device-info',
importNames: ['getUniqueId'],
message: 'Not supported for web/extension, use `getUniqueId` from `utilities/src/device/getUniqueId` instead.',
},
{
name: 'react-native-dotenv',
message: 'Do not import env vars from react-native-dotenv. Use getConfig() instead.',
},
{
name: 'wallet/src/data/apollo/usePersistedApolloClient',
importNames: ['usePersistedApolloClient'],
message:
"This hook should only be used once at the top level where the React app is initialized. Use `import { useApolloClient } from '@apollo/client'` to get the default apollo client elsewhere.",
},
{
name: 'expo-localization',
message:
'Avoid using due to issue with unsupported locales. Use utilities/src/device/locales.ts getDeviceLocales instead',
},
{
name: 'utilities/src/format/localeBased',
message: 'Use via `useLocalizationContext` instead.',
},
{
name: 'uniswap/src/features/fiatCurrency/conversion',
importNames: ['useFiatConverter'],
message: 'Use via `useLocalizationContext` instead.',
},
{
name: 'uniswap/src/features/language/formatter',
importNames: ['useLocalizedFormatter'],
message: 'Use via `useLocalizationContext` instead.',
},
{
name: 'uniswap/src/features/dataApi/balances/balances',
importNames: ['usePortfolioValueModifiers'],
message: 'Use the wrapper hooks `usePortfolioTotalValue`, `useAccountListData` or `usePortfolioBalances` instead.',
},
{
name: '@gorhom/bottom-sheet',
importNames: ['BottomSheetTextInput'],
message: 'Use our internal BottomSheetTextInput wrapper from /uniswap/src/components/modals/Modal.',
},
{
name: 'expo-haptics',
message:
'Use our internal HapticFeedback wrapper instead: import { HapticFeedback } from packages/uniswap/src/features/settings/useHapticFeedback/types',
},
{
name: '@uniswap/analytics',
importNames: ['sendAnalyticsEvent'],
message: "Please use the typed `sendAnalyticsEvent` in 'uniswap/src/features/telemetry/send'",
},
{
name: '@tamagui/core',
message: "Please import from 'tamagui' directly to prevent mismatches.",
},
{
name: 'i18next',
importNames: ['t'],
message: 'Use `useTranslation()` hook or `i18n.t` instead of importing `t` directly from i18next.',
},
{ name: 'lodash', message: 'Use specific imports like `lodash/map` for tree-shaking.' },
{
name: 'statsig-react',
message: 'Use the internal gating module instead of importing from statsig-react directly.',
},
{
name: 'uniswap/src',
message: 'Avoid importing directly from the uniswap/src barrel which causes circular imports.',
},
{
name: 'wallet/src',
message: 'Avoid importing directly from the wallet/src barrel which causes circular imports.',
},
{
name: '@uniswap/sdk-core',
importNames: ['ChainId'],
message: "Don't use ChainId from @uniswap/sdk-core. Use the UniverseChainId from universe/uniswap.",
},
{
name: 'uniswap/src/features/chains/hooks/useOrderedChainIds',
importNames: ['useOrderedChainIds'],
message: 'Use `useEnabledChains` instead, which returns the ordered chains that are currently enabled.',
},
{
name: 'uniswap/src/features/settings/selectors',
importNames: ['selectIsTestnetModeEnabled'],
message: 'Use `useEnabledChains` instead.',
},
{
name: 'uniswap/src/features/chains/chainInfo',
importNames: ['UNIVERSE_CHAIN_INFO'],
message: 'Use useChainInfo or helpers in packages/uniswap/src/features/chains/utils.ts when possible!',
},
{
name: 'uniswap/src/features/dataApi/balances/balancesRest',
importNames: ['useRESTPortfolioTotalValue'],
message: 'Use the wrapper hooks `usePortfolioTotalValue`, `useAccountListData` or `usePortfolioBalances` instead.',
},
{
name: 'wallet/src/components/ErrorBoundary/restart',
message: 'Use `wallet/src/components/ErrorBoundary/restartApp` instead.',
},
] as const
/** Pattern that blocks deep imports into @universe/* packages. */
export const crossPackageDeepImportPattern = {
group: ['@universe/*/src', '@universe/*/src/*'],
message: 'Deep imports from @universe/* packages are forbidden. Import from the package root instead.',
} as const
export const sharedRestrictedImportPatterns = [
{
group: ['ui/src/assets/icons/*.svg'],
message:
'Please do not import SVG files directly from `ui/src/assets/icons/*.svg`. Use generated icon components instead.',
},
crossPackageDeepImportPattern,
] as const
/**
* Returns restricted import patterns for @universe/* packages that exclude
* the package's own deep imports (which are legitimate internal references).
*/
export function restrictedImportPatternsForUniversePackage(packageName: string) {
return [
...sharedRestrictedImportPatterns.filter((p) => p !== crossPackageDeepImportPattern),
{
group: ['@universe/*/src', '@universe/*/src/*', `!${packageName}/src`, `!${packageName}/src/*`],
message: 'Deep imports from @universe/* packages are forbidden. Import from the package root instead.',
},
]
}
// ββ Shared no-restricted-syntax selectors βββββββββββββββββββββββββββββ
// Used in per-project overrides that customize no-restricted-syntax.
// When a project override redefines no-restricted-syntax, oxlint replaces the
// root definition entirely β so the override must spread these selectors.
// sharedRestrictedSyntaxSelectors applies everywhere the rule is enabled.
export const sharedRestrictedSyntaxSelectors = [
{
selector: "CallExpression[callee.object.name='z'][callee.property.name='any']",
message: 'Avoid using z.any() in favor of more precise custom types.',
},
] as const
// Kept separate so apps that legitimately read `process.env` (e.g. mission-control,
// dev-portal) can opt out of just this selector while keeping the rest of the
// shared selectors enabled.
export const processEnvRestrictedSyntaxSelector = {
selector: "MemberExpression[object.name='process'][property.name='env']",
message: 'Do not read `process.env` directly. Use getConfig() instead.',
} as const
// Shared across every apps/web/src override that redefines no-restricted-syntax
// (e.g. the Portfolio override) β must be spread in, since rule options are not merged.
const webRestrictedSyntaxSelectors = [
{
selector: ':matches(ExportAllDeclaration)',
message: 'Barrel exports bloat the bundle size by preventing tree-shaking.',
},
{
selector: ":matches(Literal[value='NATIVE'])",
message: "Don't use the string 'NATIVE' directly. Use the NATIVE_CHAIN_ID variable from constants/tokens instead.",
},
{
selector:
"ImportDeclaration[source.value='src/nft/components/icons'], ImportDeclaration[source.value='nft/components/icons']",
message: 'Please import icons from nft/components/iconExports instead of directly from icons.tsx',
},
{
selector:
"VariableDeclarator[id.type='ObjectPattern'][init.callee.name='useWeb3React'] > ObjectPattern > Property[key.name='account']",
message: "Do not use account directly from useWeb3React. Use the useAccount hook from 'hooks/useAccount' instead.",
},
{
selector:
"VariableDeclarator[id.type='ObjectPattern'][init.callee.name='useWeb3React'] > ObjectPattern > Property[key.name='chainId']",
message: 'Do not use chainId directly from useWeb3React. Use the useAccount hook instead.',
},
{
selector:
"VariableDeclarator[id.type='ObjectPattern'][init.callee.name='useAccount'] > ObjectPattern > Property[key.name='address']",
message: 'Do not use address directly from useAccount. Access account.address instead.',
},
{
selector:
"TSTypeAssertion[typeAnnotation.typeName.name='Address'], TSAsExpression[typeAnnotation.typeName.name='Address']",
message: 'Do not use type assertions with Address. Use assumeOxAddress or isAddress/getAddress from viem.',
},
] as const
// ββ Shared override fragments ββββββββββββββββββββββββββββββββββββββββ
const jsxPropOrderConfig = [
'error',
{
groups: ['reserved', 'shorthand-prop', 'unknown', 'callback'],
reservedPattern: '^(key|ref)$',
callbackPattern: '^on[A-Z].+',
},
] as const
export default defineConfig({
plugins: ['react', 'typescript', 'import', 'jest', 'vitest', 'unicorn'],
jsPlugins: isFastLint
? []
: [
`${rootDir}config/oxlint-plugins/universe-custom.js`,
'@jambit/eslint-plugin-typed-redux-saga',
'eslint-plugin-security',
'eslint-plugin-no-unsanitized',
// TODO: Remove oxlint-plugin-eslint after oxlint ships native object-shorthand
// (https://github.com/oxc-project/oxc/pull/17688)
'oxlint-plugin-eslint',
],
options: isFastLint
? {}
: {
typeAware: true,
reportUnusedDisableDirectives: 'error',
},
env: {
browser: true,
es2024: true,
node: true,
},
ignorePatterns: rootIgnorePatterns,
rules: {
// ββ complexity ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
complexity: ['error', { max: 30 }],
'no-regex-spaces': 'warn',
'prefer-rest-params': 'error',
'typescript/no-restricted-types': 'error',
'max-depth': ['error', 4],
'max-nested-callbacks': ['error', 3],
'no-sequences': 'warn',
'no-extra-boolean-cast': 'warn',
'no-useless-catch': 'error',
'no-useless-escape': 'warn',
'no-lone-blocks': 'warn',
'typescript/no-unnecessary-type-constraint': 'error',
'no-void': 'warn',
// ββ correctness ββββββββββββββββββββββββββββββββββββββββββββββββββββ
'react/no-children-prop': 'error',
'no-empty-character-class': 'warn',
'no-empty-pattern': 'error',
'no-nonoctal-decimal-escape': 'error',
'no-loss-of-precision': 'error',
'react/forbid-elements': [
'error',
{
forbid: [
{
element: 'div',
message: 'Please avoid using div when possible, even in web code! Use `Flex` or Fragments (`<>`)',
},
],
},
],
'no-self-assign': 'error',
'no-case-declarations': 'error',
'no-unsafe-finally': 'error',
'no-unsafe-optional-chaining': 'error',
'no-unused-vars': [
'error',
{
vars: 'all',
args: 'after-used',
ignoreRestSiblings: true,
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
fix: {
imports: 'safe-fix',
},
},
],
'no-unused-labels': 'error',
'react/exhaustive-deps': ['error', { additionalHooks: '(useAnimatedStyle|useDerivedValue|useAnimatedProps)' }],
'react/rules-of-hooks': 'error',
'use-isnan': 'warn',
'react/jsx-key': 'error',
'for-direction': 'error',
'valid-typeof': 'warn',
'require-yield': 'error',
'typescript/explicit-function-return-type': ['error', { allowExpressions: true }],
'jest/no-disabled-tests': 'error',
'jest/expect-expect': 'error',
'jest/no-conditional-expect': 'off',
'vitest/require-mock-type-parameters': 'off',
// ββ security βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
'react/no-danger': 'error',
'react/no-danger-with-children': 'error',
'no-eval': 'error',
'unicorn/no-new-buffer': 'error',
'unicorn/no-new-array': 'off',
// ββ style ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
'jest/no-export': 'error',
'jest/require-to-throw-message': 'off',
'jest/no-done-callback': 'error',
'jest/valid-title': ['error', { ignoreTypeOfDescribeName: true }],
'typescript/no-namespace': 'error',
'typescript/no-non-null-assertion': 'error',
'no-restricted-imports': [
'error',
{ paths: sharedRestrictedImportPaths, patterns: sharedRestrictedImportPatterns },
],
'no-restricted-globals': [
'error',
{ name: 'defaultStatus', message: 'Use of this global variable is restricted.' },
{ name: 'status', message: 'Use of this global variable is restricted.' },
{ name: 'scroll', message: 'Use of this global variable is restricted.' },
{ name: 'outerHeight', message: 'Use of this global variable is restricted.' },
{ name: 'screenX', message: 'Use of this global variable is restricted.' },
{ name: 'opener', message: 'Use of this global variable is restricted.' },
{ name: 'onfocus', message: 'Use of this global variable is restricted.' },
{ name: 'pageYOffset', message: 'Use of this global variable is restricted.' },
{ name: 'addEventListener', message: 'Use of this global variable is restricted.' },
{ name: 'defaultstatus', message: 'Use of this global variable is restricted.' },
{ name: 'history', message: 'Use of this global variable is restricted.' },
{ name: 'frames', message: 'Use of this global variable is restricted.' },
{ name: 'screenY', message: 'Use of this global variable is restricted.' },
{ name: 'focus', message: 'Use of this global variable is restricted.' },
{ name: 'outerWidth', message: 'Use of this global variable is restricted.' },
{ name: 'opera', message: 'Use of this global variable is restricted.' },
{ name: 'external', message: 'Use of this global variable is restricted.' },
{ name: 'innerHeight', message: 'Use of this global variable is restricted.' },
{ name: 'closed', message: 'Use of this global variable is restricted.' },
{ name: 'frameElement', message: 'Use of this global variable is restricted.' },
{ name: 'scrollY', message: 'Use of this global variable is restricted.' },
{ name: 'self', message: 'Use of this global variable is restricted.' },
{
name: 'chrome',
message: 'Direct `chrome` access is restricted. Use `getChrome()` or `getChromeWithThrow()` instead.',
},
{ name: 'onblur', message: 'Use of this global variable is restricted.' },
{ name: 'find', message: 'Use of this global variable is restricted.' },
{ name: 'parent', message: 'Use of this global variable is restricted.' },
{ name: 'top', message: 'Use of this global variable is restricted.' },
{ name: 'moveBy', message: 'Use of this global variable is restricted.' },
{ name: 'menubar', message: 'Use of this global variable is restricted.' },
{ name: 'length', message: 'Use of this global variable is restricted.' },
{ name: 'onerror', message: 'Use of this global variable is restricted.' },
{ name: 'onresize', message: 'Use of this global variable is restricted.' },
{ name: 'removeEventListener', message: 'Use of this global variable is restricted.' },
{ name: 'onload', message: 'Use of this global variable is restricted.' },
{ name: 'scrollTo', message: 'Use of this global variable is restricted.' },
{ name: 'moveTo', message: 'Use of this global variable is restricted.' },
{ name: 'scrollX', message: 'Use of this global variable is restricted.' },
{ name: 'name', message: 'Use of this global variable is restricted.' },
{ name: 'toolbar', message: 'Use of this global variable is restricted.' },
{ name: 'innerWidth', message: 'Use of this global variable is restricted.' },
{ name: 'location', message: 'Use of this global variable is restricted.' },
{ name: 'locationbar', message: 'Use of this global variable is restricted.' },
{ name: 'scrollBy', message: 'Use of this global variable is restricted.' },
{ name: 'resizeTo', message: 'Use of this global variable is restricted.' },
{ name: 'stop', message: 'Use of this global variable is restricted.' },
{ name: 'scrollbars', message: 'Use of this global variable is restricted.' },
{ name: 'blur', message: 'Use of this global variable is restricted.' },
{ name: 'screenTop', message: 'Use of this global variable is restricted.' },
{ name: 'confirm', message: 'Use of this global variable is restricted.' },
{ name: 'screen', message: 'Use of this global variable is restricted.' },
{ name: 'screenLeft', message: 'Use of this global variable is restricted.' },
{ name: 'event', message: 'Use of this global variable is restricted.' },
{ name: 'onunload', message: 'Use of this global variable is restricted.' },
{ name: 'pageXOffset', message: 'Use of this global variable is restricted.' },
{ name: 'resizeBy', message: 'Use of this global variable is restricted.' },
{ name: 'statusbar', message: 'Use of this global variable is restricted.' },
{ name: 'close', message: 'Use of this global variable is restricted.' },
{ name: 'open', message: 'Use of this global variable is restricted.' },
{ name: 'print', message: 'Use of this global variable is restricted.' },
],
yoda: 'warn',
'no-array-constructor': 'error',
'typescript/prefer-as-const': 'error',
curly: 'warn',
'prefer-const': 'error',
'typescript/prefer-enum-initializers': 'error',
// ββ additional rules βββββββββββββββββββββββββββββββββββββββββββββββ
'guard-for-in': 'error',
'max-lines': ['error', 500],
'max-params': ['error', { max: 2 }],
'react/display-name': 'error',
'react/jsx-curly-brace-presence': ['error', { props: 'never', children: 'never' }],
'react/no-unsafe': 'error',
'react/self-closing-comp': 'error',
'no-unused-expressions': ['error', { allowShortCircuit: true, allowTernary: true }],
'typescript/consistent-return': 'error',
'typescript/no-floating-promises': 'error',
'typescript/no-unsafe-return': 'error',
'typescript/no-unnecessary-condition': ['error', { allowConstantLoopConditions: true }],
'typescript/no-redundant-type-constituents': 'off',
'typescript/unbound-method': ['error', { ignoreStatic: true }],
'typescript/restrict-template-expressions': 'off',
'typescript/no-base-to-string': 'off',
// ββ suspicious βββββββββββββββββββββββββββββββββββββββββββββββββββββ
'no-alert': 'warn',
'no-async-promise-executor': 'error',
'no-bitwise': 'warn',
'no-ex-assign': 'warn',
'no-class-assign': 'error',
'react/jsx-no-comment-textnodes': 'error',
'no-compare-neg-zero': 'error',
'no-console': 'error',
'no-control-regex': 'warn',
'no-debugger': 'warn',
'no-new': 'error',
'no-script-url': 'error',
eqeqeq: ['warn', 'smart'],
'no-duplicate-case': 'error',
'react/jsx-no-duplicate-props': 'error',
'typescript/no-empty-interface': 'error',
'typescript/no-explicit-any': 'error',
'typescript/no-extra-non-null-assertion': 'error',
'typescript/no-var-requires': 'error',
'no-fallthrough': 'warn',
'no-global-assign': 'error',
'no-irregular-whitespace': 'error',
'no-label-var': 'warn',
'no-misleading-character-class': 'error',
'typescript/no-misused-new': 'error',
'no-prototype-builtins': 'error',
'no-self-compare': 'warn',
'no-shadow': 'error',
'no-shadow-restricted-names': 'warn',
'no-sparse-arrays': 'warn',
'typescript/no-unsafe-declaration-merging': 'error',
'typescript/triple-slash-reference': 'error',
'no-useless-backreference': 'error',
'no-var': 'error',
'no-with': 'warn',
// TODO(apps-infra): The following rules were used in eslint or biome but are not currently
// supported by oxlint or require tweaking with a custom plugin. Re-enable when possible.
// 'import/no-unused-modules': 'error', // On the roadmap: https://github.com/oxc-project/oxc/issues/1117
// 'react-native/no-unused-styles': 'error', // Requires @react-native/eslint-plugin
// 'react-native/sort-styles': 'error', // Requires @react-native/eslint-plugin
// 'storybook/recommended': 'error', // Requires @storybook/eslint-plugin v0.8.0 or a storybook upgrade
// ββ jsPlugin rules (excluded when ENABLE_FAST_LINT=true) ββββββββββ
...(!isFastLint && {
// correctness
'import/no-cycle': ['error', { ignoreExternal: true }],
// security
'security/detect-unsafe-regex': 'error',
'security/detect-buffer-noassert': 'error',
'security/detect-child-process': 'error',
'security/detect-disable-mustache-escape': 'error',
'security/detect-non-literal-regexp': 'error',
'security/detect-pseudoRandomBytes': 'error',
'no-unsanitized/method': 'error',
'no-unsanitized/property': 'error',
// TODO: Replace with native object-shorthand after next oxlint update
// (https://github.com/oxc-project/oxc/pull/17688)
'eslint-js/object-shorthand': ['error', 'always'],
// Not implemented natively by oxlint; provided via oxlint-plugin-eslint.
'eslint-js/no-octal-escape': 'warn',
'eslint-js/no-undef-init': 'warn',
'eslint-js/no-restricted-syntax': [
'error',
...sharedRestrictedSyntaxSelectors,
processEnvRestrictedSyntaxSelector,
],
// custom rules (from universe-custom plugin)
'universe-custom/no-unwrapped-t': [
'error',
{ blockedElements: ['Flex', 'AnimatedFlex', 'TouchableArea', 'Trace'] },
],
'universe-custom/custom-map-sort': 'error',
'universe-custom/no-hex-string-casting': 'error',
'universe-custom/no-transform-percentage-strings': 'error',
'universe-custom/enforce-query-options-result': [
'error',
{ importPath: 'utilities/src/reactQuery/queryOptions' },
],
'universe-custom/no-redux-modals': 'error',
'universe-custom/no-tolowercase-address-currencyid': 'warn',
'universe-custom/no-platform-gate-in-chain-flags': 'error',
// typed-redux-saga
'@jambit/typed-redux-saga/use-typed-effects': 'error',
'@jambit/typed-redux-saga/delegate-effects': 'error',
}),
},
overrides: [
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// SHARED OVERRIDES (apply across all projects)
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// ββ Migration files: relax type rules βββββββββββββββββββββββββββββ
{
files: ['**/*migration*', '**/*Migration*', '**/migrations/**/*.ts'],
rules: {
'typescript/explicit-function-return-type': 'off',
'typescript/no-explicit-any': 'off',
'typescript/no-non-null-assertion': 'off',
'typescript/no-unsafe-return': 'off',
},
},
// ββ Saga files ββββββββββββββββββββββ
{
files: ['**/*saga.ts', '**/*saga.tsx', '**/*Saga.ts', '**/*Saga.tsx'],
rules: {
// redux-saga's call/fork/etc. bind the receiver via the
// [obj, method] array form, an idiom unbound-method can't model, so it
// false-positives on the bound method reference. Disable it for sagas.
'typescript/unbound-method': 'off',
},
},
// ββ Logger, scripts, devtools: allow console ββββββββββββββββββββββ
{
files: [
'**/logger/**',
'**/scripts/**',
'**/setupTests.*',
'**/sideEffects.*',
'**/devtools.*',
'**/wxt.config.*',
'**/e2e/fixtures/**',
'tools/**',
],
rules: {
'no-console': 'off',
},
},
// ββ Storybook: allow alerts βββββββββββββββββββββββββββββββββββββββ
{
files: ['**/*.stories.*', '**/.storybook/**'],
rules: {
'no-alert': 'off',
},
},
// ββ JavaScript files: allow console βββββββββββββββββββββββββββββββ
{
files: ['**/*.js', '**/*.jsx'],
rules: {
'no-console': 'off',
},
},
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// PER-PROJECT OVERRIDES
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// ββ apps/cli, config-cli ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
{
files: ['apps/cli/**', 'packages/config-cli/**'],
rules: {
'no-console': 'off',
'typescript/explicit-function-return-type': 'off',
// cli legitimately reads process.env directly; redefine the rule
// without processEnvRestrictedSyntaxSelector.
...(!isFastLint && {
'eslint-js/no-restricted-syntax': ['error', ...sharedRestrictedSyntaxSelectors],
}),
},
},
...(!isFastLint
? [
{
files: ['apps/cli/**/*.ts', 'apps/cli/**/*.tsx'],
rules: {
'universe-custom/no-relative-import-paths': [
'error' as const,
{ allowSameFolder: false, prefix: '@universe/cli' },
],
},
},
]
: []),
// ββ apps/dev-portal βββββββββββββββββββββββββββββββββββββββββββββββ
{
files: ['apps/dev-portal/**'],
rules: {
'typescript/explicit-function-return-type': 'off',
'react/forbid-elements': 'off',
'max-params': 'off',
'max-lines': 'off',
'typescript/consistent-return': 'off',
'typescript/no-floating-promises': 'off',
'typescript/no-unnecessary-condition': 'off',
// dev-portal legitimately reads process.env at the SSR boundary; redefine
// the rule without processEnvRestrictedSyntaxSelector.
...(!isFastLint && {
'eslint-js/no-restricted-syntax': ['error', ...sharedRestrictedSyntaxSelectors],
}),
},
},
...(!isFastLint
? [
{
files: ['apps/dev-portal/**/*.ts', 'apps/dev-portal/**/*.tsx'],
rules: {
'universe-custom/no-relative-import-paths': ['error' as const, { allowSameFolder: false }],
},
},
]
: []),
// ββ apps/extension ββββββββββββββββββββββββββββββββββββββββββββββββ
{
files: ['apps/extension/**'],
rules: {
'typescript/explicit-function-return-type': 'off',
'no-restricted-imports': [
'error',
{
paths: [
...sharedRestrictedImportPaths,
{
name: 'ethers',
message: "Please import from '@ethersproject/module' directly to support tree-shaking.",
},
],
patterns: [...sharedRestrictedImportPatterns],
},
],
'no-restricted-globals': 'off',
...(!isFastLint && {
'eslint-js/no-restricted-syntax': [
'error',
...sharedRestrictedSyntaxSelectors,
processEnvRestrictedSyntaxSelector,
{
selector:
"CallExpression[callee.property.name='sendMessage'][callee.object.property.name='tabs'][callee.object.object.name='chrome']",
message:
'Use a message channel from apps/extension/src/background/messagePassing/messageChannels.ts instead of chrome.tabs.sendMessage.',
},
{
selector:
"CallExpression[callee.property.name='sendMessage'][callee.object.property.name='runtime'][callee.object.object.name='chrome']",
message:
'Use a message channel from apps/extension/src/background/messagePassing/messageChannels.ts instead of chrome.runtime.sendMessage.',
},
{
selector:
"CallExpression[callee.property.name='addListener'][callee.object.property.name='onMessage'][callee.object.object.property.name='runtime'][callee.object.object.object.name='chrome']",
message: 'Use a message channel instead of chrome.runtime.onMessage.addListener.',
},
{
selector:
"CallExpression[callee.property.name='removeListener'][callee.object.property.name='onMessage'][callee.object.object.property.name='runtime'][callee.object.object.object.name='chrome']",
message: 'Use a message channel instead of chrome.runtime.onMessage.removeListener.',
},
],
}),
},
},
...(!isFastLint
? [
{
files: ['apps/extension/**/*.ts', 'apps/extension/**/*.tsx'],
rules: {
'universe-custom/no-relative-import-paths': ['error' as const, { allowSameFolder: false }],
},
},
]
: []),
{
files: ['apps/extension/**/contentScript/**'],
rules: {
'no-restricted-globals': [
'error',
{
name: 'chrome',
message: 'Direct `chrome` access is restricted. Use `getChrome()` or `getChromeWithThrow()` instead.',
},
],
},
},
...(!isFastLint
? [
{
files: ['apps/extension/webpack*.js', 'apps/extension/webpack-plugins/**'],
rules: {
'security/detect-non-literal-regexp': 'off' as const,
'no-console': 'off' as const,
},
},
]
: [
{
files: ['apps/extension/webpack*.js', 'apps/extension/webpack-plugins/**'],
rules: {
'no-console': 'off' as const,
},
},
]),
{
files: ['apps/extension/**/extensionMigrations.ts', 'apps/extension/**/extensionMigrationsTests.ts'],
rules: {
'typescript/prefer-enum-initializers': 'off',
'typescript/no-non-null-assertion': 'off',
'typescript/no-empty-interface': 'off',
'typescript/no-explicit-any': 'off',
},
},
// ββ apps/mission-control ββββββββββββββββββββββββββββββββββββββββββ
{
files: ['apps/mission-control/**'],
rules: {
'typescript/explicit-function-return-type': 'off',
'react/forbid-elements': 'off',
'max-params': 'off',
'max-lines': 'off',
'jest/no-disabled-tests': 'off',
// mission-control legitimately reads process.env at the SSR boundary;
// redefine the rule without processEnvRestrictedSyntaxSelector.
...(!isFastLint && {
'eslint-js/no-restricted-syntax': ['error', ...sharedRestrictedSyntaxSelectors],
}),
},
},
{
files: ['apps/mission-control/**/*.ts', 'apps/mission-control/**/*.tsx'],
rules: {
'typescript/no-floating-promises': 'off',
'typescript/no-unnecessary-condition': 'off',
...(!isFastLint && {
'universe-custom/no-relative-import-paths': ['error', { allowSameFolder: false }],
}),
},
},
...(!isFastLint
? [
{
files: ['apps/mission-control/api/**/*.ts'],
rules: {
'universe-custom/no-relative-import-paths': 'off' as const,
},
},
]
: []),
{
files: [
'apps/mission-control/**/__tests__/**/*.ts',
'apps/mission-control/**/__tests__/**/*.tsx',
'apps/mission-control/**/*.test.ts',
'apps/mission-control/**/*.test.tsx',
],
rules: { 'react/no-children-prop': 'off' },
},
// ββ apps/mobile βββββββββββββββββββββββββββββββββββββββββββββββββββ
{
files: ['apps/mobile/**'],
rules: {
'typescript/explicit-function-return-type': 'off',
'no-restricted-imports': [
'error',
{
paths: [
...sharedRestrictedImportPaths,
{
name: 'react-router',
message: 'Do not import react-router in native code. Use react-navigation instead.',
},
{
name: 'statsig-react-native',
message: 'Use the internal gating module instead of importing from statsig-react-native directly.',
},
],
patterns: [
...sharedRestrictedImportPatterns,
{
group: ['@ethersproject/*', '!@ethersproject/bignumber'],
message: "Import from 'ethers' directly instead of '@ethersproject/*' sub-packages.",
},
],
},
],
...(!isFastLint && {
'universe-custom/enum-member-naming': 'error',
'universe-custom/no-transform-percentage-strings': 'error',
}),
},
},
...(!isFastLint
? [
{
files: ['apps/mobile/**/*.ts', 'apps/mobile/**/*.tsx'],
rules: {
'universe-custom/no-relative-import-paths': ['error' as const, { allowSameFolder: false, prefix: 'src' }],
'universe-custom/no-nested-component-definitions': 'error' as const,
'universe-custom/jsx-prop-order': jsxPropOrderConfig,
},
},
]
: []),
{
files: ['apps/mobile/**/*saga*.ts', 'apps/mobile/**/*Saga.ts', 'apps/mobile/**/handleDeepLink.ts'],
rules: { 'typescript/prefer-enum-initializers': 'off' },
},
{
files: ['apps/mobile/migrations.ts'],
rules: {
'typescript/prefer-enum-initializers': 'off',
'typescript/no-non-null-assertion': 'off',
'typescript/no-empty-interface': 'off',
'typescript/no-explicit-any': 'off',
},
},
{
files: ['apps/mobile/.maestro/scripts/**'],
rules: {
'no-restricted-imports': 'off',
curly: 'off',
'no-console': 'off',
'no-lone-blocks': 'off',
'no-case-declarations': 'off',
'no-unused-vars': 'off',
},
},
// ββ apps/web ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
{
files: ['apps/web/**'],
rules: {
'typescript/explicit-function-return-type': 'off',
'typescript/no-floating-promises': 'off',
},
},
...(!isFastLint
? [
{
files: ['apps/web/src/**/*.ts', 'apps/web/src/**/*.tsx'],
rules: {
'universe-custom/no-relative-import-paths': [
'error' as const,
{ allowSameFolder: false, rootDir: 'src' },
],
'universe-custom/import-boundary': 'error' as const,
'universe-custom/no-direct-viem-ethers-import': 'error' as const,
},
},
]
: []),
...(!isFastLint
? [
{
files: ['apps/web/src/**/*.ts', 'apps/web/src/**/*.tsx'],
rules: {
'eslint-js/no-restricted-syntax': [
'error' as const,
...sharedRestrictedSyntaxSelectors,
processEnvRestrictedSyntaxSelector,
...webRestrictedSyntaxSelectors,
],
},
},
{
files: ['apps/web/src/pages/Portfolio/**'],
rules: {
'eslint-js/no-restricted-syntax': [
'error' as const,
...sharedRestrictedSyntaxSelectors,
processEnvRestrictedSyntaxSelector,
...webRestrictedSyntaxSelectors,
{
selector: "CallExpression[callee.name='useAccount']",
message:
"Do not call 'useAccount' in portfolio pages. Use 'pages/Portfolio/hooks/usePortfolioAddress' instead.",
},
],
},