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
Incorrect documentation for func-style #12900
Comments
I can't reproduce this: Both examples are lint-free when run in the demo. It might help to fill in the issue template and share your ESLint version. Also, please let me know if something is wrong with my demo example. Thanks! |
Hi @revolter, thanks for the issue! I can confirm that the example is actually correct. The
"honoured only when using declaration" applies to the option, and means that this option changes the behavior of this rule only if the main string option is I agree that this sentence can be misinterpreted. A PR to improve the documentation is welcome! |
Should we disallow the |
@revolter just to confirm that we understand this bug report: /*eslint func-style: ["error", "expression"]*/
var foo = () => {}; You think that |
Someone might also expect that Would it be a breaking change to remove a misleading option that doesn't affect the behavior? |
Documentation for the The option disallows only function expressions/arrow functions used to initialize a variable. It also never disallows arrow functions that use /*eslint func-style: ["error", "declaration", { "allowArrowFunctions": false }]*/
var foo = function () {}; // error
var bar = () => {}; // error
arr.map(function() {}); // ok
arr.map(() => {}); // ok
var baz = () => this.something; // ok |
Yes. |
Thanks! The example is correct and the rule is in sync with the example. That's indeed the intended behavior. If the main string option is set to (even if I agree that the following can be easily misinterpreted:
PR to clarify this option in the documentation is welcome! |
I think |
…2900) (eslint#13004) * Docs: added less confusing explanation for func-style * Docs: updated func-style allowArrowFunctions info
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using?
Please show your full configuration:
Configuration
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
What did you expect to happen?
The correct code example for the configuration
/*eslint func-style: ["error", "expression"]*/
shouldn't have an arrow function, as they're disallowed by default.https://eslint.org/docs/rules/func-style#expression
What actually happened? Please include the actual, raw output from ESLint.
Are you willing to submit a pull request to fix this bug?
Maybe.
The text was updated successfully, but these errors were encountered: