Linter - ESLint



npm install eslint --save-dev
npx eslint --init

Creates:


.eslintrc.json


examples/basic/.eslintrc.json
{
    "env": {
        "browser": true,
        "es2021": true
    },
    "extends": [
        "standard"
    ],
    "parserOptions": {
        "ecmaVersion": 12,
        "sourceType": "module"
    },
    "rules": {
        "quotes": ["off", "double"],
        "no-console": ["off"],
        "indent": ["error", 4]
    }
}

Run it:


npx eslint *.js

In package.json set:


  "scripts": {
    "test": "npx eslint *.js"
  },

Then run as


$ npm run test