-
-
Notifications
You must be signed in to change notification settings - Fork 504
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
💅 possible difference in scope between biome useliteralkeys and eslint dot-notation rules #3085
Comments
I believe this is intentional, but it does not seem to be properly documented. I question this behavior because our formatter is able to remove unnecessary quotes around properties. So, personally, I am in favor of reducing the scope of |
It's not very clear what reducing scope means. If I understand correctly, the code action should only remove the brackets and keep the quotes, correct? E.g. // original
const a = {
["f"]: b
} New code action const a = {
- f: b
+ 'f': b
} |
The rule could only apply to property access: - a.b["c"];
+ a.b.c; Your example could be untouched. |
This is actually what tipped me off that something might be funky in the first place. I had set
The formatter preserved the quotes around the properties, but the linter threw errors. The only way to fix was to unquote the Reducing the scope of |
Yeah sounds good. We could consider this a fix, since it oversteps the formatter boundaries |
Environment information
Rule name
useLiteralKeys
Playground link
https://biomejs.dev/playground/?lineWidth=100&indentStyle=space"eProperties=preserve&indentWidth=4&code=YwBvAG4AcwB0ACAAdABlAHMAdAAgAD0AIAB7AAoAIAAgACAAIAAiAHQAZQBzAHQAIgA6ACAAMQAsAAoAIAAgACAAIAAiAHQAZQBzAHQAIAAyACIAOgAgADIALAAKACAAIAAgACAAIgB0AGUAcwB0ADMAIgA6ACAAMQAsAAoAfQA7AAoACgB0AGUAcwB0AFsAIgB0AGUAcwB0ACIAXQAgAD0AIAAyAA%3D%3D
Expected result
Hey folks,
There seems to be a possible difference between the scope of biome's
useLiteralKeys
linter rule and the scope of eslint'sdot-notation
linter rule. In particular, eslint seems to only apply the rule when the property of an object is being accessed, but biome seems to apply the rule both when the property is being accessed AND when the properties are being defined/created within a new object. For instance:In this example, eslint won't throw an error, but biome will and suggest to simplify by not using a string literal. You can view results in ESLint here. If that's the intended nature, all good, though would prefer parity with eslint as much as possible to help teams migrating; if that's not the intended nature, then there is probably a bug.
Thanks for your great work on this project, I love using it!
Code of Conduct
The text was updated successfully, but these errors were encountered: