-
-
Notifications
You must be signed in to change notification settings - Fork 509
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
linter: false positive for FunctionExpression
s in unicorn/consistent-function-scoping
#5365
Comments
wait i'm confused 😅 to be clear, the correct behavour here is that the following code: function outer() {
const inner = function inner() {}
} should report an error ( but with oxlint's current behaviour, it does not report an error? if so, isn't this fixed by #5312, with the new test case here ? https://github.com/oxc-project/oxc/pull/5312/files#diff-8becea68b83c5a44bd998989f16fb08f3fc78f8ccfbbd95a30cc3056a6cf0edc |
ahhh i see - thanks In summary: we do not report an error for the following code: let inner;
function outer() {
inner = function inner() {}
} But we should as there's no reason why the assignment couldn't be removed to the outer scope. NOTE: when/if we implement this, we should add the following as a PASS test case: let inner;
function foo1() {
inner = function {}
}
function foo2() {
inner = function {}
} I can't think of why someone would want to do this (maybe a different logger in dev vs prod or something?), but i don't think we should report this case |
@camc314 would work on this. |
…orn/consistent-function-scoping``` (#5675) This is to fix the cases mentioned in the comment section of #5365. In short, it will report these as PASS test cases: ```js let inner; function foo1() { inner = function() {} } function foo2() { inner = function() {} } ``` ```js let inner; function outer() { inner = function() {} } ``` And report these below as FAIL test cases: ```js let inner; function foo1() { inner = function smth() {} } function foo2() { inner = function bar() {} } ``` ```js let inner; function outer() { inner = function inner() {} } ``` The case below was already done in #5312 but mentioned in #5365. It is a FAIL case as well: ```js function outer() { const inner = function inner() {} } ``` --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Don Isaac <[email protected]>
This currently passes, but it should not:
See this thread for details.
The text was updated successfully, but these errors were encountered: