-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
docs: update no-undef-init
when not to use section
#19624
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
Conversation
✅ Deploy Preview for docs-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
Can you also update the first paragraph of this section, as there are two situations where initializing to undefined
behaves differently than omitting the initialization (mentioned loop, and redeclaration).
eslint/docs/src/rules/no-undef-init.md
Line 83 in a40348f
There is one situation where initializing to `undefined` behaves differently than omitting the initialization, and that's when a `var` declaration occurs inside of a loop. For example: |
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.
Just a few small changes to the text.
docs/src/rules/no-undef-init.md
Outdated
There are two situations where initializing to `undefined` behaves differently than omitting the initialization. | ||
|
||
The first is when a `var` declaration occurs inside of a loop. For example: |
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.
Are we sure there are only two situations?
There are two situations where initializing to `undefined` behaves differently than omitting the initialization. | |
The first is when a `var` declaration occurs inside of a loop. For example: | |
There are situations where initializing to `undefined` behaves differently than omitting the initialization. | |
One such case is when a `var` declaration occurs inside a loop. For example: |
docs/src/rules/no-undef-init.md
Outdated
@@ -150,3 +152,22 @@ for (i = 0; i < 10; i++) { | |||
``` | |||
|
|||
::: | |||
|
|||
The second is when a variable is redeclared using `var`. For example: |
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.
The second is when a variable is redeclared using `var`. For example: | |
Another such case is when a variable is redeclared using `var`. For example: |
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.
Done!
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.
LGTM, thanks! Leaving open for @snitin315 to verify.
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.
LGTM, thanks!
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[x] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
What changes did you make? (Give an overview)
Updated
when not to use
section ofno-undef-init
rule docs by adding example of variable declaration with uninitialized and initialized withundefined
.Is there anything you'd like reviewers to focus on?
Fixes #19623