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

💅 useNamingConvention: The rule should ignore variables that are destructured out of objects #2332

Closed
1 task done
vladkrasn opened this issue Apr 7, 2024 · 3 comments · Fixed by #2386
Closed
1 task done
Assignees
Labels
A-Linter Area: linter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug S-Help-wanted Status: you're familiar with the code base and want to help the project

Comments

@vladkrasn
Copy link

vladkrasn commented Apr 7, 2024

Rule name

useNamingConvention

Playground link

https://biomejs.dev/playground/?lintRules=all&code=YwBvAG4AcwB0ACAAYQAgAD0AIAB7AAoAIAAgAFcAcgBvAG4AZwBDAEEAUwBFAFMAVABSAEkAQwBUADoAIAAxACwACgAgACAAQQBMAFMATwBXAFIATwBOAEcAOgAgADEACgB9AAoACgBmAHUAbgBjAHQAaQBvAG4AIABmAHUAbgBjACAAKABhACkAIAB7AAoAYwBvAG4AcwB0ACAAewAgAFcAcgBvAG4AZwBDAEEAUwBFAFMAVABSAEkAQwBUACwAIABBAEwAUwBPAFcAUgBPAE4ARwAgAH0AIAA9ACAAYQAKAGMAbwBuAHMAdAAgAG8AbgBlACAAPQAgAEEATABTAE8AVwBSAE8ATgBHACAAKwAgADEACgBvAG4AZQAgACsAIABXAHIAbwBuAGcAQwBBAFMARQBTAFQAUgBJAEMAVAAgACsAIABBAEwAUwBPAFcAUgBPAE4ARwAKAH0ACgA%3D

Expected result

Variables that are produced by destructured objects are not necessarily declared by a Biome user, they may come from a third party library. Maybe Biome should ignore them?

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@vladkrasn vladkrasn changed the title 💅 When strict mode is enabled, the rule incorrectly catches destructured objects that don't abide to it 💅 useNamingConvention: When strict mode is enabled, the rule incorrectly catches destructured objects that don't abide to it Apr 7, 2024
@vladkrasn vladkrasn changed the title 💅 useNamingConvention: When strict mode is enabled, the rule incorrectly catches destructured objects that don't abide to it 💅 useNamingConvention: The rule should ignore variables that are destructured out of objects Apr 7, 2024
@Sec-ant Sec-ant added S-Help-wanted Status: you're familiar with the code base and want to help the project A-Linter Area: linter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug labels Apr 7, 2024
@Sec-ant
Copy link
Member

Sec-ant commented Apr 7, 2024

Instead of ignoring them, I think the expected behavior of this rule in this case should be suggesting renaming those destructured variables to comply with the naming convention.

@Conaclos Conaclos self-assigned this Apr 9, 2024
@Conaclos
Copy link
Member

Conaclos commented Apr 9, 2024

I am hesitating between completely ignoring this kind of names or applying the suggestion of @Sec-ant.
The advantage of ignoring these names is to keep a low cognitive load by using the same name.

Note: we already ignore shorthand imports such as import { I_mport } from "mod".
We should certainly choose an identical strategy for this kind of code.

@ematipico
Copy link
Member

Ther's also the fact that there's a pattern to remove properties from an object, like this:

const { SOMETHING, FOO, ...rest } = bar;

doSomething(rest);

This means that the user would be forced to write the code like this:

const { SOMETHING: something, FOO: foo, ...rest } = bar;

doSomething(rest);

I think this is very user-hostile and doesn't provide good value to the rule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Linter Area: linter L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug S-Help-wanted Status: you're familiar with the code base and want to help the project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants