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

Commit 703cad3

Browse files
committed
validateQuoteMarks: do not throw on es7 decorators
Fixes #2141
1 parent 74b11a4 commit 703cad3

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

lib/rules/validate-quote-marks.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,14 @@ module.exports.prototype = {
113113
'\'': '"'
114114
};
115115
file.iterateTokensByType('String', function(token) {
116-
if (
117-
ignoreJSX &&
118-
file.getNodeByRange(token.range[0]).parentNode.type === 'JSXAttribute'
119-
) {
120-
return;
116+
var node;
117+
118+
if (ignoreJSX) {
119+
node = file.getNodeByRange(token.range[0]).parentNode;
120+
121+
if (node && node.type === 'JSXAttribute') {
122+
return;
123+
}
121124
}
122125

123126
var str = token.value;

test/specs/rules/validate-quote-marks.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ describe('rules/validate-quote-marks', function() {
4444
var str = '<div className="flex-card__header">{this.props.children}</div>;';
4545
expect(checker.checkString(str)).to.have.errors.from('validateQuoteMarks');
4646
});
47+
48+
it('should not throw for es7 decorators', function() {
49+
checker.configure({
50+
validateQuoteMarks: { mark: '"', ignoreJSX: true, escape: true },
51+
esnext: true
52+
});
53+
var str = '@foo (s => "1") export default class Bar {}';
54+
expect(checker.checkString(str)).to.have.no.errors();
55+
});
4756
});
4857

4958
describe('option value \' ', function() {

0 commit comments

Comments
 (0)