4. Write your rule
Now, it's time to write your rule! When there is a match for your pattern, the function visit is invoked by the static analyzer. This function is the one that reports errors in your code.
The visit function is only triggered when the pattern matches and matches all occurrences of the pattern.
Let's first look at the function signature of the analysis rule:
1function visit(pattern, filename, code)
- pattern: this value represent the pattern that matches.
- filename: the filename being analyzed. For example, if the user edits the file foo/bar.py in their IDE, the value "foo/bar.py" will be passed for filename.
- code: the code as a text.
The filename argument is used to disable some checks for particular filenames. For example, we do not.
Let's go!
Start interacting with the tutorial!
my-new-rule.js