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

Commit

Permalink
validateQuoteMarks: do not throw on es7 decorators
Browse files Browse the repository at this point in the history
Fixes #2141
  • Loading branch information
markelog committed Feb 27, 2016
1 parent 74b11a4 commit 703cad3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/rules/validate-quote-marks.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,14 @@ module.exports.prototype = {
'\'': '"'
};
file.iterateTokensByType('String', function(token) {
if (
ignoreJSX &&
file.getNodeByRange(token.range[0]).parentNode.type === 'JSXAttribute'
) {
return;
var node;

if (ignoreJSX) {
node = file.getNodeByRange(token.range[0]).parentNode;

if (node && node.type === 'JSXAttribute') {
return;
}
}

var str = token.value;
Expand Down
9 changes: 9 additions & 0 deletions test/specs/rules/validate-quote-marks.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ describe('rules/validate-quote-marks', function() {
var str = '<div className="flex-card__header">{this.props.children}</div>;';
expect(checker.checkString(str)).to.have.errors.from('validateQuoteMarks');
});

it('should not throw for es7 decorators', function() {
checker.configure({
validateQuoteMarks: { mark: '"', ignoreJSX: true, escape: true },
esnext: true
});
var str = '@foo (s => "1") export default class Bar {}';
expect(checker.checkString(str)).to.have.no.errors();
});
});

describe('option value \' ', function() {
Expand Down

0 comments on commit 703cad3

Please sign in to comment.