Skip to content

Commit

Permalink
feat(unstable): add test for lint plugin destroy hook (#27981)
Browse files Browse the repository at this point in the history
Noticed that we didn't test the `destroy()` hook of lint plugins. This
PR adds a test for that.
  • Loading branch information
marvinhagemeister authored Feb 6, 2025
1 parent df02af2 commit 9213215
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/specs/lint/lint_plugin_lifecycle/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"steps": [
{
"args": "lint a.ts",
"output": "lint.out"
}
]
}
1 change: 1 addition & 0 deletions tests/specs/lint/lint_plugin_lifecycle/a.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const _a = "foo";
5 changes: 5 additions & 0 deletions tests/specs/lint/lint_plugin_lifecycle/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"lint": {
"plugins": ["./plugin.ts"]
}
}
5 changes: 5 additions & 0 deletions tests/specs/lint/lint_plugin_lifecycle/lint.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
create: test-plugin/my-rule
create: test-plugin/my-rule-2
destroy: test-plugin/my-rule
destroy: test-plugin/my-rule-2
Checked 1 file
23 changes: 23 additions & 0 deletions tests/specs/lint/lint_plugin_lifecycle/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export default {
name: "test-plugin",
rules: {
"my-rule": {
create(ctx) {
console.log(`create: ${ctx.id}`);
return {};
},
destroy(ctx) {
console.log(`destroy: ${ctx.id}`);
},
},
"my-rule-2": {
create(ctx) {
console.log(`create: ${ctx.id}`);
return {};
},
destroy(ctx) {
console.log(`destroy: ${ctx.id}`);
},
},
},
};

0 comments on commit 9213215

Please sign in to comment.