question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

no-use-before-define does not understand functions

See original GitHub issue

If 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:closed
  • Created 10 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
nzakascommented, Sep 16, 2013

@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.

0reactions
michaelficarracommented, Sep 16, 2013

@nzakas: The ramification would then be that you can’t define mutually recursive functions. This rule reintroduces the classic letrec problem.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found