-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patheslint.config.js
More file actions
153 lines (142 loc) · 3.87 KB
/
eslint.config.js
File metadata and controls
153 lines (142 loc) · 3.87 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
import { defineConfig, globalIgnores } from 'eslint/config';
import js from '@eslint/js';
import globals from 'globals';
import { FlatCompat } from '@eslint/eslintrc';
// Plugins / configs (flat-native)
import importPlugin from 'eslint-plugin-import';
import prettierPlugin from 'eslint-plugin-prettier';
import prettierFlat from 'eslint-config-prettier/flat';
const compat = new FlatCompat({
recommendedConfig: js.configs.recommended,
});
export default defineConfig([
globalIgnores([
'node_modules/**',
'dist/**',
'build/**',
'out/**',
'src/**',
'server/**',
'r-src/**',
'doc/**',
'build/lib_devel/**',
]),
// ---------- Shared base (applies to all JS) ----------
{
files: ['**/*.js', '**/*.mjs', '**/*.cjs'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: {
...globals.es2024,
__electronLog: 'readonly',
},
},
plugins: {
import: importPlugin,
prettier: prettierPlugin,
},
// Keep Airbnb-base via compat; Prettier last to disable conflicting rules
extends: [
...compat.extends('airbnb-base'),
prettierFlat,
// If you want Prettier to run as an ESLint rule, uncomment:
// prettierPlugin.configs.recommended,
],
settings: {
'import/resolver': {
node: { extensions: ['.js', '.mjs', '.cjs', '.json'] },
},
'import/core-modules': ['electron'],
},
rules: {
'no-multi-str': 'off',
'no-underscore-dangle': ['error', { allowAfterThis: true }],
// Omit .js on local imports, ignore packages
'import/extensions': ['error', 'ignorePackages', { js: 'never' }],
// Only allow dev deps in non-prod contexts
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'**/*.test.js',
'**/*.spec.js',
'**/test/**',
'**/tests/**',
'**/scripts/**',
'electron-builder.*',
'vite.config.*',
'webpack.config.*',
'eslint.config.*',
],
},
],
'no-unused-vars': [
'error',
{
caughtErrors: 'none',
},
],
},
},
// ---------- Electron MAIN (Node context, ESM) ----------
{
files: ['main.js', 'components/**/*.js'],
languageOptions: {
sourceType: 'module',
globals: { ...globals.node, ...globals.es2024 },
},
rules: {
// Main commonly touches build/dev deps; relax if you like:
'import/extensions': ['error', 'ignorePackages', { js: 'always' }],
// "import/no-extraneous-dependencies": "off",
// In Node ESM, you must include .js (or the real ext) on local imports
},
},
// ---------- Electron RENDERER (Browser context) ----------
{
files: ['renderer/**/*.js'],
languageOptions: {
sourceType: 'module',
globals: { ...globals.browser, ...globals.es2024, $: 'readonly' },
},
rules: {
// Prevent accidental Node-only APIs in renderer
// (flip to "error" once you’re confident)
'import/no-nodejs-modules': 'warn',
},
},
// ---------- PRELOAD (Node + limited DOM) ----------
{
files: ['preload/**/*.js'],
languageOptions: {
sourceType: 'module',
globals: { ...globals.node, ...globals.browser },
},
rules: {
// Encourage safe bridging
'import/extensions': ['error', 'ignorePackages', { js: 'always' }],
'no-restricted-properties': [
'warn',
{
object: 'window',
property: 'require',
message: 'Expose via contextBridge in preload.',
},
],
},
},
// ignore unused vars in scripts/**
{
files: ['scripts/**/*.js'],
rules: {
'no-console': 'off',
},
},
{
files: ['eslint.config.*'],
rules: {
'import/no-unresolved': 'off',
},
},
]);