Skip to content

Rule proposal: disallow curlies around string literals #529

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

Closed
lencioni opened this issue Apr 5, 2016 · 6 comments
Closed

Rule proposal: disallow curlies around string literals #529

lencioni opened this issue Apr 5, 2016 · 6 comments

Comments

@lencioni
Copy link
Collaborator

lencioni commented Apr 5, 2016

Bad:

function MyComponent() {
  return (
    <div className={'MyComponent'}>
      Hi mom
    </div>
  )
}

Good:

function MyComponent() {
  return (
    <div className='MyComponent'>
      Hi mom
    </div>
  )
}
@yannickcr
Copy link
Member

So, the opposite of jsx-no-literals ? If yes we could make a jsx-literals rule with always/never options.

@lencioni
Copy link
Collaborator Author

lencioni commented Apr 6, 2016

Yes, I think so. For the never case, there are probably some exceptions when used outside of props (e.g. {' '} is often used).

@ljharb
Copy link
Member

ljharb commented Apr 6, 2016

I'd think this is jsx-string-literals-in-props or something - I don't think we'd want this rule to legislate text used outside of props.

@lencioni
Copy link
Collaborator Author

lencioni commented Apr 6, 2016

Yeah, that's fair. I could see folks wanting different things in props vs outside props, so having separate rules seems like a decent way to achieve that.

@yannickcr
Copy link
Member

Mmm, apparently the current jsx-no-literals rule only apply outside props.

@ljharb
Copy link
Member

ljharb commented Apr 9, 2019

Seems closed by #1349.

@ljharb ljharb closed this as completed Apr 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants