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

feat(eslint-plugin): add rule restrict-template-expressions #850

Merged
merged 8 commits into from Nov 18, 2019
Merged

feat(eslint-plugin): add rule restrict-template-expressions #850

merged 8 commits into from Nov 18, 2019

Conversation

phaux
Copy link
Contributor

@phaux phaux commented Aug 13, 2019

Closes #818

(I'm submitting these PRs via VSCode extension and that's why I have to edit the title afterwards)

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @phaux!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint

@phaux phaux changed the title feat: 🎸 New rule restrict-template-expressions feat(eslint-plugin): 🎸 New rule restrict-template-expressions Aug 13, 2019
@bradzacher bradzacher added the enhancement: new plugin rule New rule request for eslint-plugin label Aug 13, 2019
@glen-84
Copy link
Contributor

glen-84 commented Aug 15, 2019

Would it be possible to allow any, for codebases that are not yet fully typed?

@ckknight
Copy link

Instead of options like allowBoolean or allowNumber, why not allow configuration like allowed: ['number', 'bigint', 'boolean', 'null']?

@phaux
Copy link
Contributor Author

phaux commented Aug 16, 2019

@glen-84 Noted.

@ckknight I was actually considering going into the other direction: allow "loose" option which enables all types which have obvious string representation, but later I split that into 3 separate options. Having 5 options is too much IMO. Also, I can't think of a case where you would want only one of number | bigint or null | undefined

@ark120202
Copy link

@phaux I'm not sure how common it would be, but one advantage of using a more generic filter would be an ability to allow some application-specific types with expected toString implementation.

bradzacher
bradzacher previously approved these changes Nov 13, 2019
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thanks for this!

@bradzacher bradzacher added the 1 approval PR that a maintainer has LGTM'd - any maintainer can merge this when ready label Nov 13, 2019
@codecov
Copy link

codecov bot commented Nov 18, 2019

Codecov Report

Merging #850 into master will increase coverage by 0.05%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master     #850      +/-   ##
==========================================
+ Coverage   94.17%   94.22%   +0.05%     
==========================================
  Files         124      125       +1     
  Lines        5322     5371      +49     
  Branches     1492     1509      +17     
==========================================
+ Hits         5012     5061      +49     
  Misses        177      177              
  Partials      133      133
Impacted Files Coverage Δ
...-plugin/src/rules/restrict-template-expressions.ts 100% <100%> (ø)
packages/eslint-plugin/src/rules/index.ts 100% <100%> (ø) ⬆️

@bradzacher bradzacher changed the title feat(eslint-plugin): 🎸 New rule restrict-template-expressions feat(eslint-plugin): add rule restrict-template-expressions Nov 18, 2019
@bradzacher bradzacher merged commit 46b58b4 into typescript-eslint:master Nov 18, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2020
@phaux phaux deleted the restrict-template-expressions branch February 27, 2021 15:04
@phaux phaux restored the restrict-template-expressions branch February 27, 2021 15:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1 approval PR that a maintainer has LGTM'd - any maintainer can merge this when ready enhancement: new plugin rule New rule request for eslint-plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rule proposal: Disallow implicit string conversion in template literals
5 participants