Getting Started With ESLint

An Introduction, Popular Configs Comparison, and Resources

Danny Lee
Danny Lee
Jun 17, 2020 · 6 min read
source: Flickr, by musicmoon@rogers.com used under CC BY / cropped, text added.

What is a Linter?

Linters have a long history in software development. Stephen C. Johnson (writings) developed Lint while debugging Yacc (Yet Another Compiler-Compiler), which was written in the C programming language at Bell Labs in 1978.

What are some Rule Examples?

An example of a “possible error” rule is no-debugger . It handles situations where a deadline-burdened programmer might have forgotten a debugger statement somewhere in code that is going to production. Although code with a debugger statement will open and might be functional, its not optimal. If the user opens the browser’s developer tools console, they will drop into the debugger. By choosing a setting of “error” for this rule, ESLint will flag a block of code with a debugger statement as an error:

// this code block will cause an errorfunction getUserName(user) {
debugger;
return user.name;
}
// this code block will cause an errorswitch (bird) {
case 'robin':
playRobinSong();
case 'bluejay':
playBluejaySong();
}
// optional setting for no-fallthrough rule{ "commentPattern": "allow fallthrough" ]// this code block will not show an error for case 1switch(someVariable) {
case 1:
someFunction();
// allow fallthrough

case 2:
anotherFunction();
}
// function calledjpSaxe()// construct a new objectnew jpSaxe()
let ifTheWorld = jpSaxe;
comeOverRight(jpSaxe);
comeOverRight(()=> {
jpSaxe();
});
// default configuration (options) object{ "before": true, "after": true }
// sample code() => {}; // OK()=> {}; // not OK
// alternative configuration
{ "before": false, "after": true }
// sample code() => {}; // not OK()=> {}; // OK

Other Premade Configurations

Once you get acquainted with how to setup your ESLint to accept premade configurations you might want to look into other less popular than Airbnb like Google’s (npm)or Standard JS (website). There’s also configurations by companies such as Spotify (github), Netflix (github), Palantir (github), Naver (github), Walmart (github) and also by some individuals like Wes Bos (github) and Kent C Dodds (github).

What’s different about the 4 most popular configurations?

In my own search for a style that feels right for me I searched high and low for some kind of comparison of the ESLint rules that each configuration turned on and off. But, I couldn’t find one. 😐 The comparisons I found were mostly limited to how popular a config was, how often it was updated and generalizations about their differences.

The Startup

Get smarter at building your thing. Join The Startup’s +794K followers.

Sign up for Top 10 Stories

By The Startup

Get smarter at building your thing. Subscribe to receive The Startup's top 10 most read stories — delivered straight into your inbox, once a week. Take a look.

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.

Danny Lee

Written by

Danny Lee

a nyc based coding enthusiast, handyman, farmer at-heart, artist and future surfer

The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +794K followers.

Danny Lee

Written by

Danny Lee

a nyc based coding enthusiast, handyman, farmer at-heart, artist and future surfer

The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +794K followers.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store