Repository: ember-template-lint/ember-template-lint
Pull request #381 (2018-04-02 15:08:25)

Fix link-rel-noopener not working for "noreferrer noopener"
Fixes https://github.com/ember-template-lint/ember-template-lint/issues/380.


Patch:
diff --git a/lib/rules/lint-link-rel-noopener.js b/lib/rules/lint-link-rel-noopener.js
index 8234f10f..19cbdbda 100644
--- a/lib/rules/lint-link-rel-noopener.js
+++ b/lib/rules/lint-link-rel-noopener.js
@@ -26,8 +26,8 @@ const DEFAULT_CONFIG = {
 };
 
 const STRICT_CONFIG = {
-  regexp: /no(opener.*referrer)/,
-  message: 'links with target="_blank" must have rel="noopener noreferrer"'
+  regexp: /(.*\s)?noopener\s(.*\s)?noreferrer(\s.*)?|(.*\s)?noreferrer\s(.*\s)?noopener(\s.*)?/,
+  message: 'links with target="_blank" must have rel="noopener noreferrer" or rel="noreferrer noopener"'
 };
 
 module.exports = class LinkRelNoopener extends Rule {


Test patch:
diff --git a/test/unit/rules/lint-link-rel-noopener-test.js b/test/unit/rules/lint-link-rel-noopener-test.js
index be8b4382..aeb9e630 100644
--- a/test/unit/rules/lint-link-rel-noopener-test.js
+++ b/test/unit/rules/lint-link-rel-noopener-test.js
@@ -12,10 +12,40 @@ generateRuleTests({
     '<a href="/some/where" target="_self"></a>',
     '<a href="/some/where" target="_blank" rel="noopener"></a>',
     '<a href="/some/where" target="_blank" rel="noopener noreferrer"></a>',
+    '<a href="/some/where" target="_blank" rel="noreferrer noopener"></a>',
+    '<a href="/some/where" target="_blank" rel="nofollow noreferrer noopener"></a>',
     '<a href="/some/where" target="_blank" rel="noreferrer"></a>',
     {
       config: 'strict',
       template: '<a href="/some/where/ingrid" target="_blank" rel="noopener noreferrer"></a>,'
+    },
+    {
+      config: 'strict',
+      template: '<a href="/some/where/ingrid" target="_blank" rel="nofollow noopener noreferrer"></a>,'
+    },
+    {
+      config: 'strict',
+      template: '<a href="/some/where/ingrid" target="_blank" rel="noopener nofollow noreferrer"></a>,'
+    },
+    {
+      config: 'strict',
+      template: '<a href="/some/where/ingrid" target="_blank" rel="noopener noreferrer nofollow"></a>,'
+    },
+    {
+      config: 'strict',
+      template: '<a href="/some/where/ingrid" target="_blank" rel="noreferrer noopener"></a>,'
+    },
+    {
+      config: 'strict',
+      template: '<a href="/some/where/ingrid" target="_blank" rel="nofollow noreferrer noopener"></a>,'
+    },
+    {
+      config: 'strict',
+      template: '<a href="/some/where/ingrid" target="_blank" rel="noreferrer nofollow noopener"></a>,'
+    },
+    {
+      config: 'strict',
+      template: '<a href="/some/where/ingrid" target="_blank" rel="noreferrer noopener nofollow"></a>,'
     }
   ],
 
@@ -47,7 +77,7 @@ generateRuleTests({
       template: '<a href="/some/where" target="_blank" rel="noopener"></a>',
 
       result: {
-        message: 'links with target="_blank" must have rel="noopener noreferrer"',
+        message: 'links with target="_blank" must have rel="noopener noreferrer" or rel="noreferrer noopener"',
         moduleId: 'layout.hbs',
         source: '<a href="/some/where" target="_blank" rel="noopener"></a>',
         line: 1,
@@ -59,7 +89,7 @@ generateRuleTests({
       template: '<a href="/some/where" target="_blank" rel="noreferrer"></a>',
 
       result: {
-        message: 'links with target="_blank" must have rel="noopener noreferrer"',
+        message: 'links with target="_blank" must have rel="noopener noreferrer" or rel="noreferrer noopener"',
         moduleId: 'layout.hbs',
         source: '<a href="/some/where" target="_blank" rel="noreferrer"></a>',
         line: 1,
@@ -71,7 +101,7 @@ generateRuleTests({
       template: '<a href="/some/where" target="_blank" rel="nofollow"></a>',
 
       result: {
-        message: 'links with target="_blank" must have rel="noopener noreferrer"',
+        message: 'links with target="_blank" must have rel="noopener noreferrer" or rel="noreferrer noopener"',
         moduleId: 'layout.hbs',
         source: '<a href="/some/where" target="_blank" rel="nofollow"></a>',
         line: 1,