From 49f9c0227ed00533e5431e3e530c91dd03c7c78d 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 3de32653aac240..2bb215a0e87938 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 c3dcffb492c210..3c122f94bb401c 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: [