-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path.eslintrc.js
More file actions
95 lines (89 loc) · 2.27 KB
/
.eslintrc.js
File metadata and controls
95 lines (89 loc) · 2.27 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
import js from '@eslint/js'
import tseslint from 'typescript-eslint'
import stylistic from '@stylistic/eslint-plugin'
const globals = {
browser: {
'fetch': true,
'document': true,
'window': true,
'self': true,
'console': true,
'setTimeout': true,
'setInterval': true,
'clearTimeout': true,
'clearInterval': true,
'requestAnimationFrame': true,
'navigator': true,
'history': true,
'localStorage': true
}
}
export function makeConfig(projectPath) {
return tseslint.config({
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
globals: {
...globals.browser,
'expect': true,
'it': true,
'describe': true,
'mocha': true,
'hljs': true
},
parser: tseslint.parser,
parserOptions: {
project: projectPath
}
},
files: ['**/*.ts'],
extends: [
js.configs.recommended,
tseslint.configs.base
],
plugins: {
'@stylistic': stylistic,
},
rules: {
// Semantic/type-aware rules (require typescript-eslint)
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-unused-vars': ['error', {
'vars': 'all',
'args': 'after-used',
'caughtErrors': 'all',
'argsIgnorePattern': '^event',
'caughtErrorsIgnorePattern': '^error',
}],
'@typescript-eslint/no-empty-function': 'off',
// Stylistic rules (migrated to @stylistic)
'@stylistic/member-delimiter-style': ['error', {
multiline: {
delimiter: 'none',
requireLast: false,
},
singleline: {
delimiter: 'semi',
requireLast: false,
}
}],
'@stylistic/semi': ['error', 'never'],
'@stylistic/quotes': ['error', 'single'],
'@stylistic/no-trailing-spaces': 'error',
// Core ESLint rules
'no-debugger': 'error',
'no-unused-labels': 'off',
'no-unused-vars': 'off',
'no-var': 'error',
'eqeqeq': 'error',
'strict': 'error',
}
},
{
files: ['**/*.test.ts'],
rules: {
'@typescript-eslint/no-empty-function': 'off',
}
})
}
export default makeConfig("./tsconfig.json");