remithomas / eslint-plugin-ban

Ban some methods and functions
ISC License
31 stars 3 forks source link

Smaller range for the reported error #4

Closed felixfbecker closed 5 years ago

felixfbecker commented 5 years ago

With TSLint's ban rule configured to ban it.only(), this code would report a warning for the only part:

it.only('does abc', () => {
   ^^^^
  const foo = callFn()
  assert.equal(foo, 'bar')
})

This was nice because it is unobtrusive when debugging a test but makes sure you don't accidentally commit & merge the only into master.

The ESLint plugin unfortunately reports an error for the entire function call:

it.only('does abc', () => {
   ^^^^^^^^^^^^^^^^^^^^^^^^
  const foo = callFn()
^^^^^^^^^^^^^^^^^^^^^^
  assert.equal(foo, 'bar')
^^^^^^^^^^^^^^^^^^^^^^^^^^
})
^

This makes writing code with all the distraction difficult, which results in people adding eslint-disable while debugging, which means the protection from merging it into master is gone :/

Could this range be reduced to only include the identifier, like TSLint?

remithomas commented 5 years ago

yes, indeed. Thanks for the report. I will work on it.

remithomas commented 5 years ago

This should be fixed with this last version, just published.