no-use-before-define.js: ignore hoisted named function expressions
See original GitHub issueWhen you declare a function via a named function expression, e.g. function myFunc() {};
, JavaScript hoists that function so it is available before evaluation within the context in which is was declared. Currently the no-use-before-define.js rules throws a warning for this common use case.
Issue Analytics
- State:
- Created 10 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
For what purpose 'no-use-before-define' warns about declared ...
However, when declaring functions, it is perfectly okay to call a function before it is defined (thanks to the JS hoisting mechanism)
Read more >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 >Function expression - JavaScript - MDN Web Docs
Function expressions in JavaScript are not hoisted, unlike function declarations. You can't use function expressions before you create them:.
Read more >When to Use a Function Expression vs. Function Declaration
There are two ways to create functions in JavaScript: function ... Function declarations are hoisted, while function expressions are not.
Read more >Defending Function Hoisting in a Commit Message - bazile.org
Several of my fellow developers have a preference for using function expressions over named function declarations, e.g.: let add = (a, b) =>...
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
no-use-before-define has an option called
nofunc
- exactly what I needed.Ilya is correct, this is the intended behavior.