-
Notifications
You must be signed in to change notification settings - Fork 279
Expand file tree
/
Copy patheslint.config.js
More file actions
1168 lines (1111 loc) · 36.3 KB
/
Copy patheslint.config.js
File metadata and controls
1168 lines (1111 loc) · 36.3 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, globalIgnores } from 'eslint/config';
import js from '@eslint/js';
import tseslint from 'typescript-eslint';
import reactPlugin from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
import jsxA11y from 'eslint-plugin-jsx-a11y';
import tailwindcss from 'eslint-plugin-tailwindcss';
import sonarjs from 'eslint-plugin-sonarjs';
import simpleImportSort from 'eslint-plugin-simple-import-sort';
import importPlugin from 'eslint-plugin-import';
import security from 'eslint-plugin-security';
import boundaries from 'eslint-plugin-boundaries';
import eslintComments from '@eslint-community/eslint-plugin-eslint-comments';
import eslintConfigPrettier from 'eslint-config-prettier/flat';
import globals from 'globals';
export default defineConfig([
// Global ignores
globalIgnores([
'dist/**',
'dist-electron/**',
'build/**',
'node_modules/**',
'*.config.js',
'*.config.cjs',
'*.config.ts',
'out/**',
]),
// Base ESLint recommended rules
js.configs.recommended,
// TypeScript-ESLint recommended with type checking + stylistic
// Using recommended (not strict) for a balanced approach
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.stylisticTypeChecked,
// SonarJS - Code quality and bug detection rules
sonarjs.configs.recommended,
// Security - Catch common security mistakes in AI-generated code
security.configs.recommended,
// TypeScript parser options for type-aware linting
{
name: 'typescript-parser-options',
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
// Import plugin configuration - Main/Preload (uses tsconfig.node.json)
{
name: 'import-plugin-main',
files: ['src/main/**/*.ts', 'src/preload/**/*.ts'],
plugins: {
import: importPlugin,
},
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true,
project: './tsconfig.node.json',
},
},
},
rules: {
'import/no-cycle': ['error', { maxDepth: 3, ignoreExternal: true }],
'import/no-unresolved': 'error',
'import/no-default-export': 'warn',
},
},
// Import plugin configuration - Renderer (uses tsconfig.json)
{
name: 'import-plugin-renderer',
files: ['src/renderer/**/*.{ts,tsx}', 'src/features/**/*.{ts,tsx}'],
plugins: {
import: importPlugin,
},
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true,
project: './tsconfig.json',
},
},
},
rules: {
'import/no-cycle': ['error', { maxDepth: 3, ignoreExternal: true }],
'import/no-unresolved': 'error',
'import/no-default-export': 'warn',
},
},
// Feature-specific architecture guard rails - recent-projects
{
name: 'feature-recent-projects-public-entrypoints',
files: ['src/**/*.{ts,tsx}'],
ignores: ['src/features/recent-projects/**/*'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: [
'@features/recent-projects/contracts/**',
'@features/recent-projects/core/**',
'@features/recent-projects/main/**',
'@features/recent-projects/preload/**',
'@features/recent-projects/renderer/**',
],
message:
'Import recent-projects only through its public entrypoints: @features/recent-projects/contracts, @features/recent-projects/main, @features/recent-projects/preload, or @features/recent-projects/renderer.',
},
],
},
],
},
},
{
name: 'feature-recent-projects-core-domain-guards',
files: ['src/features/recent-projects/core/domain/**/*.ts'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: [
'@features/recent-projects/core/application/**',
'@features/recent-projects/main/**',
'@features/recent-projects/preload/**',
'@features/recent-projects/renderer/**',
'@main/**',
'@renderer/**',
'@preload/**',
'electron',
'fastify',
'child_process',
'node:child_process',
],
message:
'recent-projects core/domain must stay side-effect free and cannot depend on application, adapters, infrastructure, or platform code.',
},
],
},
],
},
},
{
name: 'feature-recent-projects-core-application-guards',
files: ['src/features/recent-projects/core/application/**/*.ts'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: [
'@features/recent-projects/main/**',
'@features/recent-projects/preload/**',
'@features/recent-projects/renderer/**',
'@renderer/**',
'electron',
'fastify',
'child_process',
'node:child_process',
],
message:
'recent-projects core/application may depend only on domain, contracts, and application ports - not on adapters or runtime frameworks.',
},
],
},
],
},
},
{
name: 'feature-recent-projects-preload-guards',
files: ['src/features/recent-projects/preload/**/*.ts'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: [
'@features/recent-projects/main/**',
'@main/**',
'@renderer/**',
],
message:
'recent-projects preload may depend only on contracts and preload-local bridge helpers.',
},
],
},
],
},
},
{
name: 'feature-recent-projects-renderer-ui-guards',
files: ['src/features/recent-projects/renderer/ui/**/*.tsx'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: [
'@renderer/api',
'@renderer/api/**',
'@renderer/store',
'@renderer/store/**',
'@main/**',
'electron',
],
message:
'recent-projects renderer/ui must stay presentational. Move transport, store access, and navigation logic into hooks or adapters.',
},
],
},
],
},
},
{
name: 'feature-organizations-core-domain-guards',
files: ['src/features/organizations/core/domain/**/*.ts'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: [
'@features/organizations/core/application',
'@features/organizations/core/application/**',
'@features/organizations/main',
'@features/organizations/main/**',
'@features/organizations/preload',
'@features/organizations/preload/**',
'@features/organizations/renderer',
'@features/organizations/renderer/**',
'@main',
'@main/**',
'@renderer',
'@renderer/**',
'@preload',
'@preload/**',
'electron',
'fastify',
'child_process',
'node:child_process',
],
message:
'organizations core/domain must stay side-effect free and cannot depend on application, adapters, infrastructure, or platform code.',
},
],
},
],
},
},
{
name: 'feature-organizations-core-application-guards',
files: ['src/features/organizations/core/application/**/*.ts'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: [
'@features/organizations/main',
'@features/organizations/main/**',
'@features/organizations/preload',
'@features/organizations/preload/**',
'@features/organizations/renderer',
'@features/organizations/renderer/**',
'@renderer',
'@renderer/**',
'electron',
'fastify',
'child_process',
'node:child_process',
],
message:
'organizations core/application may depend only on domain, contracts, and application ports - not on adapters or runtime frameworks.',
},
],
},
],
},
},
{
name: 'feature-organizations-preload-guards',
files: ['src/features/organizations/preload/**/*.ts'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: [
'@features/organizations/main',
'@features/organizations/main/**',
'@main',
'@main/**',
'@renderer',
'@renderer/**',
],
message:
'organizations preload may depend only on contracts and preload-local bridge helpers.',
},
],
},
],
},
},
{
name: 'feature-organizations-renderer-ui-guards',
files: ['src/features/organizations/renderer/ui/**/*.tsx'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: [
'@renderer/api',
'@renderer/api/**',
'@renderer/store',
'@renderer/store/**',
'@main',
'@main/**',
'electron',
],
message:
'organizations renderer/ui must stay presentational. Move transport, store access, and navigation logic into hooks or adapters.',
},
],
},
],
},
},
{
name: 'feature-organizations-public-entrypoints',
files: ['src/**/*.{ts,tsx}'],
ignores: ['src/features/organizations/**/*'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: [
'@features/organizations/contracts/**',
'@features/organizations/core/**',
'@features/organizations/main/**',
'@features/organizations/preload/**',
'@features/organizations/renderer/**',
],
message:
'Import organizations only through public entrypoints: @features/organizations/contracts, @features/organizations/main, @features/organizations/preload, or @features/organizations/renderer.',
},
],
},
],
},
},
{
name: 'feature-agent-graph-public-entrypoints',
files: ['src/**/*.{ts,tsx}'],
ignores: ['src/features/agent-graph/**/*'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: [
'@features/agent-graph/core/**',
'@features/agent-graph/renderer/**',
],
message:
'Import agent-graph only through its public entrypoint: @features/agent-graph/renderer.',
},
],
},
],
},
},
{
name: 'feature-agent-graph-core-domain-guards',
files: ['src/features/agent-graph/core/domain/**/*.ts'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: [
'@features/agent-graph/renderer/**',
'@main/**',
'@renderer/**',
'@preload/**',
'electron',
'fastify',
'child_process',
'node:child_process',
],
message:
'agent-graph core/domain must stay pure and cannot depend on renderer, main, preload, or platform code.',
},
],
},
],
},
},
{
name: 'feature-agent-graph-renderer-boundaries',
files: ['src/features/agent-graph/renderer/**/*.{ts,tsx}'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: [
'@main/**',
'@preload/**',
'electron',
],
message:
'agent-graph renderer may depend on shared, renderer, package, and feature-local modules, but not on main/preload or Electron APIs directly.',
},
],
},
],
},
},
// Import plugin configuration - Feature main/preload slices
{
name: 'import-plugin-features-node',
files: ['src/features/**/main/**/*.ts', 'src/features/**/preload/**/*.ts'],
plugins: {
import: importPlugin,
},
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true,
project: ['./tsconfig.node.json', './tsconfig.json'],
},
},
},
rules: {
'import/no-cycle': ['error', { maxDepth: 3, ignoreExternal: true }],
'import/no-unresolved': 'error',
'import/no-default-export': 'warn',
},
},
// Import plugin configuration - Feature contracts/core/renderer slices
{
name: 'import-plugin-features-web',
files: [
'src/features/**/contracts/**/*.ts',
'src/features/**/core/**/*.ts',
'src/features/**/renderer/**/*.{ts,tsx}',
],
plugins: {
import: importPlugin,
},
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true,
project: ['./tsconfig.json', './tsconfig.node.json'],
},
},
},
rules: {
'import/no-cycle': ['error', { maxDepth: 3, ignoreExternal: true }],
'import/no-unresolved': 'error',
'import/no-default-export': 'warn',
},
},
// Module boundaries - Enforce Electron three-process architecture
{
name: 'module-boundaries',
files: ['src/**/*.{js,jsx,ts,tsx}'],
plugins: {
boundaries: boundaries,
},
settings: {
'boundaries/elements': [
{ type: 'main', pattern: 'src/main/**', mode: 'folder' },
{ type: 'preload', pattern: 'src/preload/**', mode: 'folder' },
{ type: 'renderer', pattern: 'src/renderer/**', mode: 'folder' },
{ type: 'shared', pattern: 'src/shared/**', mode: 'folder' },
],
'boundaries/ignore': ['**/*.test.ts', '**/*.spec.ts'],
},
rules: {
// Enforce strict module boundaries for Electron architecture
'boundaries/element-types': [
'warn',
{
default: 'disallow',
rules: [
// Renderer can only import from renderer and shared
{ from: 'renderer', allow: ['renderer', 'shared'] },
// Main process can only import from main and shared
{ from: 'main', allow: ['main', 'shared'] },
// Preload can only import from preload and shared
{ from: 'preload', allow: ['preload', 'shared'] },
// Shared can import from shared and main (for type re-exports)
{ from: 'shared', allow: ['shared', 'main'] },
],
},
],
// Prevent importing private modules
'boundaries/no-private': 'error',
},
},
// ESLint Comments
{
name: 'eslint-comments',
files: ['src/**/*.{js,jsx,ts,tsx}'],
plugins: {
'@eslint-community/eslint-comments': eslintComments,
},
rules: {
// Prevents blanket-disabling rules
'@eslint-community/eslint-comments/no-unlimited-disable': 'error',
// Require description for disable comments
'@eslint-community/eslint-comments/require-description': [
'error',
{ ignore: [] },
],
// Re-enable rules after disabling
'@eslint-community/eslint-comments/disable-enable-pair': 'error',
// No duplicate disable comments
'@eslint-community/eslint-comments/no-duplicate-disable': 'error',
// Unused disable comments
'@eslint-community/eslint-comments/no-unused-disable': 'error',
},
},
// Import sorting for all JS/TS files
{
name: 'import-sorting',
files: ['src/**/*.{js,jsx,ts,tsx}'],
plugins: {
'simple-import-sort': simpleImportSort,
},
rules: {
'simple-import-sort/imports': [
'error',
{
groups: [
// Side effect imports (e.g., import './styles.css')
['^\\u0000'],
// Node.js builtins (fs, path, etc.)
['^node:'],
// React and related packages
['^react', '^react-dom'],
// External packages from node_modules
['^@?\\w'],
// Internal aliases (@/ paths)
['^@/'],
// Parent imports (../)
['^\\.\\.(?!/?$)', '^\\.\\./?$'],
// Same-folder imports (./)
['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
// Type imports
['^.+\\u0000$'],
],
},
],
'simple-import-sort/exports': 'error',
},
},
// Main process (Electron Node.js)
{
name: 'electron-main',
files: ['src/main/**/*.ts'],
languageOptions: {
globals: {
...globals.node,
},
},
rules: {
// Allow console in main process for logging
'no-console': 'off',
},
},
{
name: 'electron-main-safe-renderer-send-guard',
files: ['src/main/**/*.ts'],
ignores: ['src/main/utils/safeWebContentsSend.ts'],
rules: {
'no-restricted-syntax': [
'error',
{
selector:
"CallExpression[callee.type='MemberExpression'][callee.property.name='send'][callee.object.type='MemberExpression'][callee.object.property.name='webContents']",
message:
'Use safeSendToRenderer(...) instead of direct webContents.send(...) in the main process.',
},
{
selector:
"CallExpression[callee.type='MemberExpression'][callee.property.name='send'][callee.object.type='MemberExpression'][callee.object.property.name='sender']",
message:
'Use safeSendToRenderer(BrowserWindow.fromWebContents(event.sender), ...) instead of direct event.sender.send(...) in the main process.',
},
{
selector:
"CallExpression[callee.type='MemberExpression'][callee.property.name='send'][callee.object.name='contents']",
message:
'Use safeSendToRenderer(...) instead of aliasing webContents and calling contents.send(...) in the main process.',
},
],
},
},
{
name: 'team-transcript-project-resolver-sonar-override',
files: ['src/main/services/team/TeamTranscriptProjectResolver.ts'],
rules: {
'sonarjs/no-identical-functions': 'off',
},
},
// Preload script (Electron bridge)
{
name: 'electron-preload',
files: ['src/preload/**/*.ts'],
languageOptions: {
globals: {
...globals.node,
...globals.browser,
},
},
},
// Renderer process (React + A11y + Tailwind)
{
name: 'renderer-react',
files: ['src/renderer/**/*.{ts,tsx}'],
languageOptions: {
globals: {
...globals.browser,
},
},
plugins: {
react: reactPlugin,
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
'jsx-a11y': jsxA11y,
tailwindcss: tailwindcss,
},
settings: {
react: {
version: 'detect',
},
tailwindcss: {
// Tailwind config path (relative to cwd)
config: 'tailwind.config.js',
// Allow custom classnames (e.g., from CSS modules)
callees: ['classnames', 'clsx', 'cn'],
},
},
rules: {
// React recommended rules
...reactPlugin.configs.recommended.rules,
// JSX runtime (React 17+) - no need to import React
...reactPlugin.configs['jsx-runtime'].rules,
// React Hooks rules
...reactHooks.configs.recommended.rules,
// Accessibility rules (recommended)
...jsxA11y.configs.recommended.rules,
// Tailwind CSS rules
...tailwindcss.configs.recommended.rules,
// React Refresh for HMR
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
// Disable prop-types since we use TypeScript
'react/prop-types': 'off',
// A11y rule adjustments for this project
// Allow click handlers on divs when keyboard handlers also present
'jsx-a11y/click-events-have-key-events': 'warn',
'jsx-a11y/no-static-element-interactions': 'warn',
'jsx-a11y/label-has-associated-control': 'warn',
'jsx-a11y/no-noninteractive-tabindex': 'warn',
// Allow autofocus for search inputs in desktop apps
'jsx-a11y/no-autofocus': 'off',
// Tailwind CSS rule adjustments
// Warn on class order (Prettier plugin handles sorting)
'tailwindcss/classnames-order': 'off', // Prettier plugin handles this
// Warn on conflicting classes
'tailwindcss/no-contradicting-classname': 'error',
// Warn on custom classnames that don't exist
'tailwindcss/no-custom-classname': 'warn',
// === React-Specific Rules ===
// Consistent component definition
'react/function-component-definition': [
'error',
{
namedComponents: 'arrow-function',
unnamedComponents: 'arrow-function',
},
],
// Strengthen exhaustive-deps
'react-hooks/exhaustive-deps': 'warn',
// Conditional hooks — warn instead of error for gradual fix
'react-hooks/rules-of-hooks': 'warn',
// React Compiler rules — downgraded to warn for existing code
'react-hooks/refs': 'warn',
'react-hooks/set-state-in-effect': 'warn',
'react-hooks/preserve-manual-memoization': 'warn',
'react-hooks/immutability': 'warn',
// Prevent prop spreading
'react/jsx-props-no-spreading': [
'warn',
{
exceptions: ['input', 'button', 'Input', 'Button', 'textarea', 'select'],
},
],
// Ensure key props
'react/jsx-key': [
'error',
{
checkFragmentShorthand: true,
checkKeyMustBeforeSpread: true,
},
],
// Prevent unnecessary fragments
'react/jsx-no-useless-fragment': 'warn',
// Self-closing components for consistency
'react/self-closing-comp': [
'error',
{
component: true,
html: true,
},
],
},
},
// Test files
{
name: 'test-files',
files: ['test/**/*.ts', '**/*.test.ts', '**/*.spec.ts'],
languageOptions: {
globals: {
...globals.node,
},
parserOptions: {
projectService: false,
project: './tsconfig.json',
},
},
rules: {
// Relax TypeScript strict rules for tests
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/unbound-method': 'off',
// Relax function/export rules for tests
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
// Relax naming conventions for tests (allow describe, it, expect patterns)
'@typescript-eslint/naming-convention': 'off',
// Allow magic numbers in tests
'sonarjs/no-hardcoded-ip': 'off',
// Allow floating promises in tests (common with async test helpers)
'@typescript-eslint/no-floating-promises': 'off',
},
},
// Custom rule overrides for all TypeScript files
{
name: 'custom-rules',
files: ['src/**/*.{ts,tsx}'],
rules: {
// === Core JavaScript rules ===
'prefer-const': 'error',
'no-var': 'error',
eqeqeq: ['error', 'always', { null: 'ignore' }],
// === TypeScript Import/Export rules ===
'@typescript-eslint/consistent-type-exports': [
'error',
{ fixMixedExportsWithInlineTypeSpecifier: true },
],
// === Unused variables ===
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
// === Relaxed strict rules for practical use ===
// Allow empty functions (useful for callbacks and stubs)
'@typescript-eslint/no-empty-function': 'off',
// Allow async functions without await (IPC handlers often need this)
'@typescript-eslint/require-await': 'off',
// Allow promises in places that don't expect them (event handlers)
'@typescript-eslint/no-misused-promises': [
'error',
{
checksVoidReturn: {
attributes: false,
arguments: false,
},
},
],
// Allow void expression in arrow functions shorthand
'@typescript-eslint/no-confusing-void-expression': [
'error',
{
ignoreArrowShorthand: true,
ignoreVoidOperator: true,
},
],
// Prefer nullish coalescing but don't error on logical or
'@typescript-eslint/prefer-nullish-coalescing': 'off',
// Allow inferrable types (style preference)
'@typescript-eslint/no-inferrable-types': 'off',
// === Anti-Hallucination Rules ===
// Explicit return types
'@typescript-eslint/explicit-function-return-type': [
'warn',
{
allowExpressions: true,
allowTypedFunctionExpressions: true,
allowHigherOrderFunctions: true,
allowDirectConstAssertionInArrowFunctions: true,
},
],
// Explicit types for exported functions (minimum requirement)
'@typescript-eslint/explicit-module-boundary-types': 'warn',
// === Naming Conventions ===
'@typescript-eslint/naming-convention': [
'warn',
// Imports can be camelCase or PascalCase (React, ReactDOM, App, etc.)
{
selector: 'import',
format: ['camelCase', 'PascalCase'],
},
// Default: variables and parameters in camelCase
{
selector: 'default',
format: ['camelCase'],
leadingUnderscore: 'allow',
},
// Static readonly class properties can be UPPER_CASE
{
selector: 'classProperty',
modifiers: ['static', 'readonly'],
format: ['camelCase', 'UPPER_CASE'],
},
// Variables: camelCase or UPPER_CASE for constants
{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
leadingUnderscore: 'allow',
},
// Functions: camelCase (includes type guards like isXxx, builders like buildXxx)
{
selector: 'function',
format: ['camelCase', 'PascalCase'],
},
// Parameters: camelCase, allow leading underscore for unused
{
selector: 'parameter',
format: ['camelCase'],
leadingUnderscore: 'allow',
},
// Types and interfaces in PascalCase
{
selector: 'typeLike',
format: ['PascalCase'],
},
// Interfaces should NOT start with I (modern convention)
{
selector: 'interface',
format: ['PascalCase'],
custom: { regex: '^I[A-Z]', match: false },
},
// Enum members in PascalCase or UPPER_CASE
{
selector: 'enumMember',
format: ['PascalCase', 'UPPER_CASE'],
},
// Object literal properties: allow any format (for API compatibility)
{
selector: 'objectLiteralProperty',
format: null,
},
// Type properties: allow any format (for type definitions matching APIs)
{
selector: 'typeProperty',
format: null,
},
],
// === Import Restrictions ===
// Note: boundaries/element-types handles main/renderer separation
'no-restricted-imports': 'off',
// === Mutation Prevention ===
'no-param-reassign': 'warn',
// === SonarJS rule adjustments ===
// Cognitive complexity - warn instead of error for gradual adoption
'sonarjs/cognitive-complexity': 'off',
// Allow some duplication in similar but not identical code
'sonarjs/no-duplicate-string': 'off',
// Relax for Electron IPC patterns (many similar switch cases)
'sonarjs/no-small-switch': 'off',
// Allow nested ternaries in JSX (common React pattern)
'sonarjs/no-nested-conditional': 'off',
// AWS/CloudFormation rule — irrelevant to an Electron app and one of the
// most expensive rules in the run (~11% of lint time, see TIMING=10)
'sonarjs/aws-restricted-ip-admin-access': 'off',
// Type-aware deprecation warnings duplicate IDE hints and alone cost
// ~30% of lint time; drop them from the CLI/CI run
'sonarjs/deprecation': 'off',
// === Downgraded to warn — existing code, fix incrementally ===
'sonarjs/slow-regex': 'warn',
'sonarjs/pseudo-random': 'warn',
'sonarjs/different-types-comparison': 'warn',
'sonarjs/no-dead-store': 'warn',
'sonarjs/unused-import': 'warn',
'sonarjs/no-unused-vars': 'warn',
'sonarjs/no-commented-code': 'warn',
'sonarjs/function-return-type': 'warn',
'sonarjs/use-type-alias': 'warn',
'sonarjs/no-nested-template-literals': 'warn',
'sonarjs/no-alphabetical-sort': 'warn',
'sonarjs/no-misleading-array-reverse': 'warn',
'sonarjs/no-os-command-from-path': 'warn',
'sonarjs/link-with-target-blank': 'warn',
'sonarjs/no-unused-collection': 'warn',
'sonarjs/todo-tag': 'warn',
'sonarjs/reduce-initial-value': 'warn',
'sonarjs/concise-regex': 'warn',
'sonarjs/void-use': 'warn',
'sonarjs/anchor-precedence': 'warn',
'sonarjs/no-control-regex': 'warn',
'sonarjs/no-nested-functions': 'warn',
'sonarjs/no-all-duplicated-branches': 'warn',
'@typescript-eslint/no-shadow': 'warn',
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/no-unsafe-call': 'warn',
'@typescript-eslint/no-unsafe-assignment': 'warn',