rizowski / eslint-watch

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

Error parsing '--rule' CLI option #154

Closed amourzenkov-sc closed 5 years ago

amourzenkov-sc commented 5 years ago

Environment

Basic Description of the problem

Erroneous handling of CLI --rule option.

How to reproduce it

Command: npx esw --rule 'indent: [2, tab]' src

Output:

Invalid value for option 'rule' - expected type Object, received value: [object Object].

Details

After some eslint-watch debugging I figured out that the command

npx esw --rule 'indent: [2, tab]' src

triggers eslint-watch's src/eslint/index.js line 17

const result = await execa('eslint', args);

with args equal to

[
  '--rule',
  { indent: [ 2, 'tab' ] },
  '--eslintrc',
  '--ignore',
  '--inline-config',
  'src'
]

So { indent: [ 2, 'tab' ] } gets changed to [object Object] string.

Just for the sake of debugging, if I manually hardcode eslint-watch's src/eslint/index.js line 17 with args equal to

[
  '--rule',
  'indent: [2, tab]',
  '--eslintrc',
  '--ignore',
  '--inline-config',
  'src'
]

everything works as expected and without throwing errors.

rizowski commented 5 years ago

This should have been fixed with #151 but I can verify. (Has not been released yet.)

rizowski commented 5 years ago

This should be fixed with v5.1.0