bug fixes for css eslint rule (#14202)

- ignores the link tags which do not have literal href
e.g. `<link rel="stylesheet" href={props.href} />`
This commit is contained in:
Prateek Bhatnagar 2020-06-15 16:42:36 -07:00 committed by GitHub
parent d3704a66f8
commit 6ff72006c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View file

@ -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({

View file

@ -50,6 +50,18 @@ ruleTester.run('no-css-tags', rule, {
);
}
}`,
`import {Head} from 'next/document';
export class Blah extends Head {
render(props) {
return (
<div>
<h1>Hello title</h1>
<link rel="stylesheet" {...props} />
</div>
);
}
}`,
],
invalid: [