-
Notifications
You must be signed in to change notification settings - Fork 625
/
eslint.config.mjs
103 lines (89 loc) · 2.16 KB
/
eslint.config.mjs
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
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import tseslint from 'typescript-eslint';
import globals from 'globals';
import tsParser from '@typescript-eslint/parser';
import jest from 'eslint-plugin-jest';
import js from '@eslint/js';
export default [
// using .mjs for module support as TypeScript Eslint configs are still experimental
{
name: 'Eslint config file',
files: ['eslint.config.mjs'],
// ...tseslint.configs.disableTypeChecked,
// ...js.configs.recommended,
languageOptions: {
sourceType: 'module',
parserOptions: {
// project: 'package.json'
}
}
},
{
name: 'general project rules',
files: ['**/*.ts'],
plugins: {
'@typescript-eslint': tseslint.plugin
},
languageOptions: {
globals: {
...globals.node
},
parser: tsParser,
ecmaVersion: 5,
sourceType: 'module',
parserOptions: {
project: 'tsconfig.json'
}
},
rules: {
// contains all of recommended, recommended-type-checked, and strict
...tseslint.configs.strictTypeChecked.rules,
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_'
}
],
'@typescript-eslint/naming-convention': [
'warn',
{
selector: ['typeLike'],
format: ['PascalCase']
},
{
selector: ['variableLike', 'function'],
format: ['camelCase'],
leadingUnderscore: 'allow'
},
{
selector: ['variable'],
format: ['camelCase', 'UPPER_CASE']
},
{
selector: 'variable',
types: ['boolean'],
format: ['PascalCase'],
prefix: ['is', 'should', 'has', 'can', 'did', 'was', 'will']
}
],
// this is set to warn because it wasn't caught before the eslint migration in 11/2024
'@typescript-eslint/restrict-template-expressions': 'warn'
}
},
{
name: 'test rules',
files: ['tests/**/*.ts'],
...jest.configs['flat/recommended'],
...jest.configs['flat/style'],
plugins: {
jest
},
rules: {
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/unbound-method': 'off',
'jest/no-done-callback': 'off'
}
},
// Prettier plugin which should be last
eslintPluginPrettierRecommended
];