-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.mjs
104 lines (95 loc) · 3.27 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
import pluginJs from '@eslint/js'
import stylistic from '@stylistic/eslint-plugin'
import { AST_NODE_TYPES } from '@typescript-eslint/utils'
import 'eslint-plugin-only-warn'
import globals from 'globals'
import tseslint from 'typescript-eslint'
import noBlankLinesInOptionalBlocks from './rule/no-blank-lines-in-optional-blocks.mjs'
import noUnusedExpressions from './rule/no-unused-expressions.mjs'
/** @import {TSESLint} from "@typescript-eslint/utils" */
/** @type {(root: string) => TSESLint.Linter.ConfigType[]} */
export function config (root) {
return [
{ files: ['**/*.{js,mjs,cjs,ts}'] },
{ languageOptions: { globals: { ...globals.browser, ...globals.node } } },
pluginJs.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
{
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: root,
},
},
},
stylistic.configs.customize({
indent: 'tab',
quotes: 'single',
semi: false,
jsx: false,
}),
{
rules: {
'no-constant-binary-expression': 'off',
'no-empty': ['warn', { allowEmptyCatch: true }],
'no-constant-condition': ['warn', { checkLoops: false }],
'prefer-const': ['warn', { destructuring: 'all' }],
'no-irregular-whitespace': ['warn', { skipRegExps: true }],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/consistent-type-imports': 'warn',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '.', varsIgnorePattern: '^[A-Z_]+$' }],
'@typescript-eslint/no-unsafe-declaration-merging': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-empty-object-type': ['warn', { allowInterfaces: 'always' }],
'@stylistic/no-trailing-spaces': 'off', // removed by typescript
'@stylistic/indent': 'off',
'@stylistic/indent-binary-ops': 'off',
'@stylistic/multiline-ternary': 'off',
'@stylistic/spaced-comment': ['warn', 'always', { exceptions: ['/'], markers: ['#region', '#endregion'] }],
'@stylistic/space-before-function-paren': ['warn', 'always'],
'@stylistic/quotes': ['warn', 'single'],
'@stylistic/padded-blocks': ['warn', { blocks: 'never', classes: 'always' }],
'@stylistic/arrow-parens': ['warn', 'as-needed'],
'@stylistic/comma-dangle': ['warn', {
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
enums: 'always-multiline',
tuples: 'always-multiline',
generics: 'ignore',
functions: 'ignore',
}],
'@stylistic/eol-last': ['warn', 'always'],
'@stylistic/max-statements-per-line': ['warn', {
ignoredNodes: [
AST_NODE_TYPES.BreakStatement,
AST_NODE_TYPES.ExpressionStatement,
AST_NODE_TYPES.ReturnStatement,
],
}],
'@stylistic/padding-line-between-statements': [
'warn',
{ blankLine: 'never', prev: 'block', next: '*' },
],
},
},
{
plugins: {
fluff: {
rules: {
...noUnusedExpressions,
...noBlankLinesInOptionalBlocks,
},
},
},
rules: {
'fluff/no-unused-expressions': 'warn',
'fluff/no-blank-lines-in-optional-blocks': 'warn',
},
},
]
}
export default config(import.meta.dirname)