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
merged 1 commit into from Sep 20, 2021

Conversation

rafaelss95
Copy link
Contributor

Fixes #3894.

@typescript-eslint
Copy link
Contributor

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
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%) ⬇️
...perimental-utils/src/ts-eslint-scope/Referencer.ts
packages/eslint-plugin-tslint/src/rules/config.ts
packages/scope-manager/src/referencer/Visitor.ts
packages/eslint-plugin-tslint/src/custom-linter.ts
packages/typescript-estree/src/version-check.ts
packages/scope-manager/src/lib/es2019.object.ts
...ages/scope-manager/src/lib/es2016.array.include.ts
packages/scope-manager/src/scope/TSModuleScope.ts
...xperimental-utils/src/ts-eslint-scope/Reference.ts
... 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 {
"TSTypeAliasDeclaration[typeAnnotation.type='TSTypeLiteral']"(
node: TSESTree.TSTypeAliasDeclaration,
): void {
if (option === 'interface') {

Other cases I found (click to expand)

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

"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
Member

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

thanks for fixing this!

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

Successfully merging this pull request may close these issues.

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