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.

conflict between prefer-const and no-use-before-define (2.5.0 regression)

See original GitHub issue

What 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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
mysticateacommented, Apr 28, 2016

I’m sorry for late response. I will do within next week. I have a vacation in next week!!

1reaction
nzakascommented, May 5, 2016

See note on the PR. Option makes sense.

Read more comments on GitHub >

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

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