From 6ff72006c831c84a9a286776b0dbbd12f132174c Mon Sep 17 00:00:00 2001 From: Prateek Bhatnagar Date: Mon, 15 Jun 2020 16:42:36 -0700 Subject: [PATCH] bug fixes for css eslint rule (#14202) - ignores the link tags which do not have literal href e.g. `` --- packages/eslint-plugin-next/lib/rules/no-css-tags.js | 4 +++- test/eslint-plugin-next/no-css-tags.test.js | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/eslint-plugin-next/lib/rules/no-css-tags.js b/packages/eslint-plugin-next/lib/rules/no-css-tags.js index 3de32653aa..2bb215a0e8 100644 --- a/packages/eslint-plugin-next/lib/rules/no-css-tags.js +++ b/packages/eslint-plugin-next/lib/rules/no-css-tags.js @@ -18,7 +18,9 @@ module.exports = function (context) { ) && attributes.find( (attr) => - attr.name.name === 'href' && !/^https?/.test(attr.value.value) + attr.name.name === 'href' && + attr.value.type === 'Literal' && + !/^https?/.test(attr.value.value) ) ) { context.report({ diff --git a/test/eslint-plugin-next/no-css-tags.test.js b/test/eslint-plugin-next/no-css-tags.test.js index c3dcffb492..3c122f94bb 100644 --- a/test/eslint-plugin-next/no-css-tags.test.js +++ b/test/eslint-plugin-next/no-css-tags.test.js @@ -50,6 +50,18 @@ ruleTester.run('no-css-tags', rule, { ); } }`, + + `import {Head} from 'next/document'; + export class Blah extends Head { + render(props) { + return ( +
+

Hello title

+ +
+ ); + } + }`, ], invalid: [ -- GitLab