0
votes

I'm using es-lint VScode extension and it is catching 5 linting errors, however when I run npm run lint from package.json It only lists 2 errors. I'm wondering why the terminal is not outputting all linting errors, so I can fix it with esw --fix on save.

Note: I'm using both prettier and airbnb config rules.

Here is my .eslintrc:

{
  "extends": ["airbnb", "prettier"],
  "plugins": ["prettier"],
  "globals": { "document": false }
}

Here is pacjakge.json:

 {
  "dependencies": {
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-redux": "^5.0.6",
    "react-scripts": "1.0.17",
    "redux": "^3.7.2",
    "styled-components": "^2.2.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject",
    "lint": "eslint --fix ./src",
    "watch:lint": "node_modules/eslint-watch/bin/esw -w --fix"
  },
  "devDependencies": {
    "eslint": "^4.12.1",
    "eslint-config-airbnb": "^16.1.0",
    "eslint-config-prettier": "^2.9.0",
    "eslint-plugin-import": "^2.8.0",
    "eslint-plugin-jsx-a11y": "^6.0.2",
    "eslint-plugin-prettier": "^2.3.1",
    "eslint-plugin-react": "^7.5.1",
    "eslint-watch": "^3.1.3",
    "prettier": "^1.9.1"
  }
1

1 Answers

1
votes

You are using the --fix option when running npm run lint, that means ESLint will only display errors/warnings it can't fix automatically.. everything else, it will just fix and not complain about.

If you want it to list all the errors/warning, you can remove --fix from your NPM script, and it will list all erros/warnings it finds (it will run eslint ./src). Later if you want to fix the errors as well, run npm run lint -- --fix, that will pass everything after -- directly to the script, i.e., will run eslint ./src --fix which will work correctly.