Skip to content

[restrict-template-expressions] add option to allow regular expressions #3671

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

Closed
3 tasks done
JoshuaKGoldberg opened this issue Aug 1, 2021 · 1 comment · Fixed by #3709
Closed
3 tasks done

[restrict-template-expressions] add option to allow regular expressions #3671

JoshuaKGoldberg opened this issue Aug 1, 2021 · 1 comment · Fixed by #3709
Labels
enhancement: plugin rule option New rule option for an existing eslint-plugin rule package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@JoshuaKGoldberg
Copy link
Member

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

{
  "rules": {
    "@typescript-eslint/restrict-template-expressions": ["error"]
  }
}
function log(value: RegExp) {
  console.log(`${value}`);
}

Expected Result

Since RegExp defines .toString(), I would expect that there would be options to allow printing them similar to allowBoolean.

Actual Result

No way to make this allowed without disabling the rule.

Additional Info

Context: hoping to enable this internally for #3278.

Versions

package version
@typescript-eslint/eslint-plugin 4.28.5
@typescript-eslint/parser 4.28.5
TypeScript 4.3.5
ESLint 7.27.0
node 16.6.0
@JoshuaKGoldberg JoshuaKGoldberg added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Aug 1, 2021
@bradzacher bradzacher added enhancement: plugin rule option New rule option for an existing eslint-plugin rule and removed triage Waiting for team members to take a look labels Aug 4, 2021
@Ulrikop
Copy link

Ulrikop commented Aug 4, 2021

I would also appreciate an option to allow objects with a toString implementation (so not only for allowing RegExp).

I want to use the rule to avoid text like [object Object], but I don't want to unnecessarily complicate the code in places where it is not necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement: plugin rule option New rule option for an existing eslint-plugin rule package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
3 participants