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 false positive calling same-scoped function #375

Closed
kevinoid opened this issue Sep 17, 2019 · 2 comments · Fixed by #378 or #562
Closed

consistent-function-scoping false positive calling same-scoped function #375

kevinoid opened this issue Sep 17, 2019 · 2 comments · Fixed by #378 or #562

Comments

@kevinoid
Copy link

Running ESLint 6.4.0 with eslint-plugin-unicorn 11.0.0 and "extends": "plugin:unicorn/recommended" on a file with the following reduced example code:

'use strict';

module.exports = function recordErrors(eventEmitter, stateArgument) {
  function onError(error) {
    stateArgument.inputError = error;
  }
  function onError2(error) {
    onError(error);
  }

  eventEmitter.once('error', onError2);
};

gives the following output:

/tmp/consistent-function-scoping-issue/issue2.js
  7:3  error  Move function to the outer scope  unicorn/consistent-function-scoping

✖ 1 problem (1 error, 0 warnings)

I believe this is incorrect since onError2 can not be moved to the global scope, since it calls onError, which is only defined in the function scope.

Thanks,
Kevin

Note: Split from #374 per #374 (comment)

@kevinoid
Copy link
Author

Thanks for the very quick fix @MrHen!

@kevinoid
Copy link
Author

kevinoid commented Jan 9, 2020

My apologies for the late follow-up, but I don't believe this issue is completely fixed.

With ESLint 6.8.0, eslint-plugin-unicorn 15.0.1, and "extends": "plugin:unicorn/recommended" I still observe the same error with the original example code. #378 appears to have fixed the issue if module.exports = is not present, but when it is present (as in the original example) the issue still occurs.

Thanks,
Kevin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants