Skip to content

Commit

Permalink
Fix no-comment-textnodes incorrectly catching urls (fixes #664)
Browse files Browse the repository at this point in the history
  • Loading branch information
petersendidit authored and yannickcr committed Jul 8, 2016
1 parent f235b84 commit f998882
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/no-comment-textnodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = function(context) {

return {
Literal: function(node) {
if (/\s*\/(\/|\*)/.test(node.value)) {
if (/^\s*\/(\/|\*)/m.test(node.value)) {
// inside component, e.g. <div>literal</div>
if (node.parent.type !== 'JSXAttribute' &&
node.parent.type !== 'JSXExpressionContainer' &&
Expand Down
9 changes: 9 additions & 0 deletions tests/lib/rules/no-comment-textnodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ ruleTester.run('jsx-needs-i18n', rule, {
args: [1],
parser: 'babel-eslint'
},
{
code: [
'<strong>',
' &nbsp;https://www.example.com/attachment/download/1',
'</strong>'
].join('\n'),
args: [1],
parser: 'babel-eslint'
},

// inside element declarations
{
Expand Down

0 comments on commit f998882

Please sign in to comment.