Skip to content

Instantly share code, notes, and snippets.

@vitorbal
Last active March 17, 2017 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vitorbal/dfabb2fda24cd47e3d7986a215749b01 to your computer and use it in GitHub Desktop.
Save vitorbal/dfabb2fda24cd47e3d7986a215749b01 to your computer and use it in GitHub Desktop.
eslint-ast-selectors
module.exports = {
create(context) {
return {
// This will be called for all FunctionDeclaration nodes
"FunctionDeclaration": function(functionDeclarationNode) {
// ...your custom logic goes here
},
}
};
module.exports = {
create(context) {
return {
"FunctionDeclaration": function(node) {
// First, exclude all function declarations that don't have
// more than 3 parameters
if (node.params.length <= 3) {
return;
}
// Now we can do our custom logic on functions with > 3 params
// .. custom logic goes here
}
}
};
module.exports = {
create(context) {
return {
"FunctionDeclaration[params.length>3]": function(node) {
// ...custom logic goes here
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment