webhintio / hint

πŸ’‘ A hinting engine for the web

Home Page:https://webhint.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] JSX prop spread notation `<input {...props}>` results in false-positives

antross opened this issue Β· comments

🐞 Bug report

Description

Based on microsoft/vscode-edge-devtools#1031

Given this example JSX that just forwards props:

function MyInput(props) {
  return <input {...props} />;
}

Webhint will produce the following error, even though props may have already included a title:

Form elements must have labels: Element has no title attribute Element has no placeholder attribute

Details

Webhint can't catch every way in which different values may have been provided to props, but it shouldn't assume expected values are missing in this case. Instead, webhint should give the developer the benefit of the doubt when the exact props included can't be determined to avoid false-positives. There's already precedent to assume the correct value is provided when the value of a prop is interpolated (e.g. <button type={type}>).