mirror of
https://github.com/denoland/deno.git
synced 2025-02-22 21:23:32 -05:00
28 lines
711 B
TypeScript
28 lines
711 B
TypeScript
![]() |
export default {
|
||
|
name: "test-plugin",
|
||
|
rules: {
|
||
|
"my-rule": {
|
||
|
create(context) {
|
||
|
return {
|
||
|
VariableDeclarator(node) {
|
||
|
if (
|
||
|
node.init?.type === "Literal" && node.init.value === "unfixed"
|
||
|
) {
|
||
|
context.report({
|
||
|
node: node.init!,
|
||
|
message: 'should be "bar" + have string type',
|
||
|
fix(fixer) {
|
||
|
return [
|
||
|
fixer.insertTextAfter(node.id, ": string"),
|
||
|
fixer.replaceText(node.init!, '"bar"'),
|
||
|
];
|
||
|
},
|
||
|
});
|
||
|
}
|
||
|
},
|
||
|
};
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
} satisfies Deno.lint.Plugin;
|