Skip to content

Latest commit

 

History

History
executable file
·
52 lines (35 loc) · 1.41 KB

jsx-quotes.md

File metadata and controls

executable file
·
52 lines (35 loc) · 1.41 KB

Enforce quote style for JSX attributes (jsx-quotes)

Enforces coding style that JSX attributes are delimited with single or double quotes.

It takes an option as the second parameter which can be "double" or "single" for double-quotes or single-quotes respectively. There is no default.

var HelloJohn = <Hello name="John" />;
var HelloJohn = <Hello name='John' />;

The third parameter enables an exception to the rule to allow you to use alternative quotes to get around to impossibility to use escaping in JSX attributes. This option can have the value "avoid-escape" and is off by default.

[2, "single", "avoid-escape"]

Rule Details

This rule will throw warnings when the wrong type of quote is used.

The following patterns are considered warnings:

// When [1, "double"]
var HelloJohn = <Hello name='John' />;

// When [1, "single"]
var HelloJohn = <Hello name="John" />;

// When [1, "double", "avoid-escape"]
var HelloJohn = <Hello name='John' />;

// When [1, "single", "avoid-escape"]
var HelloJohn = <Hello name="John" />;

The follow patterns are not considered warnings:

// When [1, "double"]
var HelloJohn = <Hello name="John" />;

// When [1, "single"]
var HelloJohn = <Hello name='John' />;

// When [1, "double", "avoid-escape"]
var HelloJohn = <Hello name='John "FooBar" Smith' />;

// When [1, "single", "avoid-escape"]
var HelloJohn = <Hello name="John 'FooBar' Smith" />;