Docs: add class fields in func-names documentation (refs #14857) #14908
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[x] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
refs #14857, fixes #14591 (comment)
What changes did you make? (Give an overview)
Updated documentation for the
func-names
rule to clarify thatas-needed
logic isn't tied to ES6, and added examples with class fields and logical assignment operators.Is there anything you'd like reviewers to focus on?
I believe the reason to specify ES6 was an expectation that future specifications might add more cases where the name is automatically assigned, e.g.
a.b = function() {}
, in which case the rule would become unpredictable for users and difficult to maintain (whether or not the name will be automatically assigned for the same syntax would depend on the targeted environment). However, that never happened, except for the cases with new syntax, so I think it's safe to say "per the ECMAScript specification" instead of "in an ES6 environment".