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

fix(eslint-plugin): [consistent-type-definitions] correct fix for export default #3899

merged 1 commit into from Sep 20, 2021


Copy link

Fixes #3894.

Copy link

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 As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

Copy link

codecov bot commented Sep 17, 2021

Codecov Report

Merging #3899 (1e7e6d8) into master (b1df817) will increase coverage by 0.81%.
The diff coverage is 66.66%.

@@            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     
Flag Coverage Δ
unittest 93.52% <66.66%> (+0.81%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...nt-plugin/src/rules/consistent-type-definitions.ts 89.18% <66.66%> (-1.99%) ⬇️
... and 171 more

@@ -122,6 +122,19 @@ export default util.createRule({

if (
Copy link
Contributor Author

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:

return {
node: TSESTree.TSTypeAliasDeclaration,
): void {
if (option === 'interface') {

Other cases I found (click to expand)

TSMethodSignature(methodNode): void {
if (mode === 'method') {

"AssignmentExpression[operator='+=']"(node): void {
if (checkCompoundAssignments) {

return {
TSIntersectionType(node): void {
if (checkIntersections === true) {

'FunctionDeclaration, FunctionExpression'(
node: TSESTree.FunctionDeclaration | TSESTree.FunctionExpression,
): void {
if (options[OptionKeys.Parameter]) {

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.

Copy link

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!

@bradzacher bradzacher added the bug Something isn't working label Sep 20, 2021
Copy link

@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.

thanks for fixing this!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
bug Something isn't working
None yet

Successfully merging this pull request may close these issues.

[consistent-type-definitions] Add option to use interface with methods
2 participants