Skip to content

Commit 913d51f

Browse files
feat: Eslint disposable test hooks (#49)
* add eslint rule to prefer disposables over test hooks Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com> * fix lint order and rule test harness paths Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com> * Fix hook detection for known test hooks * Fix outer write detection for destructuring * Fix known framework hooks for suite hooks * document dispose rule and migrate tests to RuleTester Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com> * organize eslint rule assets under eslint-rules Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com> * optimize custom rule for oxlint js plugins Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com> * handle null context options in oxlint compat path Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com> * compute source and options in before hook for compat Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com> * rename eslint-rules directory to lint-rules Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com> * align prefer-dispose docs and plugin with main lint-rules layout Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com> * enable prefer-dispose rule in oxlint config Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent e664169 commit 913d51f

9 files changed

Lines changed: 872 additions & 0 deletions

eslint-plugin-epic-web.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export { default } from './lint-rules/epic-web-plugin.js'
2+
export { default as noManualDisposeRule } from './lint-rules/no-manual-dispose.js'
3+
export { default as preferDisposeInTestsRule } from './lint-rules/prefer-dispose-in-tests.js'

eslint.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,13 @@ export const config = [
251251
},
252252
},
253253

254+
{
255+
files: testFiles,
256+
rules: {
257+
'epic-web/prefer-dispose-in-tests': WARN,
258+
},
259+
},
260+
254261
hasTestingLibrary
255262
? {
256263
files: testFiles,

lint-rules/epic-web-plugin.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import { eslintCompatPlugin } from '@oxlint/plugins'
22
import noManualDispose from './no-manual-dispose.js'
3+
import preferDisposeInTests from './prefer-dispose-in-tests.js'
34

45
const plugin = eslintCompatPlugin({
56
meta: {
67
name: 'epic-web',
78
},
89
rules: {
910
'no-manual-dispose': noManualDispose,
11+
'prefer-dispose-in-tests': preferDisposeInTests,
1012
},
1113
})
1214

1315
export default plugin
16+
export { noManualDispose, preferDisposeInTests }

lint-rules/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ remaining ESLint-compatible.
1515
## Rules
1616

1717
- [`epic-web/no-manual-dispose`](./no-manual-dispose.md)
18+
- [`epic-web/prefer-dispose-in-tests`](./prefer-dispose-in-tests.md)

0 commit comments

Comments
 (0)