mirror of
https://github.com/denoland/deno.git
synced 2025-02-23 13:43:31 -05:00

This PR supports returning multiple changes from a lint fix. It works the same way as eslint, see https://eslint.org/docs/latest/extend/custom-rules#applying-fixes . - Return a single fix - Return an array of fixes - Return a generator function with fixes
25 lines
672 B
TypeScript
25 lines
672 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) {
|
|
yield fixer.insertTextAfter(node.id, ": string");
|
|
yield fixer.replaceText(node.init!, '"bar"');
|
|
},
|
|
});
|
|
}
|
|
},
|
|
};
|
|
},
|
|
},
|
|
},
|
|
} satisfies Deno.lint.Plugin;
|