Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consistent-function-scoping fails, even though function uses block-scoped value #2164

Open
RyanZim opened this issue Jul 4, 2023 · 0 comments

Comments

@RyanZim
Copy link

RyanZim commented Jul 4, 2023

unicorn/consistent-function-scoping demands that functions that be moved to the outer scope, even though the function captures a block-scoped variable.

Totally contrived example:

function foo() {
  for (let i = 0; i < 3; i++) {
    const scoped = i + 42
    const fn = () => 5 + scoped
    console.log(fn())
  }
}

results in:

4:19  error  Move arrow function 'fn' to the outer scope  unicorn/consistent-function-scoping

Of course, it's impossible to move fn to the outer scope, as scoped isn't defined there.

@fregante fregante changed the title unicorn/consistent-function-scoping fails, even though function uses block-scoped value consistent-function-scoping fails, even though function uses block-scoped value Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants