gund / eslint-plugin-deprecation

ESLint rule that reports usage of deprecated code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Include deprecated jsx prop checks

sebakerckhof opened this issue · comments

I noticed that this plugin does not warn for usage of deprecated jsx props.
Since we needed this, I've written this plugin: https://github.com/sebakerckhof/eslint-plugin-deprecated-jsx-props

I originally started with bringing https://github.com/Drawbotics/eslint-plugin-deprecated-props up to date, but its approach is fundamentally flawed, so I ended up rewriting most of it.

Anyway, it seems to work well on our codebase, but I have no desire to maintain it and therefore I wanted to check if you're interested in adopting it as part of this plugin. I could make a PR for it if you're interested.

It has tests to ensure it works with:

  • local types and interfaces
  • external types and interfaces
  • combined / extended types and interfaces
  • spread arguments (for which we make the distinction between optional and required props)

I've run into the same issue.

Within the source file, the deprecation is properly reported:

export interface DialogHeaderProps {
  /** @deprecated use children instead. */
  heading?: string
}

const DialogHeader = React.forwardRef<HTMLElement, DialogHeaderProps>(
  (
    {
      className: classNameProp,
      // eslint-disable-next-line deprecation/deprecation
      heading,

But any consumers of the component outside the source don't report

// no error
<DialogHeader heading="Hire employee" />

VSCode marks the property as deprecated, which means the JSDoc is applied properly.
Screenshot 2024-03-27 at 15 57 17

@sebakerckhof I tried installing your plugin but didn't see an error either :(

@gmathieu It works for similar code when I test it. If you can make a reproduction repo, I can take a look.

Hey @sebakerckhof, I think we can bring your fixes into the current rules in the way that does not introduce extra rule, since this plugin already checks JSX code.
I'm totally fine if you can make a PR for it, but please add unit tests along with the fixes so we can be sure it's working and we won't break it in the future.
Also just a heads up - we are upgrading some dependencies currently and also there is a migration to latest ESLint underway so you might want to hold a bit until both #79 and #86 are merged.

Looking forward to this feature!