codeburst

Bursts of code to power through your day. Web Development articles, tutorials, and news.

Follow publication

ESLint on steroids with Airbnb + Standard JS styles

--

ESLint is a tool which helps you to write perfect JavaScript. Now it is easy to install it feature packed with best style configs out there: Airbnb Style Guide + JavaScript Standard Style.

See airbnb/javascript and standardjs for more information. Compare configs.

Just install eslint-config-airbnb-standard npm module globally:

npm install --global eslint-config-airbnb-standard

And now you can use supernormal ESLint from anywhere:

eslint -v
eslint app.js

Don’t forget to create .eslintrc file in your project. Also setup your IDE / Editor to fix your styles on the fly!

ES6, ES7, React, JSX, async/await — all new features supported by default 👍

Local installation is also appropriate. Install the module with --save-dev flag and use npx tool to run local ESLint: npx eslint -v

You can also find instructions for Atom and WebStorm.

How to use it in Sublime Text 3?

  1. Install the package npm i -g eslint-config-airbnb-standard
  2. Go to: Preferences -> Package Control -> install package
  3. Install SublimeLinter
  4. Install SublimeLinter-contrib-eslint
  5. Run npm bin -g… and copy the path
  6. Go to: Tools -> SublimeLinter -> Open User Settings
  7. Paste the path (nodejs global bin folder) inside “paths” for your OS, for example:
"paths": {
"linux": [
"~/.nvm/versions/node/v8.1.2/bin"
],
"osx": [],
"windows": [
"%AppData%\\npm"
]
},

8. Create .eslintrc file inside your working project:

{
"extends": ["airbnb-standard"]
}

9. Restart Sublime Text

10. Have fun!

Sublime Text 3 linting

What if I want to turn off semicolons?

You can turn off semicolons in .eslintrc (semi -> "never") for your project:

{
"extends": ["airbnb-standard"],
"rules": {
"semi": [2, "never"],
"object-curly-spacing": [2, "never"]
}
}

Good luck on your coding!

--

--

Published in codeburst

Bursts of code to power through your day. Web Development articles, tutorials, and news.

Responses (1)

Write a response