Skip to content

Add rule to ensure className and event handlers are merged properly #440

@siddharthkp

Description

@siddharthkp

From @joshblack:

Would it be possible to have the rule (or a follow up rule?) that helps people understand when something may not be merged correctly. For example:

-<Example {...rest} className="..." />
+<Example {...rest} className={clsx(className, '...')} />

-<Example {...rest} onClick={() => {}} />
+<Example {...rest} onClick={compose(onClick, () => {})} />

It would be helpful to know in these situations that we have not merged rest correctly. My guess is that it would be too hard in eslint world to know what rest is but figured I'd ask


Added by @siddharthkp:

We probably need to check if there is className or event handlers expected in the props and only then suggest to merge them


Implementation plan:

  • Create 2 new rules in src/rules in the same style as other files in that directory
  • Write tests for these in src/rules/__tests__
  • Add files for documentation in docs/rules
  • Don't blindly add this in every file, first check if there is className or event handlers expected from the props

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions