-
Notifications
You must be signed in to change notification settings - Fork 301
Expand file tree
/
Copy patheslint.config.mjs
More file actions
98 lines (90 loc) · 2.68 KB
/
eslint.config.mjs
File metadata and controls
98 lines (90 loc) · 2.68 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
// @ts-check
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import prettierConfig from 'eslint-config-prettier';
import globals from 'globals';
export default tseslint.config(
// Ignore patterns
{
ignores: [
'dist/**',
'release/**',
'node_modules/**',
'*.config.js',
'*.config.mjs',
'*.config.ts',
'scripts/**',
'src/__tests__/**',
'src/web/utils/serviceWorker.ts', // Service worker has special globals
'src/web/public/**', // Service worker and static assets
'src/renderer/public/**', // Static browser scripts (splash, devtools)
],
},
// Base ESLint recommended rules
eslint.configs.recommended,
// TypeScript ESLint recommended rules
...tseslint.configs.recommended,
// Prettier config - disables ESLint rules that conflict with Prettier
prettierConfig,
// Main configuration for all TypeScript files
{
files: ['src/**/*.ts', 'src/**/*.tsx'],
languageOptions: {
ecmaVersion: 2020,
sourceType: 'module',
globals: {
...globals.browser,
...globals.node,
...globals.es2020,
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
plugins: {
react: reactPlugin,
'react-hooks': reactHooksPlugin,
},
rules: {
// TypeScript-specific rules
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
// TODO: Change to 'warn' after reducing ~304 existing uses
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-require-imports': 'off', // Used in main process
// React rules
'react/jsx-uses-react': 'error',
'react/jsx-uses-vars': 'error',
'react/prop-types': 'off', // Using TypeScript for prop types
'react/react-in-jsx-scope': 'off', // Not needed with new JSX transform
// React Hooks rules
'react-hooks/rules-of-hooks': 'error',
// NOTE: exhaustive-deps is intentionally 'off' - this codebase uses refs and
// stable state setters intentionally without listing them as dependencies.
// The pattern is to use refs to access latest values without causing re-renders.
'react-hooks/exhaustive-deps': 'off',
// General rules
'no-console': 'off', // Console is used throughout
'no-undef': 'off', // TypeScript handles this
'no-control-regex': 'off', // Intentionally used for terminal escape sequences
'no-useless-escape': 'off', // Sometimes needed for clarity in regexes
'prefer-const': 'warn',
'no-var': 'error',
},
settings: {
react: {
version: 'detect',
},
},
}
);