Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[React 19] Eslint React JSDoc support #28935

Closed
eduardocque opened this issue Apr 27, 2024 · 1 comment
Closed

[React 19] Eslint React JSDoc support #28935

eduardocque opened this issue Apr 27, 2024 · 1 comment
Labels

Comments

@eduardocque
Copy link

eduardocque commented Apr 27, 2024

Summary

based on react 19 documentation prop-types is gone, so for JS users the only way to manage it is using JSDoc, can be possible to support jsdoc prop-type validation in eslint-plugin-react ?

Example

/**
 * @param {{
 *   content?: string,
 *   requiredParameter: string // required parameter if not can be with "?"
 * }} props
 * @returns {React.ReactElement}
 */
const ChildElement = props => {
  const { content = '' } = props;

  return <div>{content}</div>;
};

/** @returns {React.ReactElement} */
const ParentElement = () => {
  return <ChildElement content="Hello World" wrongParameter="test" />;
};

in this example

  • wrongParameter should be marked as error due that is not in ChildElement JSDocs
  • whole component should mark an error due that requiredParameter that exists in the JSDoc is not defined from the parent element

the intention of this request if to give some ways in javascrit to work without involve typescript to maange types and props

@kassens
Copy link
Member

kassens commented Apr 29, 2024

Unfortunately, type checking is a very complex task and out of the capabilities that a eslint plugin can provide (you need to look across files to start, which as far as I know isn't supported by ESLint).

For static type checking TypeScript (and Flow) are the supported ways.

@kassens kassens closed this as not planned Won't fix, can't repro, duplicate, stale Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants