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:
parent
d3704a66f8
commit
6ff72006c8
2 changed files with 15 additions and 1 deletions
|
@ -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({
|
||||
|
|
|
@ -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: [
|
||||
|
|
Loading…
Reference in a new issue