0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-11 14:47:26 -04:00
deno/tests/specs/lint/lint_plugin_rule_context/plugin.ts
Marvin Hagemeister 6c368c2469
fix(unstable): align js lint context API with eslint (#28066)
This PR aligns the `RuleContext` of JS plugins with ESLint.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2025-02-13 14:01:57 +00:00

30 lines
792 B
TypeScript

import path from "node:path";
export default {
name: "test-plugin",
rules: {
"my-rule": {
create(context) {
return {
VariableDeclarator(node) {
console.log(`ctx.id:`);
console.log(context.id);
console.log();
console.log(`ctx.filename:`);
console.log(path.relative(Deno.cwd(), context.filename));
console.log();
console.log(`ctx.getFilename():`);
console.log(path.relative(Deno.cwd(), context.getFilename()));
console.log();
console.log(`ctx.getSourceCode():`);
console.log(context.getSourceCode() === context.sourceCode);
console.log();
},
};
},
},
},
} satisfies Deno.lint.Plugin;