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.

Option to ignore arrow functions in `consistent-function-scoping`

See original GitHub issue

Please allow the option to ignore arrow functions in the consistent-function-scoping rule. Sometimes I create a one liner function, and I don’t want to have to move it to the highest scope.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
Arttsecommented, May 14, 2020

How about this simple example with Redux Thunk?

Arrow function (throws error):

// ESLint: Move arrow function to the outer scope.(unicorn/consistent-function-scoping)
//
//                              here
//                              ⬇
export const someAction = () => (dispatch) =>
  dispatch({
    type: SOME_TYPE,
  });

Function declaration (no error):

export function someAction() {
  return (dispatch) =>
    dispatch({
      type: SOME_TYPE,
    });
}

Is it bug or feature? Is it normal or not?

0reactions
fiskercommented, Dec 10, 2020

I took a quick look, it’s caused by scopeManager.acquire it can’t get scope, not sure how to fix it, maybe later.

Read more comments on GitHub >

github_iconTop Results From Across the Web

prefer-arrow-callback - ESLint - Pluggable JavaScript Linter
Arrow functions can be an attractive alternative to function expressions for callbacks or function arguments. For example, arrow functions are automatically ...
Read more >
unbound-method | typescript-eslint
If your function does not access this , you can annotate it with this: void , or consider using an arrow function instead....
Read more >
ES6 arrow functions, syntax and lexical scoping
Arrow functions are always anonymous, which means we can't do this with ES6: // ES5 function doSomething() { //... }.
Read more >
Enforce the location of arrow function bodies with implicit ...
An arrow function body can contain an implicit return as an expression instead of a block body. It can be useful to enforce...
Read more >
JSHint Options Reference
Setting this option to "nofunc" will allow function declarations to be ignored. For more in-depth understanding of scoping and hoisting in JavaScript, read ......
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