rizowski / eslint-watch

ESLint with simple watching capabilities
https://www.npmjs.com/package/eslint-watch
MIT License
196 stars 29 forks source link

`--clear --color -w` causes duplicated output #163

Closed robchristian closed 5 years ago

robchristian commented 5 years ago

Environment

Basic Description of the problem

My team runs eslint with color output. Upon switching to eslint-watch, color was gone (we have an .eslintrc.json, I would expect esw to not change the behavior of eslint output). Upon adding --color and --clear (because obviously we want the terminal to clear, reviewing errors should not require extra focus), the terminal clears but it now logs errors in duplicate or triplicate, maybe even more.

How to reproduce it

from our package.json:

"lint-watch": "esw --color -c .eslintrc.json --cache --ext .ts,.tsx,.jsx,.js src -w --clear",

--color and --clear seem to be the main factors. Changing their order hasn't had much effect.

Our eslintrc.json:

{
  "parser": "@typescript-eslint/parser",
  "extends": ["eslint-config-airbnb"],
  "plugins": [ "jasmine", "@typescript-eslint" ],
  "rules": {
    "strict": 0,
    "indent": [ 2, 2, {"SwitchCase": 1}],
    "linebreak-style": [ 2, "unix" ],
    "max-len": [0],
    "import/no-unresolved": [0],
    "new-cap": [0],
    "arrow-parens": ["error", "always"],
    "camelcase": ["error"],
    "react/no-did-update-set-state": 0,
    "object-curly-newline": ["error", { "consistent": true }],
    "import/prefer-default-export": 0,
    "react/require-default-props": 0,
    "react/forbid-prop-types": 0,
    "jsx-a11y/label-has-for": 0,
    "jsx-a11y/label-has-associated-control": 0,
    "react/destructuring-assignment": 0,
    "jsx-a11y/anchor-is-valid": 0,
    "jsx-a11y/click-events-have-key-events": 0,
    "jsx-a11y/no-static-element-interactions": 0,
    "jsx-a11y/no-noninteractive-element-interactions": 0,
    "import/no-extraneous-dependencies": 0,
    "import/no-cycle": 0,
    "import/order": 0,
    "import/no-self-import": 0,
    "react/jsx-filename-extension": [1, { "extensions": [".tsx", ".jsx"] }],
    "consistent-return": [1, { "treatUndefinedAsUnspecified": false }]
  },
  "parserOptions": {
    "sourceType": "module",
    "allowImportExportEverywhere": false
  },
  "env": {
    "es6": true,
    "commonjs": true,
    "browser": true,
    "jest": true
  },
  "overrides": [
    {
     "files": ["*.ts", "*.tsx"],
        "rules": {
          "no-undef": 0,
          "no-unused-vars": 0,
          "react/prop-types": 0,
          "no-void": 0
        }
    }
  ]
}

Debug output:

I probably can't include this for you, since the output contains a lot of filepaths from a private, for-profit, project.

rizowski commented 5 years ago

🤔 Huh I'll have to look into that when I get a chance. I agree with you, it shouldn't remove color when running through esw. It also shouldn't be duplicating errors.

robchristian commented 5 years ago

Thanks.

Also,

rumanHuq commented 5 years ago

for me simply using --color -w reproduces the issue

tdeo commented 5 years ago

I've been running into a similar issue and I figured our by running esw with DEBUG=esw:* that this was in fact caused by using simultaneously --cache and -w:

  esw:events:watch Detected change: .eslintcache +826ms
  esw:eslint Executing [ '--cache', '--ext', [ '.json', '.js', '.html' ], '--eslintrc', '--ignore', '--inline-config', '.' ] +0ms
  esw:events:watch Detected change: .eslintcache +708ms
  esw:eslint Executing [ '--cache', '--ext', [ '.json', '.js', '.html' ], '--eslintrc', '--ignore', '--inline-config', '.' ] +0ms

I fixed it by changing my eslint-watch command to esw --cache -w --color src/ instead of esw --cache -w --color .

EDIT: actually, using --watch-ignore '/.git|node_modules|.eslintcache/' does the same job