Working on a project and don’t want to or can’t install ESLint as a devDependency
in your package.json
? or maybe you just want ESLint to work on all of your projects instantly without all of the per app configuration. The steps described below will help you.
Installing ESLint Globally
Before starting, ensure you have Node.js
installed along with npm
(which should come packaged with your Node install).
Install ESLint Globally
npm i -g eslint
Navigate to your home folder.
On Linux: cd to or type
~/
in your file explorer of choice to get to your home folder.On Windows: Go to
C:\Users
folder in explorer, then enter the folder with your username.Create your
.eslintrc.json
file in your home folder and add your desired eslint config to it in JSON.// Example JSON config { "env": { "browser": true, "es2021": true }, "extends": "eslint:recommended", "parserOptions": { "ecmaVersion": "latest", "sourceType": "module" } }
Now you can lint your files
eslint lintmepls.js
(Optional) Install ESLint extension for VSCode
Go to the extensions tab, type in
ESLint
and download the one byMicrosoft
.Extension Links:
- Open VSX: https://open-vsx.org/extension/dbaeumer/vscode-eslint
- Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint
Helpful Resources
- ESLint playground: https://eslint.org/play/
- More on config files: https://eslint.org/docs/latest/use/configure/configuration-files