Unverified Commit 2b85da77 authored by Mark Ladyshau's avatar Mark Ladyshau Committed by GitHub

Change condition to check for string attribute in lint rules utility function (#42625)

<!--
Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change that you're making:
-->

Fixes #42604.

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
parent eed63e1e
......@@ -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,
......
......@@ -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 (
<Html>
<Head>
<link
href="https://fonts.googleapis.com/css?family=Krona+One&display=swap"
rel="stylesheet"
crossOrigin=""
/>
</Head>
</Html>
);
}
}
export default MyDocument;
`,
],
invalid: [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment