forked from dorny/paths-filter
-
Notifications
You must be signed in to change notification settings - Fork 2
/
eslint.config.mjs
98 lines (92 loc) · 2.97 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
// @ts-check
import {fixupPluginRules} from '@eslint/compat'
import {FlatCompat} from '@eslint/eslintrc'
import jsEslint from '@eslint/js'
import eslintConfigPrettier from 'eslint-config-prettier'
import tsEslint from 'typescript-eslint'
const compat = new FlatCompat({
baseDirectory: import.meta.dirname,
recommendedConfig: jsEslint.configs.recommended,
allConfig: jsEslint.configs.all
})
/* eslint-disable @typescript-eslint/explicit-function-return-type */
/**
* @param {string} name the pugin name
* @param {string} alias the plugin alias
* @returns {import("eslint").ESLint.Plugin}
*/
function legacyPlugin(name, alias = name) {
const plugin = compat.plugins(name)[0]?.plugins?.[alias]
if (!plugin) {
throw new Error(`Unable to resolve plugin ${name} and/or alias ${alias}`)
}
return fixupPluginRules(plugin)
}
/* eslint-enable @typescript-eslint/explicit-function-return-type */
export default tsEslint.config(
jsEslint.configs.recommended,
...tsEslint.configs.strictTypeChecked,
...tsEslint.configs.stylisticTypeChecked,
{
languageOptions: {
parserOptions: {
projectService: {
allowDefaultProject: ['*.js', '*.mjs']
},
tsconfigRootDir: import.meta.dirname
}
}
},
{
ignores: ['**/coverage', '**/dist', '**/esbuild.config.mjs']
},
{
plugins: {
github: legacyPlugin('eslint-plugin-github', 'github'), // pending https://github.com/github/eslint-plugin-github/issues/513
import: legacyPlugin('eslint-plugin-import', 'import') // Needed for above
},
rules: {
'@typescript-eslint/await-thenable': 'warn',
'@typescript-eslint/explicit-function-return-type': 'warn',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-floating-promises': ['warn', {ignoreIIFE: true, ignoreVoid: false}],
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/no-unused-vars': ['warn', {argsIgnorePattern: '^_'}],
'@typescript-eslint/restrict-template-expressions': [
'error',
{
allowNever: true,
allowNumber: true
}
],
'github/array-foreach': 'error',
'github/no-implicit-buggy-globals': 'error',
'github/no-then': 'error',
'github/no-dynamic-script-tag': 'error',
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: true,
optionalDependencies: true,
peerDependencies: true
}
],
'import/order': ['warn', {'newlines-between': 'always', alphabetize: {order: 'asc'}}],
'no-console': ['warn']
}
},
{
files: ['**/*.test.ts'],
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off'
}
},
{
files: ['**/*.js', '**/*.mjs'],
...tsEslint.configs.disableTypeChecked
},
eslintConfigPrettier
)