Open yvele opened 1 year ago
With the following rule:
"unicorn/consistent-function-scoping" : ["error", { checkArrowFunctions : true }]
(I do really want arrow function to move upper scope when they do not use any variable or upper this).
this
This is wrongly reported as a problem:
class Foo { public bar = new FinalizationRegistry(() => { console.log(this); // <- `this` is used in this arrow function }) }
error Move arrow function to the outer scope unicorn/consistent-function-scoping
Same for:
function foo(this) { const bar = () => console.log(this); // <- `this` is used in this arrow function return [].map(() => bar); }
error Move arrow function 'bar' to the outer scope
The cases below should be OK when an arrow function only consuming this from outer scope.
Just had this false-positive with this in a class show up after switching eslint's parser from espree to @typescript-eslint/parser. So the bug looks to be parser-related.
espree
@typescript-eslint/parser
With the following rule:
(I do really want arrow function to move upper scope when they do not use any variable or upper
this
).This is wrongly reported as a problem:
Same for:
The cases below should be OK when an arrow function only consuming
this
from outer scope.