From ff4f6760f488c2acd4003cb01fe0c1de9b858f4d Mon Sep 17 00:00:00 2001 From: mrkldshv Date: Tue, 8 Nov 2022 11:01:10 +0000 Subject: [PATCH] Change condition to check for string --- .../src/utils/node-attributes.ts | 11 +++++----- .../google-font-display.test.ts | 21 +++++++++++++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/packages/eslint-plugin-next/src/utils/node-attributes.ts b/packages/eslint-plugin-next/src/utils/node-attributes.ts index 4ad4667fa8b7..e5d0878f3686 100644 --- a/packages/eslint-plugin-next/src/utils/node-attributes.ts +++ b/packages/eslint-plugin-next/src/utils/node-attributes.ts @@ -32,11 +32,12 @@ export default class NodeAttributes { if (!!attribute.value) { // hasValue - const value = attribute.value.value - ? attribute.value.value - : typeof attribute.value.expression.value !== 'undefined' - ? attribute.value.expression.value - : attribute.value.expression.properties + const value = + typeof attribute.value.value === 'string' + ? attribute.value.value + : typeof attribute.value.expression.value !== 'undefined' + ? attribute.value.expression.value + : attribute.value.expression.properties this.attributes[attribute.name.name] = { hasValue: true, diff --git a/test/unit/eslint-plugin-next/google-font-display.test.ts b/test/unit/eslint-plugin-next/google-font-display.test.ts index d52ec9a831d7..45ae4b0b70c7 100644 --- a/test/unit/eslint-plugin-next/google-font-display.test.ts +++ b/test/unit/eslint-plugin-next/google-font-display.test.ts @@ -56,6 +56,27 @@ ruleTester.run('google-font-display', rule, { export default MyDocument; `, + + `import Document, { Html, Head } from "next/document"; + + class MyDocument extends Document { + render() { + return ( + + + + + + ); + } + } + + export default MyDocument; + `, ], invalid: [