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 autofix for variable name matching property name #4662

Closed
Tracked by #4574
guoyunhe opened this issue Mar 26, 2020 · 4 comments
Closed
Tracked by #4574

Fix autofix for variable name matching property name #4662

guoyunhe opened this issue Mar 26, 2020 · 4 comments
Labels
status: ready to implement is ready to be worked on by someone syntax: css-in-js relates to JS objects & template literals

Comments

@guoyunhe
Copy link

Clearly describe the bug

In React JSX/TSX files, the stylelint plugin try to auto fix variable casing in the style property. But this will cause the code not working.

What code is needed to reproduce this issue?

e.g.

// Container.jsx
import React from 'react';

export default function Container({maxWidth, children}) {
  return <div style={{ maxWidth: maxWidth + 10 }}>{children}</div>
}

What vscode-stylelint configuration is needed to reproduce the bug?

"editor.codeActionsOnSave": {
  "source.fixAll.stylelint": true
}

Is this issue related to autofix? (editor.codeActionsOnSave)

Yes

Which version of vscode-stylelint are you using?

0.84.0

Which version of stylelint are you using?

13.2.0

Does your issue relate to non-standard syntax (e.g. SCSS, nesting, etc.)?

It is related to JSX

What did you expect to happen?

The code is valid and should not be touched.

What actually happened (e.g. what warnings or errors you are getting)?

The code is changed, maxWidth --> maxwidth, and thus not working anymore.

@guoyunhe guoyunhe changed the title React JSX style wrong auto fix React JSX variable name changed after auto fix Mar 26, 2020
@jeddy3 jeddy3 transferred this issue from stylelint/vscode-stylelint Mar 26, 2020
@jeddy3 jeddy3 changed the title React JSX variable name changed after auto fix Fix autofix for variable name matching property name Mar 26, 2020
@jeddy3 jeddy3 added status: ready to implement is ready to be worked on by someone syntax: css-in-js relates to JS objects & template literals type: bug labels Mar 26, 2020
@jeddy3 jeddy3 mentioned this issue Mar 26, 2020
23 tasks
@jeddy3
Copy link
Member

jeddy3 commented Mar 26, 2020

@guoyunhe Thanks for the report and for using the template.

I've transferred your issue because the problem is in stylelint itself, rather than the VS Code extension.

The underlying problem is likely with the parser stylelint uses to support CSS-in-JS. I've added this issue to #4574, which is a growing list of the problems with the syntax that we need help to fix.

Please consider contributing to the parser if you have time.

@rbong
Copy link

rbong commented Jun 5, 2021

The parser is not the issue. The parser interprets the expression appropriately and does not turn it into lowercase when stringifying the parsed expression. The issue is with the value-keyword-case rule, which transforms parts of expressions even if they are not string literals.

@rbong
Copy link

rbong commented Jun 5, 2021

This appears to come down to the exact same issue described here: #5185 (comment)

This is probably a duplicate of that issue, I don't believe it's related to the "variable name matching property name" as indicated in the title. Using another property name results in the same issue:

return <div style={{ minWidth: maxWidth + 10 }}>{children}</div>

@jeddy3
Copy link
Member

jeddy3 commented Jan 18, 2022

Closing as the syntax option was removed for the 14.0.0 release. (See the migration guide.)

We'll also be deprecating our forked CSS-in-JS package, in favour of leaner custom syntaxes.

Please consider writing a custom syntax specific to the CSS-in-JS library in this issue and fixing the bug there.

@jeddy3 jeddy3 closed this as completed Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready to implement is ready to be worked on by someone syntax: css-in-js relates to JS objects & template literals
Development

No branches or pull requests

3 participants