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

[New] Align no-deprecated rule with React 18 deprecations #3548

Merged
merged 1 commit into from Mar 14, 2023

Conversation

sergei-startsev
Copy link
Contributor

The list of deprecated APIs in React 18.0.0:

  • react-dom: ReactDOM.render
  • react-dom: ReactDOM.hydrate
  • react-dom: ReactDOM.unmountComponentAtNode
  • react-dom/server: ReactDOMServer.renderToNodeStream

Ref: https://github.com/facebook/react/blob/main/CHANGELOG.md#deprecations

Migration guide: https://beta.reactjs.org/blog/2022/03/08/react-18-upgrade-guide

@codecov
Copy link

codecov bot commented Mar 9, 2023

Codecov Report

Merging #3548 (5e648c8) into master (45184ef) will increase coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head 5e648c8 differs from pull request most recent head 838ac07. Consider uploading reports for the commit 838ac07 to get more accurate results

@@            Coverage Diff             @@
##           master    #3548      +/-   ##
==========================================
+ Coverage   97.60%   97.62%   +0.01%     
==========================================
  Files         132      132              
  Lines        9285     9286       +1     
  Branches     3395     3392       -3     
==========================================
+ Hits         9063     9065       +2     
+ Misses        222      221       -1     
Impacted Files Coverage Δ
lib/rules/no-deprecated.js 99.02% <100.00%> (+1.04%) ⬆️

... and 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@sergei-startsev
Copy link
Contributor Author

@ljharb / @gaearon for awareness.

Comment on lines -51 to -52
'ReactDOM.render(element, container);',
'ReactDOM.unmountComponentAtNode(container);',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should be able to keep these test cases with the react version set to 17.999.999

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added one more test to cover this scenario.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant, keep the "valid" tests cases, because these remain valid in react < 18.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant, keep the "valid" cases, because these remain valid in react < 18.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You cannot leave it where it was before, React version isn't specified there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right - i mean, edit the existing rule to add the react version, so that "a passing test for ReactDOM.render" remains

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React version can be specified using eslint settings.react.version property which is demonstrated in the added tests. Introducing multiple sources to determine React version doesn't seem like a good idea to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ljharb Is there anything else that prevents the PR from being merged? I believe the requested scenario has been covered:

// React < 18
{
code: `
import { render, hydrate } from 'react-dom';
import { renderToNodeStream } from 'react-dom/server';
ReactDOM.render(element, container);
ReactDOM.unmountComponentAtNode(container);
ReactDOMServer.renderToNodeStream(element);
`,
settings: { react: { version: '17.999.999' } },
},

docs/rules/no-deprecated.md Show resolved Hide resolved
@ljharb ljharb merged commit 838ac07 into jsx-eslint:master Mar 14, 2023
262 of 263 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants