Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Gettings started writing a ESLint rule

Gettings started writing a ESLint rule

First, take a look at the ESLint rule documentation. Just skim it for now. It's very long and boring. You can come back to it later.

ESLint rules works on the AST (Abstract Syntax Tree) representation of the code. In short, this is a tree structure that describes the code in a very verbose form. ESLint walks this tree and rules can subscribe to be notified when it hits a specific node type, like a Literal type, which could be the "hello" part of const welcome = "hello";.

Go ahead and play around with some code in AST Explorer (Make sure the parser is espree). It's a great tool!

Here are some good articles on the subject (ignore the scaffolding parts):

When you have some background knowledge, try cloning our repo and open any rule file and its and start modifying just to play around.

When you're ready to start working on a rule, take a look at previous rule addition for what's needed to add: and

Happy to answer question you might have in

Have fun! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment