-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(eslint-plugin): [consistent-type-definitions] correct fix for export default
#3899
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
Conversation
Thanks for the PR, @rafaelss95! 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 #3899 +/- ##
==========================================
+ Coverage 92.70% 93.52% +0.81%
==========================================
Files 329 149 -180
Lines 11534 8046 -3488
Branches 3257 2552 -705
==========================================
- Hits 10693 7525 -3168
+ Misses 368 164 -204
+ Partials 473 357 -116
Flags with carried forward coverage won't be shown. Click here to find out more. |
@@ -122,6 +122,19 @@ export default util.createRule({ | |||
}); | |||
} | |||
|
|||
if ( |
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.
While working on this fix, I noticed that the option is checked after having already found a certain node (and in some other files as well), for example:
typescript-eslint/packages/eslint-plugin/src/rules/consistent-type-definitions.ts
Lines 50 to 54 in 1e7e6d8
return { | |
"TSTypeAliasDeclaration[typeAnnotation.type='TSTypeLiteral']"( | |
node: TSESTree.TSTypeAliasDeclaration, | |
): void { | |
if (option === 'interface') { |
Other cases I found (click to expand)
typescript-eslint/packages/eslint-plugin/src/rules/method-signature-style.ts
Lines 120 to 123 in b1d4449
TSMethodSignature(methodNode): void { | |
if (mode === 'method') { | |
return; | |
} |
typescript-eslint/packages/eslint-plugin/src/rules/restrict-plus-operands.ts
Lines 136 to 137 in 1c1b572
"AssignmentExpression[operator='+=']"(node): void { | |
if (checkCompoundAssignments) { |
typescript-eslint/packages/eslint-plugin/src/rules/sort-type-union-intersection-members.ts
Lines 242 to 244 in 25ea953
return { | |
TSIntersectionType(node): void { | |
if (checkIntersections === true) { |
typescript-eslint/packages/eslint-plugin/src/rules/typedef.ts
Lines 180 to 183 in 1c1b572
'FunctionDeclaration, FunctionExpression'( | |
node: TSESTree.FunctionDeclaration | TSESTree.FunctionExpression, | |
): void { | |
if (options[OptionKeys.Parameter]) { |
typescript-eslint/packages/eslint-plugin/src/rules/explicit-function-return-type.ts
Lines 71 to 76 in 1c1b572
return { | |
'ArrowFunctionExpression, FunctionExpression'( | |
node: TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression, | |
): void { | |
if ( | |
options.allowConciseArrowFunctionExpressionsStartingWithVoid && |
But, IMHO this could be improved by either moving the conditional up then wrapping the return {
or, in some cases do ...(optionX && { node ... })
, and so avoiding looking for nodes which doesn't corresponds unnecessarily. Does it makes sense for you? If so, I can send a PR refactor
for that.
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.
happy to accept a PR if you want!
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 fixing this!
Fixes #3894.