palantir / tslint-react

:orange_book: Lint rules related to React & JSX for TSLint.
Apache License 2.0
749 stars 76 forks source link

Allow/disallow curly braces for string literal attributes (enforce double/single quotes only) #246

Closed spradlin-dev closed 5 years ago

spradlin-dev commented 5 years ago

existing quotes rule jsx-double only makes sure you don't type attr='value', but doesn't prevent attr={'value'}.

I want enable my team to catch inconsistent quotes in JSX and only use curly braces for string values when they have to be interpreted or concatenated, such as using string templates.

No error

<Component name="string"/>
<Component name={'string-' + id}/>
<Component name={`string-${id}`}/>

Error

<Component name={'string'}/>
<Component name={"string"}/>
adidahiya commented 5 years ago

Sounds like a good idea, but I would suggest making this an ESLint rule instead. See https://github.com/palantir/tslint-react/issues/210