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 triggers for variables defined below a function even if variable will be defined when a function using that variable is called.

See original GitHub issue

What version of ESLint are you using? 2.12.0

What parser (default, Babel-ESLint, etc.) are you using? babel-eslint

Please show your full configuration: https://github.com/AriaFallah/eslint-config-aria/blob/master/index.js

Specific line:

"no-use-before-define": [2, "nofunc"]

What did you do? Please include the actual source code causing the issue.

function x() {
  return myFunc()
}

const myFunc = function() {
  return 5
}

console.log(x())

What did you expect to happen? No errors. This doesn’t result in myFunc is undefined in console because the function is not called before myFunc is defined.

What actually happened? Please include the actual, raw output from ESLint.

error  'myFunc' was used before it was defined  no-use-before-define

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
AriaFallahcommented, Jun 14, 2016

@vsemozhetbyt

Right, but that’s only if they’re in the same function scope. If you run the example code I provided in the babel REPL, you’ll get:

screen shot 2016-06-14 at 4 56 48 pm

1reaction
vsemozhetbytcommented, Jun 14, 2016

I see.

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-use-before-define - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
ESLint no-use-before-define - javascript - Stack Overflow
This flag determines whether or not the rule checks variable declarations in upper scopes. If this is true, the rule warns every reference...
Read more >
Chapter 4. Variables, Functions, and Flow Control - O'Reilly
If you have defined a global variable with the same name, the function's assignment statement overwrites the value originally assigned to the global...
Read more >
React Native development tools - Part 1: Linting tools - Pusher
no-use-before-define is a default rule implemented by ESLint. This rule prevents you from using variables that haven't previously been defined yet. In React ......
Read more >
Documentation: 15: 43.10. Trigger Functions - PostgreSQL
PL/pgSQL can be used to define trigger functions on data changes or database ... variable holding the new database row for INSERT /...
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