-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
Remove the condition argument from warning() #17568
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 653965e:
|
Details of bundled changes.Comparing: 7bf40e1...653965e react
react-dom
react-test-renderer
react-native-renderer
react-art
react-cache
react-reconciler
react-is
ReactDOM: size: 0.0%, gzip: 0.0% React: size: 0.0%, gzip: 0.0% Size changes (experimental) |
Details of bundled changes.Comparing: 7bf40e1...653965e react
react-dom
react-reconciler
react-art
react-test-renderer
react-native-renderer
ReactDOM: size: 0.0%, gzip: 0.0% Size changes (stable) |
typeof subscribe === 'function', | ||
'Subscription must specify a subscribe function', | ||
); | ||
if (!(typeof getCurrentValue === 'function')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make a special case and convert these to !==
negation directly.
identifier, | ||
MAX_TOUCH_BANK, | ||
); | ||
if (!(identifier <= MAX_TOUCH_BANK)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for these. <=
needs to flip to >
, <
needs to flip to >=
, >
needs to be <=
, and >=
needs to become <
.
warningWithoutStack( | ||
typeof input === 'string' || | ||
if ( | ||
!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For more complex conditions like this it's fine to leave them as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Let's detect
if (!(a === b))
early and instead outputif (a !== b)
and possibly the same for<
and such. - Need to fix up
warningWithoutStack.www.js
. It currently re-exportswarning
from WWW. But it has the old API. SowarningWithoutStack.www.js
should now export a function that calls the WWWwarning
withfalse
as first argument.
this should be good now but lemme recheck tomorrow |
I still see the old |
👍, the previous usage of warning is In my option, it's naturally more to warn in the condition of true. if (true) {
warn('xxx')
} and why not write |
* prep for codemod * prep warnings * rename lint rules * codemod for ifs * shim www functions * Handle more cases in the transform * Thanks De Morgan * Run the codemod * Delete the transform * Fix up confusing conditions manually * Fix up www shims to match expected API * Also check for low-pri warning in the lint rule
Step 2 of #16753
warning-and-invariant-args
intowarning-args
andinvariant-args
.toWarnDev
andtoLowPriorityWarnDev
didn't actually need any changes as they track the underlying console calls