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

[Rule Migration] migrate eslint-plugin-react rules #85

Closed
47 of 49 tasks
rEl1cx opened this issue Nov 5, 2023 · 9 comments
Closed
47 of 49 tasks

[Rule Migration] migrate eslint-plugin-react rules #85

rEl1cx opened this issue Nov 5, 2023 · 9 comments
Assignees
Labels
Type: Feature New features

Comments

@rEl1cx
Copy link
Owner

rEl1cx commented Nov 5, 2023

Migration Status

Correctness and best practices rules

The following stylistic rules in eslint-plugin-react can be replaced by the same rules in @stylistic/eslint-plugin-jsx:

  • react/jsx-child-element-spacing
  • react/jsx-closing-bracket-location
  • react/jsx-closing-tag-location
  • react/jsx-curly-brace-presence
  • react/jsx-curly-newline
  • react/jsx-curly-spacing
  • react/jsx-equals-spacing
  • react/jsx-first-prop-new-line
  • react/jsx-indent-props
  • react/jsx-indent
  • react/jsx-max-props-per-line
  • react/jsx-newline
  • react/jsx-one-expression-per-line
  • react/jsx-pascal-case
  • react/jsx-props-no-multi-spaces
  • react/jsx-sort-default-props
  • react/jsx-sort-props
  • react/jsx-space-before-closing
  • react/jsx-tag-spacing
  • react/jsx-wrap-multilines

The following correctness rules in eslint-plugin-react can be enforced by TypeScript with appropriate tsconfig.json settings:

  • react/jsx-no-duplicate-props
  • react/jsx-no-undef
  • react/jsx-uses-react
  • react/jsx-uses-vars
  • react/no-invalid-html-attribute
  • react/no-unescaped-entities -> No need when using @typescript-eslint/parser
  • react/no-unknown-property
  • react/style-prop-object
  • react/react-in-jsx-scope
  • react/require-render-return

Outdated or obsolete rules

These rules are considered outdated or obsolete. They are not going to be supported by this plugin.

  • react/default-props-match-prop-types
  • react/forbid-foreign-prop-types
  • react/forbid-prop-types
  • react/no-unused-prop-types
  • react/prefer-exact-props
  • react/prefer-es6-class
  • react/prefer-stateless-function
  • react/require-default-props
  • react/require-optimization
  • react/sort-default-props
  • react/sort-prop-types
  • react/state-in-constructor
  • react/static-property-placement
  • react/jsx-no-bind
@rEl1cx rEl1cx added the Type: Enhancement Enhancements to existing features label Nov 5, 2023
@rEl1cx rEl1cx pinned this issue Nov 5, 2023
@rEl1cx rEl1cx self-assigned this Nov 11, 2023
@rEl1cx rEl1cx added Type: Enhancement Enhancements to existing features Type: Feature New features and removed Type: Enhancement Enhancements to existing features labels Nov 17, 2023
@rEl1cx rEl1cx changed the title Rule Request: migrate eslint-plugin-react rules [Rule Migration] migrate eslint-plugin-react rules Nov 17, 2023
@rEl1cx rEl1cx unpinned this issue Jan 27, 2024
@yunsii
Copy link
Contributor

yunsii commented Apr 21, 2024

How to migrate react/self-closing-comp rule?

@rEl1cx
Copy link
Owner Author

rEl1cx commented Apr 21, 2024

How to migrate react/self-closing-comp rule?

All stylistic rules including jsx-self-closing-comp have been migrated to @stylistic/eslint-plugin-jsx, which can be used in addition to this plugin.

@Talent30
Copy link

Talent30 commented Aug 3, 2024

How about rule:
https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md

@karlhorky
Copy link
Contributor

karlhorky commented Oct 6, 2024

Hi @rEl1cx, thanks for this! Amazing as always 🚀

However, I ran into an issue today that eslint-plugin-mdx requires react/jsx-uses-vars

There is not yet full TypeScript support for MDX files, and it appears ESLint doesn't support multiple parsers for a set of files (eg. for trying to use typescript-eslint parser along with the MDX parser).

I tried to use eslint-plugin-react-x for this (looking for react-x/jsx-uses-vars) and found this part of the issue description:

The following can be enforced by TypeScript, no need to implement them

  • react/jsx-uses-vars

What do you think about implementing this for other languages like MDX? (and also just for completeness, for other situations where TypeScript cannot be used)

I can create a separate issue for this to track this request.

@rEl1cx
Copy link
Owner Author

rEl1cx commented Oct 7, 2024

Hi @rEl1cx, thanks for this! Amazing as always 🚀

However, I ran into an issue today that eslint-plugin-mdx requires react/jsx-uses-vars

There is not yet full TypeScript support for MDX files, and it appears ESLint doesn't support multiple parsers for a set of files (eg. for trying to use typescript-eslint parser along with the MDX parser).

I tried to use eslint-plugin-react-x for this (looking for react-x/jsx-uses-vars) and found this part of the issue description:

The following can be enforced by TypeScript, no need to implement them

  • react/jsx-uses-vars

What do you think about implementing this for other languages like MDX? (and also just for completeness, for other situations where TypeScript cannot be used)

I can create a separate issue for this to track this request.

This is a good point, I agree with creating a separate issue to track this, please proceed.

@karlhorky
Copy link
Contributor

Thanks for the response! New issue here:

@karlhorky
Copy link
Contributor

karlhorky commented Oct 29, 2024

Opened another similar one for react/no-unknown-property, since this is also a common, helpful rule:

@stianjensen
Copy link

This says that react/no-unused-prop-types is outdated/obsolete. I'm guessing because prop-types are deprecated?
But the rule also supported linting based on a declared typescript type, and ensured props that were declared were actually used. Is that not still relevant?
https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md

@rEl1cx
Copy link
Owner Author

rEl1cx commented Dec 19, 2024

This says that react/no-unused-prop-types is outdated/obsolete. I'm guessing because prop-types are deprecated? But the rule also supported linting based on a declared typescript type, and ensured props that were declared were actually used. Is that not still relevant? jsx-eslint/eslint-plugin-react@master/docs/rules/no-unused-prop-types.md

Thank you for mentioning that the rule also supported linting based on a declared TypeScript type. This aspect was overlooked at the time, and I will reconsider whether to migrate this rule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature New features
Projects
None yet
Development

No branches or pull requests

5 participants