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
the rule func-names
should behave differently depending on parser options
#8761
Comments
Thanks for the proposal. I'm not sure it's a good idea to make rule behavior depend on the parser options -- we have done this a little bit in the past, and it has caused issues like #8744 (comment) for other parsers. If we do add this functionality, I think it would be better to make it a new rule option. |
Thanks for your reply. I have looked into that issue. As I understand it, the real problem is not about the idea of rules behaving differently when having a different ecmaVersion, but about ESLint should accept parser options supplied by third-party parsers (such as |
To be more precise, parser options are options that can be provided by the user to configure the behavior of a parser. The This means that a user could be writing ES6 code without the In other words, the |
I see. Then what about asking custom parser to provide ESLint with in what |
Unfortunately that wouldn't solve the problem. First, some parsers support experimental features, or they might only support some features of a particular ECMAScript version but not other features. In this particular case, there is a larger issue: |
You're right. Thanks for your patience! |
What you did?
ESLint config:
The code:
What you would like to happen?
With
parserOptions.ecmaVersion
set to5
or below, the optionas-needed
for rulefunc-names
should behave the same asalways
, since older versions of ECMAScript won't automatically infername
for anonymous functions. Soas-needed
here means you always need to specify the name explicitly.In other cases (
parserOptions.ecmaVersion >= 6
), the behavior of optionas-needed
should maintain status quo.What actually happened?
ESLint was considering
func
had an inferredname
and therefore complained nothing.The text was updated successfully, but these errors were encountered: