1) The lint name suggests that it is about the style of all functions but this is not the case. Based on the name, my initial expectation was that the lint is about the choice between function and arrow functions. That is kinda close but not quite right, and the docs do not anticipate this misconception.
1) The docs use the term "function expression" to mean "function expression assigned to a variable". This is incorrect and further contributes to the misconception above.
What do you think is the correct solution?
Do not use the term "function expression" to mean "function expression assigned to a variable". That is incorrect and confusing. In const x = () => {}, only the () => {} part is a function expression. As a reference, see the Functions MDN page.
For instance, I would change the summary line to
- Enforce the consistent use of either function declarations or expressions
+ Enforce the consistent use of either function declarations or expressions assigned to variables
Maybe explicitly state that the lint does not apply to callback functions.
Participation
[X] I am willing to submit a pull request for this change.
Additional comments
I admit the phrase "function expression assigned to a variable" is verbose. But brevity at the cost of technical correctness is not a good trade. It confused me and I doubt I'm the only one.
Docs page(s)
https://eslint.org/docs/latest/rules/func-style
What documentation issue do you want to solve?
1) The lint name suggests that it is about the style of all functions but this is not the case. Based on the name, my initial expectation was that the lint is about the choice between
function
and arrow functions. That is kinda close but not quite right, and the docs do not anticipate this misconception. 1) The docs use the term "function expression" to mean "function expression assigned to a variable". This is incorrect and further contributes to the misconception above.What do you think is the correct solution?
Do not use the term "function expression" to mean "function expression assigned to a variable". That is incorrect and confusing. In
const x = () => {}
, only the() => {}
part is a function expression. As a reference, see the Functions MDN page.For instance, I would change the summary line to
Maybe explicitly state that the lint does not apply to callback functions.
Participation
Additional comments
I admit the phrase "function expression assigned to a variable" is verbose. But brevity at the cost of technical correctness is not a good trade. It confused me and I doubt I'm the only one.