Skip to content

feat(lint): Add ESLint rule to warn against spreading props

Warren Gifford requested to merge mihir/eslint-no-spreading into main

Created by: plibither8

This PR adds an ESLint rule to warn against spreading ambiguously-named props (props and rest) into components.

Relevant discussion on Slack.

Bad code:

<MyComponent {...rest} />
              ~~~~~~~

OK code:

<MyComponent {...ariaAttributes} />

Bonus amazing code:

const { prop_one, prop_two } = props
<MyComponent prop_one={prop_one} prop_two={prop_two} />

Test plan

Tested on VS Code by implementing the unsafe patterns and observing eslint warning showing up.

App preview:

Check out the client app preview documentation to learn more.

Merge request reports

Loading