Skip to content

Commit 07f6ba9

Browse files
committed
Merge pull request #183 from CalebMorris/hotfix/literalsFix
Added type limits to jsx-no-literals.
2 parents 5666ed7 + 0bdf5b6 commit 07f6ba9

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/rules/jsx-no-literals.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ module.exports = function(context) {
2424
if (
2525
!/^[\s]+$/.test(node.value) &&
2626
node.parent &&
27-
node.parent.type !== 'JSXExpressionContainer'
27+
node.parent.type !== 'JSXExpressionContainer' &&
28+
node.parent.type !== 'JSXAttribute' &&
29+
node.parent.type.indexOf('JSX') !== -1
2830
) {
2931
reportLiteralNode(node);
3032
}

tests/lib/rules/jsx-no-literals.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,20 @@ ruleTester.run('jsx-no-literals', rule, {
9494
].join('\n'),
9595
args: [1],
9696
parser: 'babel-eslint'
97+
}, {
98+
code: [
99+
'var foo = require(\'foo\');'
100+
].join('\n'),
101+
args: [1],
102+
parser: 'babel-eslint'
103+
}, {
104+
code: [
105+
'<Foo bar=\'test\'>',
106+
' {\'blarg\'}',
107+
'</Foo>'
108+
].join('\n'),
109+
args: [1],
110+
parser: 'babel-eslint'
97111
}
98112
],
99113

0 commit comments

Comments
 (0)