-
Notifications
You must be signed in to change notification settings - Fork 357
Expand file tree
/
Copy patheslint.config.mjs
More file actions
139 lines (130 loc) · 3.6 KB
/
eslint.config.mjs
File metadata and controls
139 lines (130 loc) · 3.6 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat'
import js from '@eslint/js'
import tsPlugin from '@typescript-eslint/eslint-plugin'
import tsParser from '@typescript-eslint/parser'
import prettierConfig from 'eslint-config-prettier'
import raineConfig from 'eslint-config-raine'
import standardConfig from 'eslint-config-standard'
import importXPlugin from 'eslint-plugin-import-x'
import jsdocPlugin from 'eslint-plugin-jsdoc'
// The modern replacement
import nPlugin from 'eslint-plugin-n'
import promisePlugin from 'eslint-plugin-promise'
import globals from 'globals'
export default [
// --- 1. GLOBAL IGNORES ---
{
ignores: ['**/node_modules/', 'dist/', 'build/', 'temp/', '.cache/', '**/node_modules/**/*.md'],
},
// --- 2. PLUGIN DEFINITIONS ---
{
plugins: {
// import-x works natively with ESLint 10
'import-x': importXPlugin,
n: fixupPluginRules(nPlugin),
promise: fixupPluginRules(promisePlugin),
jsdoc: jsdocPlugin,
},
},
// --- 3. GLOBAL SETUP & SETTINGS ---
{
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: {
...globals.browser,
...globals.mocha,
...globals.node,
...globals.es2021,
...globals.jest,
...raineConfig.globals,
},
},
settings: {
// Modern replacement for 'plugin:import/typescript'
'import-x/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import-x/resolver': {
typescript: {
alwaysTryTypes: true,
project: './tsconfig.json',
},
node: true,
},
},
},
// --- 4. BASE RULES (Standard + Raine) ---
...fixupConfigRules([
{
rules: {
...js.configs.recommended.rules,
...standardConfig.rules,
...raineConfig.rules,
},
},
]).map(config => {
// We must remap 'import/' rules to 'import-x/' for the new plugin
if (config.rules) {
const newRules = {}
for (const [key, value] of Object.entries(config.rules)) {
const newKey = key.startsWith('import/') ? key.replace('import/', 'import-x/') : key
newRules[newKey] = value
}
config.rules = newRules
}
return config
}),
// --- 5. JSDOC SPECIFIC OVERRIDES ---
{
rules: {
'jsdoc/require-jsdoc': [
'error',
{
contexts: ['VariableDeclarator > ArrowFunctionExpression'],
require: { ClassDeclaration: true, ClassExpression: true },
},
],
},
},
// --- 6. TYPESCRIPT OVERRIDES ---
{
files: ['**/*.ts'],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaVersion: 'latest',
project: './tsconfig.json',
},
globals: {
...globals.node,
...globals.es2021,
},
},
plugins: {
'@typescript-eslint': tsPlugin,
},
rules: {
'no-undef': 'off',
'no-redeclare': 'off',
'@typescript-eslint/no-redeclare': 'off',
...tsPlugin.configs['eslint-recommended'].rules,
...tsPlugin.configs.recommended.rules,
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-use-before-define': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
caughtErrors: 'none',
destructuredArrayIgnorePattern: '^_',
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
'@typescript-eslint/array-type': ['error', { default: 'array' }],
},
},
// --- 7. PRETTIER ---
prettierConfig,
]