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

no-empty-function false positive #12768

Closed
EvgenyOrekhov opened this issue Jan 10, 2020 · 6 comments · Fixed by #13036
Closed

no-empty-function false positive #12768

EvgenyOrekhov opened this issue Jan 10, 2020 · 6 comments · Fixed by #13036
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules

Comments

@EvgenyOrekhov
Copy link

Tell us about your environment

  • ESLint Version: 6.8.0
  • Node Version: 12.14.1
  • npm Version: 6.13.4

What parser (default, Babel-ESLint, etc.) are you using?

default

Please show your full configuration:

Configuration
{
  "no-empty-function": ["error", { "allow": ["methods"] }]
}

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

const object = {
  async method() {}
};
eslint .

What did you expect to happen?

No no-empty-function warnings.

What actually happened? Please include the actual, raw output from ESLint.

Unexpected empty async method 'method'. (no-empty-function)

Are you willing to submit a pull request to fix this bug?

Yes

@EvgenyOrekhov EvgenyOrekhov added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Jan 10, 2020
@EvgenyOrekhov
Copy link
Author

ESLint demo

@EvgenyOrekhov
Copy link
Author

I can see in the source code that there is actually some code for handling async methods and functions. But it's basically dead code now. I guess one of the possible solutions would be to extend the ALLOW_OPTIONS array to include "asyncFunctions" and "asyncMethods". That way it would be an enhancement, I guess.

@kaicataldo
Copy link
Member

Verified using our demo.

Given that we have a separate option for "generatorFunctions" and "generatorMethods", I personally think it makes sense to add "asyncFunctions" and "asyncMethods" as an option.

I'm not sure whether to mark this as a bug or an enhancement, since adding new options is an enhancement, but given the lack of these options, I think this should also be classified as a bug. 🤷‍♂

Either way, I support solving this by adding "allow": "asyncFunctions|asyncMethods" options. Let' see what the rest of the team has to say.

@kaicataldo kaicataldo added accepted There is consensus among the team that this change meets the criteria for inclusion enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon accepted There is consensus among the team that this change meets the criteria for inclusion labels Jan 10, 2020
@mdjermanovic
Copy link
Member

I also think this should be fixed in some way. There are also async arrow functions.

By the current implementation, it seems that async generator functions and async generator methods would be treated as just generator functions/generator methods? Looks like there could be an exponential growth of options if something new appears.

@eslint-deprecated eslint-deprecated bot added the auto closed The bot closed this issue label Feb 11, 2020
@eslint-deprecated
Copy link

Unfortunately, it looks like there wasn't enough interest from the team
or community to implement this change. While we wish we'd be able to
accommodate everyone's requests, we do need to prioritize. We've found
that issues failing to reach accepted status after 21 days tend to
never be accepted, and as such, we close those issues.
This doesn't mean the idea isn't interesting or useful, just that it's
not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

@kaicataldo kaicataldo added accepted There is consensus among the team that this change meets the criteria for inclusion and removed auto closed The bot closed this issue evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Feb 11, 2020
@kaicataldo
Copy link
Member

On thinking about this more, this seems like a clear case of an unintentionally missing feature (it was probably implemented before async functions were added to the language). The rule definitely doesn't feel complete without it, so I'm marking as accepted. If anyone from the team disagrees, please let me know!

@kaicataldo kaicataldo reopened this Feb 11, 2020
kaicataldo pushed a commit that referenced this issue Mar 20, 2020
…13036)

* Fix: added async in allow method in no-empty-function

* Chore: added tests for async* allow

* Docs: updated docs for async method and funct

* Chore: more tests and test fixes and docs refactore

* Update docs/rules/no-empty-function.md

Co-Authored-By: YeonJuan <yeonjuan93@naver.com>

* Update docs/rules/no-empty-function.md

Co-Authored-By: YeonJuan <yeonjuan93@naver.com>

* Update docs/rules/no-empty-function.md

Co-Authored-By: YeonJuan <yeonjuan93@naver.com>

* Docs: fixed the ecma version for docs snippet

Co-authored-by: YeonJuan <yeonjuan93@naver.com>
anikethsaha added a commit to anikethsaha/eslint that referenced this issue Mar 23, 2020
…2768) (eslint#13036)

* Fix: added async in allow method in no-empty-function

* Chore: added tests for async* allow

* Docs: updated docs for async method and funct

* Chore: more tests and test fixes and docs refactore

* Update docs/rules/no-empty-function.md

Co-Authored-By: YeonJuan <yeonjuan93@naver.com>

* Update docs/rules/no-empty-function.md

Co-Authored-By: YeonJuan <yeonjuan93@naver.com>

* Update docs/rules/no-empty-function.md

Co-Authored-By: YeonJuan <yeonjuan93@naver.com>

* Docs: fixed the ecma version for docs snippet

Co-authored-by: YeonJuan <yeonjuan93@naver.com>
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Sep 18, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Sep 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants