-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patheslint.config.mjs
More file actions
115 lines (111 loc) Β· 4.09 KB
/
eslint.config.mjs
File metadata and controls
115 lines (111 loc) Β· 4.09 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
import eslint from '@eslint/js';
import { defineConfig } from 'eslint/config';
import tseslint from 'typescript-eslint';
import globals from 'globals';
import stylistic from '@stylistic/eslint-plugin';
export default defineConfig(
// 1) Ignore build artifacts
{
ignores: ['dist/**', 'build/**', 'coverage/**', 'node_modules/**'],
},
// 2) Base JS + stylistic rules for JS & TS
{
files: ['**/*.{js,cjs,mjs,ts,tsx}'],
...eslint.configs.recommended,
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},
},
plugins: {
'@stylistic': stylistic,
},
rules: {
// Core style rules migrated from .eslintrc.json
'space-before-function-paren': ['error', 'always'],
'no-trailing-spaces': 'error',
'semi': 'off',
'no-unused-expressions': ['error', {
allowShortCircuit: true,
allowTernary: true,
}],
'quotes': ['error', 'single'],
'key-spacing': ['error', {
beforeColon: false,
afterColon: true,
mode: 'strict',
}],
'indent': ['error', 4, {
VariableDeclarator: 1,
SwitchCase: 1,
}],
'lines-between-class-members': ['error', 'always', {
exceptAfterSingleLine: true,
}],
'keyword-spacing': ['error', {
overrides: {
this: { before: false },
},
}],
'object-curly-spacing': ['error', 'always'],
'@stylistic/semi': ['error', 'always'],
// Replace obsolete brace-rules/brace-on-same-line with core brace-style
'brace-style': ['error', 'allman', {
allowSingleLine: true,
}],
},
},
// 3) Non-typed TS rules (safe everywhere TS is parsed)
...tseslint.configs.recommended.map((config) => ({
...config,
files: ['**/*.{ts,tsx}'],
})),
// 4) Typed TS rules β scoped to TS/TSX and with projectService enabled
...tseslint.configs.recommendedTypeChecked.map((config) => ({
...config,
files: ['**/*.{ts,tsx}'],
languageOptions: {
...(config.languageOptions ?? {}),
parserOptions: {
...(config.languageOptions?.parserOptions ?? {}),
// Enable type-aware linting using your tsconfig
projectService: true,
},
},
rules: {
...(config.rules ?? {}),
// TypeScript-specific rules migrated and aligned with modern best practices
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/consistent-type-assertions': 'off',
'@stylistic/member-delimiter-style': ['error', {
multiline: {
delimiter: 'semi',
requireLast: true,
},
singleline: {
delimiter: 'comma',
requireLast: false,
},
}],
'@stylistic/type-annotation-spacing': ['error', {
before: false,
after: true,
}],
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-import-type-side-effects': 'error',
'@typescript-eslint/no-unused-expressions': ['error', {
allowShortCircuit: true,
allowTernary: true,
}],
},
})),
);