File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -139,33 +139,7 @@ configurations minimal and only enable rules that catch real problems (the kind
139139that are likely to happen). This keeps our linting faster and reduces the number
140140of false positives.
141141
142- #### ` epic-web/no-manual-dispose `
143-
144- This config includes ` epic-web/no-manual-dispose ` as a warning to encourage
145- ` using ` and ` await using ` for disposable resources.
146-
147- The rule warns on:
148-
149- - direct calls to ` [Symbol.dispose] ` , ` [Symbol.asyncDispose] ` , and
150- ` [Symbol.disposeAsync] `
151- - ` .dispose() ` (or ` ['dispose']() ` ) calls inside ` finally ` blocks
152-
153- Example warning:
154-
155- ``` js
156- let tempFile
157- try {
158- tempFile = createTempFile ()
159- } finally {
160- tempFile? .[Symbol .dispose ]()
161- }
162- ` ` `
163-
164- Preferred:
165-
166- ` ` ` js
167- using tempFile = createTempFile ()
168- ` ` `
142+ Custom rule documentation lives in [ ` eslint-rules/index.md ` ] ( ./eslint-rules/index.md ) .
169143
170144### Oxlint
171145
Original file line number Diff line number Diff line change 1+ # ESLint rules
2+
3+ Custom ESLint rules for this package live in this directory.
4+
5+ Each rule should have:
6+
7+ - implementation: ` *.js `
8+ - tests: ` *.test.js `
9+ - documentation: ` *.md `
10+
11+ ## Rules
12+
13+ - [ ` epic-web/no-manual-dispose ` ] ( ./no-manual-dispose.md )
Original file line number Diff line number Diff line change 1+ # ` epic-web/no-manual-dispose `
2+
3+ Warns when disposable resources are cleaned up manually in patterns that should
4+ use ` using ` or ` await using ` .
5+
6+ ## Why
7+
8+ Manual cleanup with ` try/finally ` and disposal calls is easier to get wrong and
9+ less readable than language-level disposables.
10+
11+ ## What it warns on
12+
13+ - direct calls to ` [Symbol.dispose] `
14+ - direct calls to ` [Symbol.asyncDispose] `
15+ - direct calls to ` [Symbol.disposeAsync] `
16+ - ` .dispose() ` and ` ['dispose']() ` calls inside ` finally ` blocks
17+
18+ ## Examples
19+
20+ ### Invalid
21+
22+ ``` js
23+ let tempFile
24+ try {
25+ tempFile = createTempFile ()
26+ } finally {
27+ tempFile? .[Symbol .dispose ]()
28+ }
29+ ` ` `
30+
31+ ` ` ` js
32+ let tempFile
33+ try {
34+ tempFile = createTempFile ()
35+ } finally {
36+ tempFile? .dispose ()
37+ }
38+ ` ` `
39+
40+ ### Valid
41+
42+ ` ` ` js
43+ using tempFile = createTempFile ()
44+ ` ` `
45+
46+ ` ` ` js
47+ await using db = await createDisposableDatabase ()
48+ ` ` `
49+
50+ ` ` ` js
51+ function cleanup (resource ) {
52+ resource .dispose ()
53+ }
54+ ` ` `
You can’t perform that action at this time.
0 commit comments