-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.mjs
More file actions
92 lines (91 loc) · 3.01 KB
/
eslint.config.mjs
File metadata and controls
92 lines (91 loc) · 3.01 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
import path from 'node:path'
import { defineConfig } from 'eslint/config'
import { includeIgnoreFile } from '@eslint/config-helpers'
import eslint from '@eslint/js'
import markdown from '@eslint/markdown'
import stylistic from '@stylistic/eslint-plugin'
import tseslint from 'typescript-eslint'
export default defineConfig(
// .gitignore
includeIgnoreFile(path.resolve(import.meta.dirname, '.gitignore')),
// JS/TS
{
files: ['**/*.?(m|c){js,ts}'],
extends: [
eslint.configs.recommended,
stylistic.configs.recommended,
tseslint.configs.strictTypeChecked,
tseslint.configs.stylisticTypeChecked,
{
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
// Dependency issues.
{
rules: {
// TypeScript isn't smart enough for this.
'@typescript-eslint/no-non-null-assertion': 'off',
// For declaration merging, 'with-single-extends' is the most reasonable compromise as of 2025-11.
// https://github.com/typescript-eslint/typescript-eslint/issues/1614#issuecomment-2150456569
// https://github.com/typescript-eslint/typescript-eslint/issues/11468#issuecomment-3168083087
'@typescript-eslint/no-empty-object-type': ['error', {
allowInterfaces: 'with-single-extends',
}],
},
},
// Stylistic rules.
{
rules: {
'@typescript-eslint/explicit-member-accessibility': 'error',
'@typescript-eslint/restrict-template-expressions': ['error', {
allowAny: false,
allowBoolean: true,
allowNullish: true,
allowNumber: true,
allowRegExp: true,
}],
'@typescript-eslint/no-unused-vars': ['error', {
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
}],
'@typescript-eslint/naming-convention': ['error', {
selector: ['classProperty', 'classMethod', 'parameterProperty'],
modifiers: ['private'],
format: ['camelCase'],
leadingUnderscore: 'require',
}],
},
},
],
},
// Test files
{
files: ['test/**/*.ts'],
rules: {
// @playwright/test likes empty object patterns. (It ASTs the test fns internally.)
'no-empty-pattern': ['error', { allowObjectPatternsAsParameters: true }],
},
},
// Markdown code blocks
markdown.configs.processor,
{
files: ['*.md/**/*.{js,ts}'],
extends: [
// Disable type checks until eslint and typescript can interop better.
// https://github.com/eslint/markdown/tree/main/examples/typescript
tseslint.configs.disableTypeChecked,
],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
},
},
)