-
Notifications
You must be signed in to change notification settings - Fork 225
Expand file tree
/
Copy patheslint.config.mjs
More file actions
190 lines (174 loc) · 4.57 KB
/
eslint.config.mjs
File metadata and controls
190 lines (174 loc) · 4.57 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
import js from '@eslint/js'
import tseslint from 'typescript-eslint'
import pluginN from 'eslint-plugin-n'
import pluginMocha from 'eslint-plugin-mocha'
import pluginJsdoc from 'eslint-plugin-jsdoc'
import prettierConfig from 'eslint-config-prettier'
import globals from 'globals'
/**
* Defines the AST nodes we expect to have documentation for. It includes
* most publicly defined stuff with the following exceptions:
* - No need for descriptions on Options interfaces.
* - No need to document setters.
* - No need to document protected or private.
* - No need to document inline types in function parameters.
*/
const needsDocsContexts = [
'TSInterfaceDeclaration[id.name!=/.*Options/]',
'TSTypeAliasDeclaration',
'TSEnumDeclaration',
'TSEnumMember',
'TSMethodSignature[accessibility!=/(private|protected)/]',
'ClassBody > TSPropertySignature[accessibility!=/(private|protected)/]',
'TSInterfaceBody > TSPropertySignature[accessibility!=/(private|protected)/]',
'FunctionDeclaration',
'ClassDeclaration',
'MethodDefinition[accessibility!=/(private|protected)/][kind!=/(set|constructor)/]',
'ClassBody > ClassProperty[accessibility!=/(private|protected)/]',
]
export default [
// Global ignores
{
ignores: [
'dist/**',
'node_modules/**',
'coverage/**',
'**/*.d.ts',
'deps/**',
'scripts/**',
'tools/**',
],
},
// Base ESLint recommended rules
js.configs.recommended,
// TypeScript ESLint recommended rules
...tseslint.configs.recommended,
// Main configuration for lib/ and test/
{
files: ['lib/**/*.ts', 'test/**/*.{js,ts}'],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
globals: {
...globals.node,
...globals.es2021,
...globals.mocha,
},
},
plugins: {
'@typescript-eslint': tseslint.plugin,
n: pluginN,
mocha: pluginMocha,
jsdoc: pluginJsdoc,
},
settings: {
jsdoc: {
ignorePrivate: true,
ignoreInternal: true,
},
},
rules: {
// TypeScript rules
'@typescript-eslint/explicit-module-boundary-types': [
'error',
{
allowArgumentsExplicitlyTypedAsAny: true,
},
],
'@typescript-eslint/no-explicit-any': 'off',
// TypeScript ESLint v8 new rules - allow empty interfaces for extending
'@typescript-eslint/no-empty-object-type': [
'error',
{
allowInterfaces: 'always',
},
],
// Allow unused vars if prefixed with underscore
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
// Node.js rules (migrated from eslint-plugin-node to eslint-plugin-n)
'n/no-unsupported-features/es-syntax': [
'error',
{
ignores: ['modules'],
},
],
'n/no-missing-import': [
'error',
{
tryExtensions: ['.js', '.ts'],
},
],
'n/no-missing-require': [
'error',
{
tryExtensions: ['.js', '.ts'],
},
],
// JSDoc rules
'jsdoc/check-tag-names': [
'warn',
{
definedTags: ['category', 'internal', 'experimental'],
},
],
'jsdoc/require-jsdoc': [
'warn',
{
contexts: needsDocsContexts,
},
],
'jsdoc/require-description': [
'warn',
{
contexts: needsDocsContexts,
},
],
'jsdoc/require-description-complete-sentence': 'warn',
'jsdoc/require-returns': 'off',
'jsdoc/require-param-type': 'off',
'jsdoc/tag-lines': [
'warn',
'any',
{
startLines: 1,
},
],
'jsdoc/no-undefined-types': [
'warn',
{
definedTypes: [
'durabilityLevel',
'effectiveRoles',
'GetOptions',
'IBucketSettings',
'MutationState',
'StorageBackend',
],
},
],
// Other rules
'prefer-rest-params': 'off',
},
},
// Test-specific overrides
{
files: ['test/**/*.{js,ts}'],
rules: {
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-require-imports': 'off', // Tests use CommonJS
'jsdoc/require-jsdoc': 'off',
},
},
// Prettier config (must be last to override conflicting rules)
prettierConfig,
]