-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[Fix] no-invalid-html-attribute: allow 'shortcut icon' on link
#3174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -130,6 +130,9 @@ ruleTester.run('no-invalid-html-attribute', rule, { | |||||
| { code: '<link rel="icon"></link>' }, | ||||||
| { code: 'React.createElement("link", { rel: "icon" })' }, | ||||||
| { code: 'React.createElement("link", { rel: ["icon"] })' }, | ||||||
| { code: '<link rel="shortcut icon"></link>' }, | ||||||
| { code: 'React.createElement("link", { rel: "shortcut icon" })' }, | ||||||
| { code: 'React.createElement("link", { rel: ["shortcut icon"] })' }, | ||||||
| { code: '<link rel="license"></link>' }, | ||||||
| { code: 'React.createElement("link", { rel: "license" })' }, | ||||||
| { code: 'React.createElement("link", { rel: ["license"] })' }, | ||||||
|
|
@@ -231,6 +234,83 @@ ruleTester.run('no-invalid-html-attribute', rule, { | |||||
| }, | ||||||
| ], | ||||||
| invalid: [ | ||||||
| { | ||||||
| code: '<a rel="alternatex"></a>', | ||||||
| output: '<a rel=""></a>', | ||||||
| errors: [ | ||||||
| { | ||||||
| messageId: 'neverValid', | ||||||
| }, | ||||||
| ], | ||||||
| }, | ||||||
| { | ||||||
| code: 'React.createElement("a", { rel: "alternatex" })', | ||||||
| output: 'React.createElement("a", { rel: "alternatex" })', | ||||||
| errors: [ | ||||||
| { | ||||||
| messageId: 'neverValid', | ||||||
| }, | ||||||
| ], | ||||||
| }, | ||||||
| { | ||||||
| code: 'React.createElement("a", { rel: ["alternatex"] })', | ||||||
| output: 'React.createElement("a", { rel: ["alternatex"] })', | ||||||
| errors: [ | ||||||
| { | ||||||
| messageId: 'neverValid', | ||||||
| }, | ||||||
| ], | ||||||
| }, | ||||||
| { | ||||||
| code: '<a rel="alternatex alternate"></a>', | ||||||
| output: '<a rel=" alternate"></a>', | ||||||
| errors: [ | ||||||
| { | ||||||
| messageId: 'neverValid', | ||||||
| }, | ||||||
| ], | ||||||
| }, | ||||||
| { | ||||||
| code: 'React.createElement("a", { rel: "alternatex alternate" })', | ||||||
| errors: [ | ||||||
| { | ||||||
| messageId: 'neverValid', | ||||||
| }, | ||||||
| ], | ||||||
| }, | ||||||
| { | ||||||
| code: 'React.createElement("a", { rel: ["alternatex alternate"] })', | ||||||
| errors: [ | ||||||
| { | ||||||
| messageId: 'neverValid', | ||||||
| }, | ||||||
| ], | ||||||
| }, | ||||||
| { | ||||||
| code: '<a rel="alternate alternatex"></a>', | ||||||
| output: '<a rel="alternate "></a>', | ||||||
| errors: [ | ||||||
| { | ||||||
| messageId: 'neverValid', | ||||||
| }, | ||||||
| ], | ||||||
| }, | ||||||
| { | ||||||
| code: 'React.createElement("a", { rel: "alternate alternatex" })', | ||||||
| errors: [ | ||||||
| { | ||||||
| messageId: 'neverValid', | ||||||
| }, | ||||||
| ], | ||||||
| }, | ||||||
| { | ||||||
| code: 'React.createElement("a", { rel: ["alternate alternatex"] })', | ||||||
| errors: [ | ||||||
| { | ||||||
| messageId: 'neverValid', | ||||||
| }, | ||||||
| ], | ||||||
| }, | ||||||
| { | ||||||
| code: '<html rel></html>', | ||||||
| output: '<html ></html>', | ||||||
|
|
@@ -373,6 +453,26 @@ ruleTester.run('no-invalid-html-attribute', rule, { | |||||
| }, | ||||||
| ], | ||||||
| }, | ||||||
| { | ||||||
| code: '<a rel="noreferrer noopener"></a>', | ||||||
| output: '<a rel="noreferrer noopener"></a>', | ||||||
| errors: [ | ||||||
| { | ||||||
| messageId: 'spaceDelimited', | ||||||
| data: { attributeName: 'rel' }, | ||||||
| }, | ||||||
| ], | ||||||
| }, | ||||||
| { | ||||||
| code: '<a rel="noreferrer\xa0\xa0noopener"></a>', | ||||||
| output: '<a rel="noreferrer noopener"></a>', | ||||||
| errors: [ | ||||||
| { | ||||||
| messageId: 'spaceDelimited', | ||||||
| data: { attributeName: 'rel' }, | ||||||
| }, | ||||||
| ], | ||||||
| }, | ||||||
| { | ||||||
| code: '<a rel={"noreferrer noopener foobar"}></a>', | ||||||
| output: '<a rel={"noreferrer noopener "}></a>', | ||||||
|
|
@@ -537,6 +637,73 @@ ruleTester.run('no-invalid-html-attribute', rule, { | |||||
| }, | ||||||
| ], | ||||||
| }, | ||||||
| { | ||||||
| code: '<link rel="shortcut"></link>', | ||||||
| errors: [ | ||||||
| { | ||||||
| messageId: 'notAlone', | ||||||
| data: { | ||||||
| reportingValue: 'shortcut', | ||||||
| missingValue: 'icon', | ||||||
| }, | ||||||
| }, | ||||||
| ], | ||||||
| }, | ||||||
| { | ||||||
| code: '<link rel="shortcut foo"></link>', | ||||||
| output: '<link rel="shortcut "></link>', | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm but it actually does that - it's the opposite of code: '<a rel={"batgo noopener"}></a>',
output: '<a rel={" noopener"}></a>',
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test fails when I remove it
This comment was marked as outdated.
Sorry, something went wrong.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh no, we shouldn't remove it - it is the testcase for the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm basically saying that the autofix output should never have leading or trailing spaces.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that also confused me, but apparently that's "how things used to be" in Apparently it only runs one cycle when fixing and we would need to find a way to kind of
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fair point. altho it seems like adding
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea! But where would I run this, I think I haven't fully grasped when/how fix runs. Would this be part of fix? Or would we just always in the end after all checks run another trim as it's never good/valid to keep it?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding a single fixer on program exit that trimmed any attribute strings that had been previously autofixed (we’d have to track that manually) would be good. I think that should wait for a followup PR, tho, because it was a pre-existing problem. I’ll land this tomorrow, as-is. |
||||||
| errors: [ | ||||||
| { | ||||||
| messageId: 'neverValid', | ||||||
| data: { | ||||||
| reportingValue: 'foo', | ||||||
| attributeName: 'rel', | ||||||
| }, | ||||||
| }, | ||||||
| { | ||||||
| messageId: 'notPaired', | ||||||
| data: { | ||||||
| reportingValue: 'shortcut', | ||||||
| secondValue: 'foo', | ||||||
| missingValue: 'icon', | ||||||
| }, | ||||||
| }, | ||||||
| ], | ||||||
| }, | ||||||
| { | ||||||
| code: '<link rel="shortcut icon"></link>', | ||||||
| output: '<link rel="shortcut icon"></link>', | ||||||
| errors: [ | ||||||
| { | ||||||
| messageId: 'spaceDelimited', | ||||||
| data: { attributeName: 'rel' }, | ||||||
| }, | ||||||
| ], | ||||||
| }, | ||||||
| { | ||||||
| code: '<link rel="shortcut foo"></link>', | ||||||
| output: '<link rel="shortcut foo"></link>', | ||||||
| errors: [ | ||||||
| { | ||||||
| messageId: 'neverValid', | ||||||
| data: { | ||||||
| reportingValue: 'foo', | ||||||
| attributeName: 'rel', | ||||||
| }, | ||||||
| }, | ||||||
| { | ||||||
| messageId: 'notAlone', | ||||||
| data: { | ||||||
| reportingValue: 'shortcut', | ||||||
| missingValue: 'icon', | ||||||
| }, | ||||||
| }, | ||||||
| { | ||||||
| messageId: 'spaceDelimited', | ||||||
| data: { attributeName: 'rel' }, | ||||||
| }, | ||||||
| ], | ||||||
| }, | ||||||
| { | ||||||
| code: '<a rel="manifest"></a>', | ||||||
| output: '<a rel=""></a>', | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.