Skip to content

fix: allow console.debug() in no-debug #349

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

Merged
merged 5 commits into from
Apr 21, 2021
Merged

Conversation

gndelia
Copy link
Collaborator

@gndelia gndelia commented Apr 20, 2021

closes #327

I intentionally left out the following scenario

const { debug } = console
debug()

because it goes against the first invalid tests that against any debug(), it raises a flag.

@gndelia gndelia added the bug Something isn't working label Apr 20, 2021
@gndelia gndelia requested a review from Belco90 April 20, 2021 15:37
@gndelia gndelia self-assigned this Apr 20, 2021
@Belco90
Copy link
Member

Belco90 commented Apr 20, 2021

I intentionally left out the following scenario

const { debug } = console
debug()

because it goes against the first invalid tests that against any debug(), it raises a flag.

I'm not sure if I understand the reason. The first invalid case is way too simple but from the Aggressive Reporting point of view is invalid. However, the case you mentioned shouldn't be reported ideally. Am I missing something else?

@gndelia
Copy link
Collaborator Author

gndelia commented Apr 20, 2021

I intentionally left out the following scenario

const { debug } = console
debug()

because it goes against the first invalid tests that against any debug(), it raises a flag.

I'm not sure if I understand the reason. The first invalid case is way too simple but from the Aggressive Reporting point of view is invalid. However, the case you mentioned shouldn't be reported ideally. Am I missing something else?

I don't know how I can differentiate

const { debug } = console
debug()

from simply (which is reported from the aggressive reporting point of view)

debug()

as this 👆 is included in the above one

@Belco90
Copy link
Member

Belco90 commented Apr 20, 2021

@gndelia ok, I see what you mean now.

The difference is basically where they come from: one has been declared destructuring from console, the other one hasn't been declared (which is not a real-ish scenario so it should be improved to import it from some module).

Since console is a JS built-in module, we don't need to be that picky checking if the debug method has been declared from a module/object related to Testing Library or not. Just checking that the init.name of the VariableDeclarator (if any) is "console" should be enough to avoid reporting in that case.

Could you include that case in the rule then, please?

@gndelia gndelia requested a review from Belco90 April 20, 2021 22:17
@gndelia gndelia requested a review from Belco90 April 21, 2021 18:28
Copy link
Member

@Belco90 Belco90 left a comment

Choose a reason for hiding this comment

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

Nice, almost there! Just a couple of small tweaks and this is good to go 🚀

Copy link
Member

@Belco90 Belco90 left a comment

Choose a reason for hiding this comment

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

Awesome 👏

@Belco90 Belco90 merged commit 43a14a2 into main Apr 21, 2021
@Belco90 Belco90 deleted the no-debug/bug/allow-consoledebug branch April 21, 2021 19:47
@github-actions
Copy link

🎉 This PR is included in version 4.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

no-debug also affects console.debug()
3 participants