-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy patheslint.config.mjs
113 lines (108 loc) · 3.21 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
104
105
106
107
108
109
110
111
112
113
// @ts-check
/* eslint-disable import/no-named-as-default-member -- We want to be able to use the full package name for the imports here for clarity */
import eslint from '@eslint/js';
import eslintCommentPlugin from '@eslint-community/eslint-plugin-eslint-comments/configs';
import stylisticPlugin from '@stylistic/eslint-plugin';
// @ts-expect-error importPlugin is not typed
import importPlugin from 'eslint-plugin-import';
import tseslint from 'typescript-eslint';
/**
* Typed to any as the type is incompatible for some reason - it works!
* @type {any}
*/
const stylisticConfig = stylisticPlugin.configs.customize({
indent: 'tab',
quotes: 'single',
semi: true,
commaDangle: 'never',
braceStyle: '1tbs'
});
/**
* Typed to any as the type is incompatible for some reason - it works!
* @type {any}
*/
const eslintCommentPluginConfig = eslintCommentPlugin.recommended;
export default tseslint.config(
{
// https://eslint.org/docs/rules/
extends: [eslint.configs.recommended],
rules: {
'require-atomic-updates': 'off', // This rule is widely controversial and causes false positives
'no-console': 'off',
'prefer-const': 'error',
'no-var': 'error',
'no-unused-vars': 'off',
'one-var': ['error', 'never']
}
},
{
// https://typescript-eslint.io/rules/
extends: [tseslint.configs.recommended],
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_' }
],
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-object-type': ['off'],
'@typescript-eslint/no-import-type-side-effects': 'error',
'@typescript-eslint/consistent-type-imports': ['error', {
fixStyle: 'separate-type-imports'
}]
}
},
{
// https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/
extends: [eslintCommentPluginConfig],
rules: {
'@eslint-community/eslint-comments/disable-enable-pair': ['error', { allowWholeFile: true }],
'@eslint-community/eslint-comments/require-description': 'error'
}
},
{
// https://eslint.style/rules
extends: [stylisticConfig],
rules: {
'@stylistic/no-extra-semi': 'error',
'@stylistic/yield-star-spacing': ['error', 'after'],
'@stylistic/operator-linebreak': ['error', 'after', { overrides: { '?': 'before', ':': 'before' } }],
'@stylistic/curly-newline': ['error', {
multiline: true,
consistent: true
}],
'@stylistic/object-curly-newline': ['error', {
multiline: true,
consistent: true
}]
}
},
{
// https://www.npmjs.com/package/eslint-plugin-import
extends: [importPlugin.flatConfigs.recommended, importPlugin.flatConfigs.warnings, importPlugin.flatConfigs.typescript],
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true,
project: './tsconfig.json'
},
node: true
}
},
rules: {
'import/order': ['warn', {
'groups': ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'],
'newlines-between': 'never'
}],
'import/first': 'error',
'import/consistent-type-specifier-style': ['error', 'prefer-top-level']
}
},
{
ignores: [
'scripts/*',
'dist/*'
]
}
);