Skip to content

jsx-handler-names support skipping prop naming checks #3722

Closed
@Max10240

Description

@Max10240

My project has many components from other dependency packages, like:

<ComponentFromOtherLibraryFoo customPropNameFoo={handleSomething} />;
<ComponentFromOtherLibraryBar customPropNameBar={handleSomething} />;

Every time I come across them, I need to add an extra line of boring comments:

// eslint-disable-next-line jsx-handler-names
<ComponentFromOtherLibraryFoo customPropNameFoo={handleSomething} />;
// eslint-disable-next-line jsx-handler-names
<ComponentFromOtherLibraryBar customPropNameBar={handleSomething} />;

To be honest, I don't care about the names of these PROPS(even the components in my own project, I just want it to check my handler function's name)

To make matters worse, if the prop's name is not camelCase (e.g., all lowercase letters: "foofoo"), the option "eventHandlerPropPrefix" is not valid either, because it only applies to CamelCase naming:

/* with config: 
{
  eventHandlerPrefix: '(on|handle)',
  eventHandlerPropPrefix: '(on|foo)',
}
*/
// fine
<ComponentFromOtherLibraryFoo fooPropName={handleSomething} />;

// not work, still has error
<ComponentFromOtherLibraryFoo foo={handleSomething} />;

So, it would be nice if there were an option like "checkPropName". For those who don't care about prop naming, simply turn it off.
like:

{
  eventHandlerPrefix: '(on|handle)',
  eventHandlerPropPrefix: '(on|foo)',
  // ...
  checkPropName: false,
}

Anyway, I want to confirm if this option is necessary (and if anyone else has experienced this), and if so, I can create a PR to do it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions