Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ban-ts-comment] multiline @ts-ignore and @ts-expect-error not supported #2617

Closed
dimitropoulos opened this issue Sep 30, 2020 · 7 comments · Fixed by #2644
Closed

[ban-ts-comment] multiline @ts-ignore and @ts-expect-error not supported #2617

dimitropoulos opened this issue Sep 30, 2020 · 7 comments · Fixed by #2644
Labels
bug Something isn't working good first issue Good for newcomers package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@dimitropoulos
Copy link
Contributor

dimitropoulos commented Sep 30, 2020

The regex we use for detecting TypeScript directives was originally adapted from tslint. Since then (I think??) TypeScript has added multiline comment support for directives.

You can see TypeScript's own regexs here (they have one for single line and another for multiline) as well as some useful test cases here.

Repro

{
  "rules": {
    "@typescript-eslint/ban-ts-comment": "error"
  }
}
if (false) {
  // @ts-expect-error
  console.log('this errors (appropriately) because a description is missing');
}

if (false) {
  // @ts-expect-error explanation: ziltoid is omniscient
  console.log('this does not error (appropriately) because a description is present');
}

if (false) {
  /* @ts-expect-error */
  console.log('this one does not error, although it should');
}

Expected Result

if (false) {
  /* @ts-expect-error */
  console.log('this one does not error, although it should');
}

should return an error.

Actual Result

no error is returned.

Additional Info

Versions

package version
@typescript-eslint/eslint-plugin 4.1.1
@typescript-eslint/parser 4.1.1
TypeScript 4.0.2
ESLint 7.10.0
node 12.6.0
@dimitropoulos dimitropoulos added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Sep 30, 2020
@dimitropoulos
Copy link
Contributor Author

I'll note that while I'd be happy to fix this, this would be a great first contribution from someone because the typescript tests (linked above) and the real-life regex used by typescript (also linked above) are already written. We simply need to update our regex here to match (or, add two like typescript did, if so, and check both) and add some new tests (which, again, can simply mirror theirs).

@bradzacher
Copy link
Member

prior art for a similar fix for prefer-ts-expect-error: #2541

@bradzacher bradzacher added bug Something isn't working good first issue Good for newcomers and removed triage Waiting for maintainers to take a look labels Sep 30, 2020
@dimitropoulos
Copy link
Contributor Author

cool, thanks. I'll make a reminder to come check back on this in a little while.

In the meantime if anyone sees this and wants to give it a try I'd be happy to help however I can - pair programming included.

@parynaz
Copy link

parynaz commented Oct 1, 2020

@dimitropoulos hi! I'm looking to contribute for the first time here & this looks like a good candidate as you have pointed out. Is this still something I could look into fixing?

@dimitropoulos
Copy link
Contributor Author

Definitely! Let me know if I can help!

@dopecodez
Copy link
Contributor

I'd like to do take this up if its available. @parynaz , do you still plan on contributing to this issue?

@dimitropoulos
Copy link
Contributor Author

thanks again @dopecodez for your contribution!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working good first issue Good for newcomers package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants