Skip to content

Instantly share code, notes, and snippets.

@matiasfha
Created May 27, 2020 15:53
Show Gist options
  • Save matiasfha/2c150a928c6141592fff05261a7c79be to your computer and use it in GitHub Desktop.
Save matiasfha/2c150a928c6141592fff05261a7c79be to your computer and use it in GitHub Desktop.
A example rule for a basic eslint plugin
module.exports = {
meta: {
type: "suggestion",
docs: {
description: "Force Async function naming convention",
category: "Possible Errors",
recommended: true,
},
},
create: function (context) {
return {
FunctionDeclaration(node) {
console.log(node);
if (node.async && !/Async$/.test(node.id.name)) {
context.report({
node,
message: "Async function name must end in 'Async'",
});
}
},
};
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment