1010 * - `Object`:
1111 * - `escape`: allow the "other" quote mark to be used, but only to avoid having to escape
1212 * - `mark`: the same effect as the non-object values
13+ * - `ignoreJSX`: ignore JSX nodes
1314 *
1415 * JSHint: [`quotmark`](http://jshint.com/docs/options/#quotmark)
1516 *
2829 * var x = "x";
2930 * var y = '"x"';
3031 * ```
32+ *
3133 * ##### Invalid example for mode `{ "mark": "\"", "escape": true }`
3234 *
3335 * ```js
3436 * var x = "x";
3537 * var y = 'x';
3638 * ```
3739 *
40+ * ##### Valid example for mode `{ "mark": "'", "escape": true, "ignoreJSX": true }`
41+ *
42+ * ```js
43+ * <div className="flex-card__header">{this.props.children}</div>;
44+ * ```
45+ *
3846 * ##### Valid example for mode `"\""` or mode `true`
3947 *
4048 * ```js
@@ -62,13 +70,19 @@ module.exports.prototype = {
6270
6371 configure : function ( quoteMark ) {
6472 this . _allowEscape = false ;
73+ this . _ignoreJSX = false ;
6574
6675 if ( typeof quoteMark === 'object' ) {
6776 assert (
6877 typeof quoteMark . escape === 'boolean' && quoteMark . mark !== undefined ,
6978 this . getOptionName ( ) + ' option requires the "escape" and "mark" property to be defined'
7079 ) ;
7180 this . _allowEscape = quoteMark . escape ;
81+
82+ if ( quoteMark . ignoreJSX ) {
83+ this . _ignoreJSX = quoteMark . ignoreJSX ;
84+ }
85+
7286 quoteMark = quoteMark . mark ;
7387 }
7488
@@ -77,6 +91,11 @@ module.exports.prototype = {
7791 this . getOptionName ( ) + ' option requires \'"\', "\'", or boolean true'
7892 ) ;
7993
94+ assert (
95+ quoteMark === '"' || quoteMark === '\'' || quoteMark === true ,
96+ this . getOptionName ( ) + ' option requires \'"\', "\'", or boolean true'
97+ ) ;
98+
8099 this . _quoteMark = quoteMark ;
81100 } ,
82101
@@ -87,12 +106,20 @@ module.exports.prototype = {
87106 check : function ( file , errors ) {
88107 var quoteMark = this . _quoteMark ;
89108 var allowEscape = this . _allowEscape ;
109+ var ignoreJSX = this . _ignoreJSX ;
110+
90111 var opposite = {
91112 '"' : '\'' ,
92113 '\'' : '"'
93114 } ;
94-
95115 file . iterateTokensByType ( 'String' , function ( token ) {
116+ if (
117+ ignoreJSX &&
118+ file . getNodeByRange ( token . range [ 0 ] ) . parentNode . type === 'JSXAttribute'
119+ ) {
120+ return ;
121+ }
122+
96123 var str = token . value ;
97124 var mark = str [ 0 ] ;
98125 var stripped = str . substring ( 1 , str . length - 1 ) ;
0 commit comments