Repository: yannickcr/eslint-plugin-react (js)

Issue:
`no-comment-textnodes` false positive on URL
I have JSX like the following:
```js
<strong>
  &nbsp;https://www.example.com/attachment/download/1
</strong>
```

Since the line doesn't start with `//` or `/*`, there shouldn't be any way this is identified as an accidental leaked comment.

Pull request description:
Fix no-comment-textnodes incorrectly catching urls (fixes #664)
Fixes #664.

Patch:
diff --git a/lib/rules/jsx-filename-extension.js b/lib/rules/jsx-filename-extension.js
index 6fa7e1dc..2fde88d4 100644
--- a/lib/rules/jsx-filename-extension.js
+++ b/lib/rules/jsx-filename-extension.js
@@ -32,9 +32,12 @@ module.exports = function(context) {
   return {
 
     JSXElement: function(node) {
-      var allowedExtensions = getExtensionsConfig();
       var filename = context.getFilename();
+      if (filename === '<text>') {
+        return;
+      }
 
+      var allowedExtensions = getExtensionsConfig();
       var isAllowedExtension = allowedExtensions.some(function (extension) {
         return filename.slice(-extension.length) === extension;
       });
diff --git a/lib/rules/no-comment-textnodes.js b/lib/rules/no-comment-textnodes.js
index 7a3bfc58..7c3cf71d 100644
--- a/lib/rules/no-comment-textnodes.js
+++ b/lib/rules/no-comment-textnodes.js
@@ -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' &&


Test patch:
diff --git a/tests/lib/rules/jsx-filename-extension.js b/tests/lib/rules/jsx-filename-extension.js
index f40e3d5c..578682dc 100644
--- a/tests/lib/rules/jsx-filename-extension.js
+++ b/tests/lib/rules/jsx-filename-extension.js
@@ -33,6 +33,11 @@ var ruleTester = new RuleTester();
 ruleTester.run('jsx-filename-extension', rule, {
 
   valid: [
+    {
+      filename: '<text>',
+      code: withJSX,
+      parserOptions: parserOptions
+    },
     {
       filename: 'MyComponent.jsx',
       code: withJSX,
diff --git a/tests/lib/rules/no-comment-textnodes.js b/tests/lib/rules/no-comment-textnodes.js
index fcfd78d6..2cb700fb 100644
--- a/tests/lib/rules/no-comment-textnodes.js
+++ b/tests/lib/rules/no-comment-textnodes.js
@@ -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
     {