no-use-before-define does not understand functions
See original GitHub issueIf the variable is declared after declaration of the function, and it’s used inside the function, no-use-before-define will complain about it, even if the function is invoked after variable definition:
function a() {
alert(b);
}
var b=0;
a();
Issue Analytics
- State:
- Created 10 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
ESLint no-use-before-define - javascript - Stack Overflow
Actually, having this rule turned on for functions doesn't make any sense - they ARE hoisted, while classes and variables are not. Like...
Read more >no-use-before-define - ESLint - Pluggable JavaScript Linter
Rule Details. This rule will warn when it encounters a reference to an identifier that has not yet been declared. Examples of incorrect...
Read more >typescript-eslint/no-use-before-define.md at main - GitHub
Disallow the use of variables before they are defined. 🛑 This file is source code, not the primary documentation location! 🛑. See https://typescript-eslint....
Read more >no-use-before-define - TypeScript ESLint
Disallow the use of variables before they are defined. Examples. This rule extends the base eslint/no-use-before-define rule. It adds support for ...
Read more >Adam Wathan on Twitter: "I find it very odd that the ESLint "no ...
I find it very odd that the ESLint "no-use-before-define" rule complains about code like this... It thinks "bar" is being used before it's ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@michaelficarra The behavior I describe is how the
latedef
option works in JSHint, which is what this rule was designed to mimic. You can turn the rule off if it doesn’t apply to your code.@nzakas: The ramification would then be that you can’t define mutually recursive functions. This rule reintroduces the classic letrec problem.