Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

(quotemark) add option to enforce double quotes in JSX attributes and single quotes elsewhere #673

Closed
prabirshrestha opened this issue Sep 21, 2015 · 11 comments

Comments

@prabirshrestha
Copy link

No description provided.

@adidahiya
Copy link
Contributor

is this a feature request?

just to be clear, you want to enforce double quotes in HTML attributes within JSX?

<MyComponent someAttr="valid" another='invalid' />

@prabirshrestha
Copy link
Author

This is a feature request.

const value = 'some text';
<input placeholder="placeholder" value={value} />

I want to enforce double quotes only in attributes within JSX. If it isn't an attribute should use single quote.

@adidahiya adidahiya changed the title allows only single quotes in *.ts and *.tsx but force double quotes in *.tsx attributes. (quotemark) add option to enforce double quotes in JSX attributes and single quotes elsewhere Sep 22, 2015
@cajoy
Copy link

cajoy commented Oct 13, 2015

This rule is really needed for TSX files as tslinter complains about doublequotes in TSX files.

@nikolaymatrosov
Copy link

+1

1 similar comment
@dupski
Copy link
Contributor

dupski commented Oct 31, 2015

+1

@jkillian
Copy link
Contributor

jkillian commented Nov 1, 2015

Seems like a solid rule idea that is popular. I'll prioritize this!

@jkillian
Copy link
Contributor

jkillian commented Nov 2, 2015

Just to double-check, this is just a stylistic issue right? Using single quotes for JSX attributes shouldn't cause any functional problems as far as I know:

<div someProp='someValue' />

@dupski
Copy link
Contributor

dupski commented Nov 2, 2015

Hi Jason

Yes you can use either single or double quotes in JSX as far as I can tell,
so yes this is mainly a stylistic issue.

If possible I think it might be nice to configure JSX quoting separately
from TS, maybe a quotemark-jsx setting? There are instances where you might
want to interchangeably use the single or double quoting styles, e.g.
because it is not possible to escape quotes in JSX.

Cheers!
On 2 Nov 2015 9:05 pm, "Jason Killian" notifications@github.com wrote:

Just to double-check, this is just a stylistic issue right? Using single
quotes for JSX attributes shouldn't cause any functional problems as far as
I know:


Reply to this email directly or view it on GitHub
#673 (comment).

@jkillian
Copy link
Contributor

jkillian commented Nov 6, 2015

I'm thinking we could add two more options to the quotemark rule: jsx-single and jsx-double. These rules would enforce either single or double quotes for JSX attributes. If you have the avoid-escape option set, they would allow you to use the other form of quotemark when necessary. Does this sound like it would meet everyone's use case?

@dupski
Copy link
Contributor

dupski commented Nov 6, 2015

Sounds good to me :)
On 6 Nov 2015 6:32 pm, "Jason Killian" notifications@github.com wrote:

I'm thinking we could add two more options to the quotemark rule:
jsx-single and jsx-double. These rules would enforce either single or
double quotes for JSX attributes. If you have the avoid-escape option
set, they would allow you to use the other form of quotemark when
necessary. Does this sound like it would meet everyone's use case?


Reply to this email directly or view it on GitHub
#673 (comment).

@adidahiya adidahiya added this to the TSLint 3.x milestone Jan 13, 2016
@adidahiya adidahiya modified the milestones: TSLint 3.3, TSLint 3.x Jan 15, 2016
@adidahiya
Copy link
Contributor

this feature is available now in tslint@next (v3.2.2-dev.1)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants