6. Write your rule
The rule code has a visit function that is the entry point of your rule.
1function visit(node, filename, code)
It has the following parameter:
- The
node
your rule matches on. The exact type of this argument depends on the element type being checked. All types inherit theAstElement
type. As the element checked is set toFunctionCall
, the node for our rule will be a typeFunctionCall
. - The
filename
where the code is located (a string) - The code being checked (a string)
- If the element type checked is a function call, the value of node is a
FunctionCall
object - If the element type checked is an if condition, the value of node is a
IfCondition
- If the element type checked is a for loop, the value of node is a
ForStatement
object - If the element type checked is a function definition, the value of node is a
FunctionDefinition
object - If the element type checked is a try block, the value of node is a
TryBlock
object - If the element type checked is an import, the value of node is an
Import
or anImportFrom
- If the element type checked is an assignment, the value of node is a
Assignment
object
Let's go!
Start interacting with the tutorial!
my-new-rule.js