Repository navigation
Expand file tree
/
Copy pathbunfig.toml
More file actions
415 lines (405 loc) · 17.7 KB
/
Copy pathbunfig.toml
File metadata and controls
415 lines (405 loc) · 17.7 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
# The final config (user, 2026-10-17): bunfig.answered.toml with Q12-Q14 applied. PR A ships it as the root bunfig.toml.
# Q12: the 24 type-aware rules at Bun's severities (8 errors, the rest warnings), with the five no-unsafe-*, require-await and
# await-thenable off in tests (the override below). Q13: core no-useless-escape stays on (Bun's default). Q14: no [install] peer = false.
[lint]
typeAware = true # Q11: the type-aware rules run in the gate, the editor and every bun lint
plugins = [{ name = "regexp", specifier = "eslint-plugin-regexp" }]
ignorePatterns = [
"**/dist/**",
"**/dts/**",
"docs/**",
"benchmarks/results/**",
"**/bench/**/results/**",
]
reportUnusedDisableDirectives = "warn"
[lint.rules]
"@typescript-eslint/ban-ts-comment" = [
"error",
{ ts-expect-error = "allow-with-description" },
]
"@typescript-eslint/ban-types" = "off"
"@typescript-eslint/consistent-type-definitions" = ["error", "interface"]
"@typescript-eslint/consistent-type-imports" = [
"error",
{ disallowTypeAnnotations = false, fixStyle = "separate-type-imports", prefer = "type-imports" },
]
"@typescript-eslint/explicit-function-return-type" = "off"
"@typescript-eslint/explicit-module-boundary-types" = "off"
"@typescript-eslint/method-signature-style" = ["error", "property"]
"@typescript-eslint/no-array-constructor" = "error"
"@typescript-eslint/no-dupe-class-members" = "error"
"@typescript-eslint/no-duplicate-enum-values" = "error"
"@typescript-eslint/no-dynamic-delete" = "off"
"@typescript-eslint/no-empty-object-type" = [
"error",
{ allowInterfaces = "always" },
]
"@typescript-eslint/no-explicit-any" = "off"
"@typescript-eslint/no-extra-non-null-assertion" = "error"
"@typescript-eslint/no-extraneous-class" = "off"
"@typescript-eslint/no-import-type-side-effects" = "error"
"@typescript-eslint/no-invalid-void-type" = "off"
"@typescript-eslint/no-misused-new" = "error"
"@typescript-eslint/no-namespace" = ["error", { allowDeclarations = false }]
"@typescript-eslint/no-non-null-asserted-nullish-coalescing" = "error"
"@typescript-eslint/no-non-null-asserted-optional-chain" = "error"
"@typescript-eslint/no-non-null-assertion" = "off"
"@typescript-eslint/no-redeclare" = ["error", { builtinGlobals = false }]
"@typescript-eslint/no-require-imports" = "error"
"@typescript-eslint/no-this-alias" = "error"
"@typescript-eslint/no-unnecessary-type-constraint" = "error"
"@typescript-eslint/no-unsafe-declaration-merging" = "error"
"@typescript-eslint/no-unsafe-function-type" = "error"
"@typescript-eslint/no-unused-expressions" = [
"error",
{ allowShortCircuit = true, allowTaggedTemplates = true, allowTernary = true },
]
"@typescript-eslint/no-unused-vars" = [
"error",
{ args = "after-used", argsIgnorePattern = "^_", caughtErrorsIgnorePattern = "^_", ignoreRestSiblings = true, vars = "all", varsIgnorePattern = "^_" },
]
"@typescript-eslint/no-use-before-define" = [
"error",
{ classes = false, functions = false, variables = true },
]
"@typescript-eslint/no-useless-constructor" = "off"
"@typescript-eslint/no-wrapper-object-types" = "error"
"@typescript-eslint/prefer-as-const" = "error"
"@typescript-eslint/prefer-literal-enum-member" = "error"
"@typescript-eslint/prefer-namespace-keyword" = "error"
"@typescript-eslint/triple-slash-reference" = "off"
"@typescript-eslint/unified-signatures" = "off"
"accessor-pairs" = [
"error",
{ enforceForTSTypes = false, enforceForClassMembers = true, getWithoutSet = false, setWithoutGet = true },
]
"array-callback-return" = [
"error",
{ allowImplicit = false, checkForEach = false, allowVoid = false },
]
"arrow-body-style" = "off"
"block-scoped-var" = "error"
"bun/format" = "off" # Q6: bun fmt --check is its own step
"constructor-super" = "off"
"curly" = "off"
"default-case-last" = "error"
"dot-notation" = ["error", { allowKeywords = true, allowPattern = "" }]
"eqeqeq" = ["error", "smart"]
"getter-return" = "off"
"import/consistent-type-specifier-style" = ["error", "prefer-top-level"]
"import/first" = "error"
"import/newline-after-import" = ["error", { count = 1 }]
"import/no-duplicates" = "error"
"import/no-mutable-exports" = "error"
"import/no-named-default" = "error"
"n/handle-callback-err" = ["error", "^(err|error)$"]
"n/no-exports-assign" = "error"
"n/no-new-require" = "error"
"n/no-path-concat" = "error"
"n/no-top-level-await" = "error"
"new-cap" = [
"error",
{ capIsNew = false, capIsNewExceptions = ["Array", "Boolean", "Date", "Error", "Function", "Number", "Object", "RegExp", "String", "Symbol", "BigInt"], newIsCap = true, newIsCapExceptions = [], properties = true },
]
"no-alert" = "error"
"no-array-constructor" = "off"
"no-async-promise-executor" = "off"
"no-caller" = "error"
"no-case-declarations" = "error"
"no-class-assign" = "off"
"no-compare-neg-zero" = "error"
"no-cond-assign" = ["error", "always"]
"no-console" = ["warn", {}]
"no-const-assign" = "off"
"no-control-regex" = "error"
"no-debugger" = "error"
"no-delete-var" = "error"
"no-dupe-args" = "off"
"no-dupe-class-members" = "off"
"no-dupe-keys" = "off"
"no-duplicate-case" = "error"
"no-empty" = ["error", { allowEmptyCatch = true }]
"no-empty-character-class" = "off"
"no-empty-pattern" = ["error", { allowObjectPatternsAsParameters = false }]
"no-eval" = ["error", { allowIndirect = false }]
"no-ex-assign" = "error"
"no-extend-native" = ["error", { exceptions = [] }]
"no-extra-bind" = "error"
"no-extra-boolean-cast" = ["error", {}]
"no-fallthrough" = [
"error",
{ allowEmptyCase = false, reportUnusedFallthroughComment = false },
]
"no-func-assign" = "off"
"no-global-assign" = ["error", { exceptions = [] }]
"no-implied-eval" = "error"
"no-import-assign" = "off"
"no-invalid-regexp" = "off"
"no-irregular-whitespace" = [
"error",
{ skipComments = false, skipJSXText = false, skipRegExps = false, skipStrings = true, skipTemplates = false },
]
"no-iterator" = "error"
"no-labels" = "off"
"no-lone-blocks" = "error"
"no-loss-of-precision" = "error"
"no-misleading-character-class" = ["error", { allowEscape = false }]
"no-multi-str" = "error"
"no-new" = "error"
"no-new-func" = "error"
"no-new-native-nonconstructor" = "off"
"no-new-symbol" = "off"
"no-new-wrappers" = "error"
"no-obj-calls" = "off"
"no-octal" = "error"
"no-octal-escape" = "error"
"no-proto" = "error"
"no-prototype-builtins" = "error"
"no-redeclare" = "off"
"no-regex-spaces" = "error"
"no-restricted-globals" = [
"error",
{ message = "Use `globalThis` instead.", name = "global" },
{ message = "Use `globalThis` instead.", name = "self" },
{ message = "Import it: `import { Buffer } from \"node:buffer\"`.", name = "Buffer" },
{ message = "Import it: `import process from \"node:process\"`.", name = "process" },
] # Q8: node/prefer-global/{buffer,process} "never"
"no-restricted-properties" = [
"error",
{ message = "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property = "__proto__" },
{ message = "Use `Object.defineProperty` instead.", property = "__defineGetter__" },
{ message = "Use `Object.defineProperty` instead.", property = "__defineSetter__" },
{ message = "Use `Object.getOwnPropertyDescriptor` instead.", property = "__lookupGetter__" },
{ message = "Use `Object.getOwnPropertyDescriptor` instead.", property = "__lookupSetter__" },
]
"no-restricted-syntax" = "off"
"no-self-assign" = ["error", { props = true }]
"no-self-compare" = "error"
"no-sequences" = ["error", { allowInParentheses = true }]
"no-setter-return" = "off"
"no-shadow-restricted-names" = ["error", { reportGlobalThis = true }]
"no-sparse-arrays" = "error"
"no-template-curly-in-string" = "error"
"no-this-before-super" = "off"
"no-throw-literal" = "error"
"no-undef" = "off"
"no-undef-init" = "error"
"no-unexpected-multiline" = "off"
"no-unmodified-loop-condition" = "error"
"no-unneeded-ternary" = ["error", { defaultAssignment = false }]
"no-unreachable" = "off"
"no-unreachable-loop" = ["error", { ignore = [] }]
"no-unsafe-finally" = "error"
"no-unsafe-negation" = "off"
"no-unused-expressions" = "off"
"no-unused-vars" = "off"
"no-use-before-define" = "off"
"no-useless-backreference" = "off"
"no-useless-call" = "error"
"no-useless-catch" = "error"
"no-useless-computed-key" = ["error", { enforceForClassMembers = true }]
"no-useless-constructor" = "off"
"no-useless-rename" = [
"error",
{ ignoreDestructuring = false, ignoreImport = false, ignoreExport = false },
]
"no-useless-return" = "error"
"no-var" = "error"
"no-with" = "off"
"object-shorthand" = [
"error",
"always",
{ avoidQuotes = true, ignoreConstructors = false },
]
"one-var" = ["error", { initialized = "never" }]
"prefer-arrow-callback" = "off"
"prefer-const" = [
"error",
{ destructuring = "all", ignoreReadBeforeAssign = true },
]
"prefer-exponentiation-operator" = "error"
"prefer-object-has-own" = "error"
"prefer-promise-reject-errors" = ["error", { allowEmptyReject = false }]
"prefer-regex-literals" = ["error", { disallowRedundantWrapping = true }]
"prefer-rest-params" = "error"
"prefer-spread" = "error"
"prefer-template" = "error"
"react/jsx-child-element-spacing" = "off"
"react/jsx-closing-bracket-location" = "off"
"react/jsx-closing-tag-location" = "off"
"react/jsx-curly-brace-presence" = [
"error",
{ props = "never", children = "never", propElementValues = "always" },
]
"react/jsx-curly-newline" = "off"
"react/jsx-curly-spacing" = "off"
"react/jsx-equals-spacing" = "off"
"react/jsx-first-prop-new-line" = "off"
"react/jsx-indent" = "off"
"react/jsx-indent-props" = "off"
"react/jsx-max-props-per-line" = "off"
"react/jsx-newline" = "off"
"react/jsx-one-expression-per-line" = "off"
"react/jsx-props-no-multi-spaces" = "off"
"react/jsx-tag-spacing" = "off"
"react/jsx-wrap-multilines" = "off"
"symbol-description" = "error"
"unicode-bom" = ["error", "never"]
"unicorn/consistent-empty-array-spread" = "error"
"unicorn/empty-brace-spaces" = "off"
"unicorn/error-message" = "error"
"unicorn/escape-case" = ["error", "uppercase"]
"unicorn/new-for-builtins" = "error"
"unicorn/no-abusive-eslint-disable" = "error"
"unicorn/no-instanceof-builtins" = [
"error",
{ useErrorIsError = false, strategy = "loose", include = [], exclude = [] },
]
"unicorn/no-nested-ternary" = "off"
"unicorn/no-new-array" = "error"
"unicorn/no-new-buffer" = "error"
"unicorn/number-literal-case" = "off"
"unicorn/prefer-array-some" = "error"
"unicorn/prefer-date-now" = "error"
"unicorn/prefer-dom-node-text-content" = "error"
"unicorn/prefer-includes" = "error"
"unicorn/prefer-node-protocol" = "error"
"unicorn/prefer-number-properties" = [
"error",
{ checkInfinity = false, checkNaN = true },
]
"unicorn/prefer-regexp-test" = "error"
"unicorn/prefer-string-starts-ends-with" = "error"
"unicorn/prefer-type-error" = "error"
"unicorn/throw-new-error" = "error"
"use-isnan" = [
"error",
{ enforceForIndexOf = true, enforceForSwitchCase = true },
]
"valid-typeof" = ["error", { requireStringLiterals = true }]
"vars-on-top" = "error"
"yoda" = ["error", "never", { exceptRange = false, onlyEquality = false }]
# eslint-plugin-regexp, run as a JavaScript plugin (loads without the eslint package)
"regexp/confusing-quantifier" = "warn"
"regexp/control-character-escape" = "error"
"regexp/match-any" = "error"
"regexp/negation" = "error"
"regexp/no-contradiction-with-assertion" = "error"
"regexp/no-dupe-characters-character-class" = "error"
"regexp/no-dupe-disjunctions" = "error"
"regexp/no-empty-alternative" = "warn"
"regexp/no-empty-capturing-group" = "error"
"regexp/no-empty-character-class" = "error"
"regexp/no-empty-group" = "error"
"regexp/no-empty-lookarounds-assertion" = "error"
"regexp/no-empty-string-literal" = "error"
"regexp/no-escape-backspace" = "error"
"regexp/no-extra-lookaround-assertions" = "error"
"regexp/no-invalid-regexp" = "error"
"regexp/no-invisible-character" = "error"
"regexp/no-lazy-ends" = "warn"
"regexp/no-legacy-features" = "error"
"regexp/no-misleading-capturing-group" = "error"
"regexp/no-misleading-unicode-character" = "error"
"regexp/no-missing-g-flag" = "error"
"regexp/no-non-standard-flag" = "error"
"regexp/no-obscure-range" = "error"
"regexp/no-optional-assertion" = "error"
"regexp/no-potentially-useless-backreference" = "warn"
"regexp/no-super-linear-backtracking" = "error"
"regexp/no-trivially-nested-assertion" = "error"
"regexp/no-trivially-nested-quantifier" = "error"
"regexp/no-unused-capturing-group" = "error"
"regexp/no-useless-assertions" = "error"
"regexp/no-useless-backreference" = "error"
"regexp/no-useless-character-class" = "error"
"regexp/no-useless-dollar-replacements" = "error"
"regexp/no-useless-escape" = "error"
"regexp/no-useless-flag" = "warn"
"regexp/no-useless-lazy" = "error"
"regexp/no-useless-non-capturing-group" = "error"
"regexp/no-useless-quantifier" = "error"
"regexp/no-useless-range" = "error"
"regexp/no-useless-set-operand" = "error"
"regexp/no-useless-string-literal" = "error"
"regexp/no-useless-two-nums-quantifier" = "error"
"regexp/no-zero-quantifier" = "error"
"regexp/optimal-lookaround-quantifier" = "warn"
"regexp/optimal-quantifier-concatenation" = "error"
"regexp/prefer-character-class" = "error"
"regexp/prefer-d" = "error"
"regexp/prefer-plus-quantifier" = "error"
"regexp/prefer-predefined-assertion" = "error"
"regexp/prefer-question-quantifier" = "error"
"regexp/prefer-range" = "error"
"regexp/prefer-set-operation" = "error"
"regexp/prefer-star-quantifier" = "error"
"regexp/prefer-unicode-codepoint-escapes" = "error"
"regexp/prefer-w" = "error"
"regexp/simplify-set-operations" = "error"
"regexp/sort-flags" = "error"
"regexp/strict" = "error"
"regexp/use-ignore-case" = "error"
[[lint.overrides]]
files = [
"**/__tests__/**",
"**/*.spec.*",
"**/*.test.*",
"**/*.bench.*",
"**/*.benchmark.*",
]
rules = { "bun:test/consistent-test-it" = "off", "bun:test/no-focused-tests" = "error", "bun:test/no-identical-title" = "error", "bun:test/prefer-hooks-in-order" = "off", "bun:test/prefer-lowercase-title" = "off", "n/no-top-level-await" = "off", "vitest/no-import-node-test" = "error", "no-restricted-globals" = ["error", { message = "Use `globalThis` instead.", name = "global" }, { message = "Use `globalThis` instead.", name = "self" }, { message = "Import it: `import { Buffer } from \"node:buffer\"`.", name = "Buffer" }] } # Q4; antfu turns node/prefer-global/process off in tests
[[lint.overrides]]
files = ["packages/bun-ui/**", "examples/bun-ui/**"]
rules = { "react/error-boundaries" = "error", "react/exhaustive-deps" = "warn", "react/iframe-missing-sandbox" = "warn", "react/jsx-key" = "error", "react/jsx-no-comment-textnodes" = "warn", "react/jsx-no-script-url" = "warn", "react/no-access-state-in-setstate" = "error", "react/no-array-index-key" = "warn", "react/no-children-prop" = "warn", "react/no-clone-element" = "warn", "react/no-danger" = "warn", "react/no-danger-with-children" = "error", "react/no-did-mount-set-state" = "warn", "react/no-did-update-set-state" = "warn", "react/no-direct-mutation-state" = "error", "react/no-find-dom-node" = "error", "react/no-namespace" = "error", "react/no-render-return-value" = "error", "react/no-unsafe" = "warn", "react/no-unstable-nested-components" = "error", "react/no-unused-class-component-methods" = "warn", "react/no-will-update-set-state" = "warn", "react/only-export-components" = ["error", { allowConstantExport = false, allowExportNames = [] }], "react/purity" = "warn", "react/rules-of-hooks" = "error", "react/set-state-in-effect" = "warn", "react/set-state-in-render" = "error", "react/static-components" = "error", "react/unsupported-syntax" = "error", "react/use-memo" = "error", "react/void-dom-elements-no-children" = "error" }
# bun-client's React binding (PR-C6) and its tests: the hooks rules, nothing of the app rules above.
[[lint.overrides]]
files = [
"packages/bun-client/lib/react.ts",
"packages/bun-client/__tests__/react/**",
"packages/bun-client/__tests__/react.type-test.ts",
]
rules = { "react/exhaustive-deps" = "warn", "react/jsx-key" = "error", "react/rules-of-hooks" = "error" }
# antfu's per-glob disables (antfu/disables/scripts, cli, dts, cjs, config-files), kept as they are today.
[[lint.overrides]]
files = ["**/scripts/**", "**/cli/**", "**/cli.*", "**/*.config.*"]
rules = { "n/no-top-level-await" = "off" }
[[lint.overrides]]
files = ["**/*.d.ts", "**/*.d.mts", "**/*.d.cts"]
rules = { "@typescript-eslint/no-unused-vars" = "off", "unicorn/no-abusive-eslint-disable" = "off" }
[[lint.overrides]]
files = ["**/*.js", "**/*.cjs"]
rules = { "@typescript-eslint/no-require-imports" = "off" }
# CLI entry points: printing is the product, and top-level await blocks no importer.
# benchmarks/ joined in PR F, with the two rules its ESLint config turned off.
[[lint.overrides]]
files = [
"scripts/**",
"playground/**",
"examples/**",
"templates/*/scripts/**",
"benchmarks/**",
]
rules = { "no-console" = "off", "n/no-top-level-await" = "off" }
# Q12: in tests, the type-aware rules that flag test idiom (untyped fixtures, async callbacks with no await) are off.
[[lint.overrides]]
files = ["**/__tests__/**", "**/*.spec.*", "**/*.test.*"]
rules = { "@typescript-eslint/no-unsafe-argument" = "off", "@typescript-eslint/no-unsafe-assignment" = "off", "@typescript-eslint/no-unsafe-call" = "off", "@typescript-eslint/no-unsafe-member-access" = "off", "@typescript-eslint/no-unsafe-return" = "off", "@typescript-eslint/require-await" = "off", "@typescript-eslint/await-thenable" = "off" }
# Q5: Bun's default bug rules stay on, except bun:test/no-export in the shared test helpers.
[[lint.overrides]]
files = ["**/__tests__/helpers/**"]
rules = { "bun:test/no-export" = "off" }
[fmt]
singleAttributePerLine = true # the one option we set that is not Prettier's default
# Q3: Markdown is not formatted; Q2: no sortImports. Files a tool writes are not
# formatted either, so regenerating one never fails `bun fmt --check`: test
# timings (`--update-timings`), benchmark baselines (`--save-baseline`) and
# lerna.json (`lerna version`).
ignorePatterns = [
"**/*.md",
"docs/**",
"benchmarks/results/**",
"**/bun-timings*.json",
"**/baselines/*.json",
"lerna.json",
]