Install ESLint Through NPM
Install ESLint globally by running npm install -g eslint
Create a .eslint File in Your User Directory
We'll create a global .eslint.json file which will dictate linting for all directories below the User directory — for example Users/username/Projects. Linting settings can be overridden on a per-project basis by adding a .eslintrc file to a specific project directory.
- Open the terminal
- Go to the User directory by running
cd
- To install linting rules from a style guide, you'll need a package.json file. Create one by running
npm init
and following the prompts - Generate an .eslintrc file by running
eslint --init
. I selected the 'Use a popular style guide' option, followed by 'Airbnb', and finally 'JSON'
Install Sublime Packages
- Open Sublime Text
- Install Package Control if you don't have it
- Install SublimeLinter and SublimeLinter ESLint with Package Control
- Restart Sublime Text
- Edit a JavaScript file that resides under the User directory
At this point linting should be enabled and you should see warnings appear at the bottom of your editor!
Noticed an error in these steps or have feedback? You can reach out to me using the contact form.