Skip to content

Commit 554eceb

Browse files
committed
Fix no-comment-textnodes incorrectly catching urls (fixes jsx-eslint#664)
1 parent dea9e18 commit 554eceb

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/rules/no-comment-textnodes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = function(context) {
1919

2020
return {
2121
Literal: function(node) {
22-
if (/\s*\/(\/|\*)/.test(node.value)) {
22+
if (/^\s*\/(\/|\*)/m.test(node.value)) {
2323
// inside component, e.g. <div>literal</div>
2424
if (node.parent.type !== 'JSXAttribute' &&
2525
node.parent.type !== 'JSXExpressionContainer' &&

tests/lib/rules/no-comment-textnodes.js

+9
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,15 @@ ruleTester.run('jsx-needs-i18n', rule, {
109109
args: [1],
110110
parser: 'babel-eslint'
111111
},
112+
{
113+
code: [
114+
'<strong>',
115+
' &nbsp;https://www.example.com/attachment/download/1',
116+
'</strong>'
117+
].join('\n'),
118+
args: [1],
119+
parser: 'babel-eslint'
120+
},
112121

113122
// inside element declarations
114123
{

0 commit comments

Comments
 (0)