Rule suggestion: symbol-description
See original GitHub issue(bug report template was previously here. It was removed)
I suggest new rule: symbol-description
with options always
and never
: It should check if all (or neither of) symbols created in code have the description as described in the Spec: 19.4.1.1 Symbol ( [ description ] )
Rationale: symbol description is optional but it facilitates debugging because Symbol#toString returns a descriptive string containing symbol description so it’s worth enforcing.
When does this rule warn? Please describe and show example code:
The rule as briefly described above has 2 settings: always
and never
With always
setting it should warn if the following code is detected:
Symbol();
With never
setting it should warn if the following code is detected:
Symbol('any strng');
Symbol(anyVariable);
EDIT:
As @nzakas asked me to do I’m updating the request with the rule proposal template:
Is this rule preventing an error or is it stylistic?
The rule neither prevents an error nor is stylistic. I’d say it belongs either to “Best Practices” or to “ECMAScript 6” groups.
Why is this rule a candidate for inclusion instead of creating a custom rule?
It covers one of the new language features. If it’s in the core people may adopt good practice of describing symbols used in their code by analysing the rules list and finding this one.
Are you willing to create the rule yourself?
Yes, but I never implemented eslint rule so I’m going to need some help.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:12 (12 by maintainers)
Top GitHub Comments
@jrencz please read over our guidelines for submitting rule proposals and update your description to match the format.
In general I like the idea, but I’d like to see a proper proposal before evaluating.
Agreed, I don’t think “never” is necessary.
I’m 👍