-
Notifications
You must be signed in to change notification settings - Fork 4
/
eslint.config.js
106 lines (105 loc) · 2.45 KB
/
eslint.config.js
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
const eslint = require('@eslint/js');
const ts = require('@typescript-eslint/eslint-plugin');
const tsParser = require('@typescript-eslint/parser');
const prettier = require('eslint-config-prettier');
const wdio = require('eslint-plugin-wdio');
const globals = require('globals');
module.exports = [
// Ignored dirs
{
ignores: ['**/dist/**/*'],
},
// All files
{
files: ['**/*.{js,mjs,ts}'],
languageOptions: {
ecmaVersion: 'latest',
globals: {
...globals.es2021,
},
},
rules: {
...eslint.configs.recommended.rules,
},
},
// Node & Electron main process files and scripts
{
files: ['**/*.{js,mjs,ts}'],
ignores: ['src/preload.ts', 'src/util.ts'],
languageOptions: {
globals: {
...globals.node,
},
},
},
// Electron renderer process files
{
files: ['example*/src/preload.ts', 'example*/src/util.ts'],
languageOptions: {
globals: {
...globals.browser,
},
},
},
// TS files
{
files: ['**/*.ts'],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaFeatures: { modules: true },
ecmaVersion: 'latest',
project: './tsconfig.json',
},
},
plugins: {
'@typescript-eslint': ts,
},
rules: {
...ts.configs['eslint-recommended'].rules,
...ts.configs.recommended.rules,
'no-undef': 'off', // redundant - TS will fail to compile with undefined vars
'no-redeclare': 'off', // redundant - TS will fail to compile with duplicate declarations
'@typescript-eslint/no-empty-interface': [
'error',
{
allowSingleExtends: true,
},
],
'@typescript-eslint/no-namespace': [
'error',
{
allowDeclarations: true,
},
],
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'after-used',
ignoreRestSiblings: true,
argsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
},
],
'@typescript-eslint/no-explicit-any': ['warn'],
},
},
// E2E TS files
{
files: ['test/*.spec.ts'],
languageOptions: {
globals: {
...wdio.configs.recommended.globals,
},
},
plugins: {
wdio,
},
rules: {
...wdio.configs.recommended.rules,
'@typescript-eslint/no-var-requires': 'off',
},
},
// ensure all rules work with prettier
prettier,
];