eslint-react icon indicating copy to clipboard operation
eslint-react copied to clipboard

[feat] New rule `no-explict-spread-props`

Open SukkaW opened this issue 9 months ago • 0 comments

Describe the problem

    <a
      className={styles.link}
      {...{
        href: props.href,
        rel: 'noopener noreferrer',
        target: '_blank',
      }}
      {...props}
    >
      {label}
    </a>

Describe the solution you'd like

This kind of code should be forbidden and should be auto fixed to

    <a
      className={styles.link}
      href={props.href}
      rel="noopener noreferrer"
      target="_blank"
      {...props}
    >
      {label}
    </a>

Alternatives considered

No response

Additional context

This should be allowed:

    <Comp
      {...(
        props.a ? { b: 'c' } : {}
      )}
      {...props}
    />

SukkaW avatar May 07 '24 03:05 SukkaW