Skip to content
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

Rule suggestion: symbol-description #6778

Closed
jrencz opened this issue Jul 27, 2016 · 12 comments
Closed

Rule suggestion: symbol-description #6778

jrencz opened this issue Jul 27, 2016 · 12 comments
Assignees
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion feature This change adds a new feature to ESLint rule Relates to ESLint's core rules

Comments

@jrencz
Copy link
Contributor

jrencz commented Jul 27, 2016

(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.

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Jul 27, 2016
@alberto alberto added rule Relates to ESLint's core rules feature This change adds a new feature to ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Jul 27, 2016
@mysticatea
Copy link
Member

Thank you for this issue.

I like this idea 👍.

@platinumazure
Copy link
Member

My only question is whether this is important enough to meet our new rule criteria. If not, I could see a use for a symbol-themed plugin.

Not sure if I want to endorse just yet, but I'm not doing thumbs-down either.

@nzakas
Copy link
Member

nzakas commented Aug 1, 2016

@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.

@jrencz
Copy link
Contributor Author

jrencz commented Aug 1, 2016

@nzakas I updated the description

@platinumazure
Copy link
Member

platinumazure commented Aug 1, 2016

Now I understand what users need to do to conform to the rule (seems reasonable for symbols to have a description). I'll champion.

@jrencz If this issue is accepted, we will look to you to implement. If you need/want any help, you can talk to the champion of the rule you are trying to add (which would be me in this case). Of course, you can always stop by the Gitter chat if you want real-time help from anyone who might be online. Thanks for the proposal!

@platinumazure platinumazure self-assigned this Aug 1, 2016
jrencz added a commit to jrencz/eslint that referenced this issue Aug 1, 2016
@jrencz
Copy link
Contributor Author

jrencz commented Aug 1, 2016

@platinumazure I made some quick and dirty attempt to implement the rule as described: https://github.com/jrencz/eslint/tree/symbol-description

Should I file a PR as-is (with no documentation) or should I better prepare some docs first?

@platinumazure
Copy link
Member

@jrencz Definitely add docs before submitting a PR 😄 But if you would like, I am happy to take a look at your WIP branch.

@jrencz
Copy link
Contributor Author

jrencz commented Aug 1, 2016

@platinumazure I'd appreciate. I'll add documentation tomorrow.

I based my code on rules radix and no-new-symbol

@vitorbal
Copy link
Member

vitorbal commented Aug 1, 2016

I am 👍 for this rule proposal.

@mysticatea
Copy link
Member

I'm not sure if we need thenever option. I think no option is more simple.
That implementation looks good to me 😉

jrencz added a commit to jrencz/eslint that referenced this issue Aug 2, 2016
jrencz added a commit to jrencz/eslint that referenced this issue Aug 2, 2016
@vitorbal
Copy link
Member

vitorbal commented Aug 2, 2016

@mysticatea agreed, I don't think the never option is of much use. Wanted to voice the same opinion but you beat me to it 😄

@nzakas
Copy link
Member

nzakas commented Aug 2, 2016

Agreed, I don't think "never" is necessary.

I'm 👍

@nzakas nzakas added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Aug 2, 2016
jrencz added a commit to jrencz/eslint that referenced this issue Aug 19, 2016
jrencz added a commit to jrencz/eslint that referenced this issue Aug 19, 2016
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion feature This change adds a new feature to ESLint rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

7 participants