conflict between prefer-const and no-use-before-define (2.5.0 regression)
See original GitHub issueWhat version of ESLint are you using? 2.5.0 (I think my previous version that didn’t fail was 2.4.0, but it could have been a different 2.x) What parser (default, Babel-ESLint, etc.) are you using? Default Please show your full configuration:
{
...
"no-use-before-define": ["error", "nofunc"],
...
"prefer-const": "error",
}
What did you do? Please include the actual source code causing the issue.
let interval;
function checkForWindow() {
const newFocussed = BrowserWindow.getFocusedWindow();
if (newFocussed !== currentlyFocussed) {
clearInterval(interval);
newFocussed.toggleDevTools();
}
}
interval = setInterval(checkForWindow, msIntervalToCheckForWindow);
What did you expect to happen? no warnings What actually happened? Please include the actual, raw output from ESLint. either
76:13 error 'interval' is never reassigned, use 'const' instead prefer-const
or if I change it to const after the interval
72:35 error 'interval' was used before it was defined no-use-before-define
I see the rule says this is an error
// the initializer is separated.
let a;
a = 0;
console.log(a);
but this is not
let a;
if (true) {
a = 0;
}
console.log(a);
I would suggest that
let a;
// read or write of a in any sub block (e.g. if or function)
console.log(a);
is not an error?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:11 (10 by maintainers)
Top Results From Across the Web
eslint/CHANGELOG.md - UNPKG
129, * dc4075e Update: fix false negative in no-use-before-define (fixes ... 928, * 27616a8 Fix: prefer-const false positive with object spread (fixes ...
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 >prettier ignore specific rule | The AI Search Engine You Control
This is a prettier plugin that allows organizing import as part of the prettier ... Preventing conflict between Prettier (code formatter) and ESLint/TSLint....
Read more >A conflict in regression coefficients interpretations (R code ...
The issue here, is that you are fitting an interaction. The interpretation of the main effects changes in the presence of an interaction....
Read more >ESLint no-use-before-define - javascript - Stack Overflow
How do I get this ESLint rule ( no-use-before-define ) to not warn in ...
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
I’m sorry for late response. I will do within next week. I have a vacation in next week!!
See note on the PR. Option makes sense.