Last active
May 1, 2025 17:13
-
-
Save oscarotero/1668dffc30764b74c8c3c92170b98c18 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const plugin: Deno.lint.Plugin = { | |
// The name of your plugin. Will be shown in error output | |
name: "my-plugin", | |
// Object with rules. The property name is the rule name and | |
// will be shown in the error output as well. | |
rules: { | |
"my-rule": { | |
// Inside the `create(context)` method is where you'll put your logic. | |
// It's called when a file is being linted. | |
create(context) { | |
// Return an AST visitor object | |
return { | |
// Here in this example we forbid any identifiers being named `_a` | |
Identifier(node) { | |
if (node.name === "_a") { | |
// Report a lint error with a custom message | |
context.report({ | |
node, | |
message: "should be _b", | |
// Optional: Provide a fix, which can be applied when | |
// the user runs `deno lint --fix` | |
fix(fixer) { | |
return fixer.replaceText(node, "_b"); | |
}, | |
}); | |
} | |
}, | |
}; | |
}, | |
}, | |
}, | |
}; | |
export default plugin; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const plugin: Deno.lint.Plugin = { | |
// The name of your plugin. Will be shown in error output | |
name: "my-plugin", | |
// Object with rules. The property name is the rule name and | |
// will be shown in the error output as well. | |
rules: { | |
"my-rule": { | |
// Inside the `create(context)` method is where you'll put your logic. | |
// It's called when a file is being linted. | |
create(context) { | |
// Return an AST visitor object | |
return { | |
// Here in this example we forbid any identifiers being named `_a` | |
Identifier(node) { | |
if (node.name === "_a") { | |
// Report a lint error with a custom message | |
context.report({ | |
node, | |
message: "should be _b", | |
// Optional: Provide a fix, which can be applied when | |
// the user runs `deno lint --fix` | |
fix(fixer) { | |
return fixer.replaceText(node, "_b"); | |
}, | |
}); | |
} | |
}, | |
}; | |
}, | |
}, | |
}, | |
}; | |
export default plugin; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment