-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(eslint-plugin): [no-type-alias]: add allowGenerics option #3865
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): [no-type-alias]: add allowGenerics option #3865
Conversation
Thanks for the PR, @scottohara! 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. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day. |
Codecov Report
@@ Coverage Diff @@
## master #3865 +/- ##
==========================================
+ Coverage 92.70% 93.53% +0.83%
==========================================
Files 329 149 -180
Lines 11534 8049 -3485
Branches 3257 2553 -704
==========================================
- Hits 10693 7529 -3164
+ Misses 368 164 -204
+ Partials 473 356 -117
Flags with carried forward coverage won't be shown. Click here to find out more.
|
I think an option |
Hi @JounQin, Thanks for your suggestion of I think I agree with you that an To confirm, for declarations like: type Foo = Record<string, number>;
type Bar = Readonly<Foo>;
// etc. ...the
I'm interested to understand whether the option also needs to support some of the other elements of your
? Are there any other forms of generic declarations (other than |
@scottohara Personally I'd love to see an option to cover my use case which only disallows simple alias, but for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for this!
Fixes #3784
(⚠️ Note: an earlier version of this PR introduced an
allowedAliasNames: []
option which accepted an array of strings to ignore. This was later swapped to anallowGenerics: 'always' | 'never'
option that permits/prevents anyTSTypeReference
that has parameters)This change adds an option to
no-type-alias
to allow generics to be ignored by the rule.The new option is
allowGenerics
, and can be set to"always"
or"never"
(default is"never"
), e.g.As discussed in #3784, the main driver for this change is to avoid a conflict when using both
consistent-indexed-object-style
andno-type-alias
with their default options.Specifically to allow the following code to pass both rules: