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

Docs: Fixes incorrect example #11331

Closed
wants to merge 3 commits into from
Closed

Docs: Fixes incorrect example #11331

wants to merge 3 commits into from

Conversation

vermiceli
Copy link
Contributor

This commit also updates the documentation for the parameters to
include the fact that the first parameter is the rule setting and not a
global to be restricted.

What is the purpose of this pull request? (put an "X" next to 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:

What changes did you make? (Give an overview)
I've fixed an incorrect example in the documentation and clarified an incorrect sentence in the parameter explanation.

Is there anything you'd like reviewers to focus on?
no

This commit also updates the documentation for the parameters to
include the fact that the first parameter is the rule setting and not a
global to be restricted.
@jsf-clabot
Copy link

jsf-clabot commented Jan 29, 2019

CLA assistant check
All committers have signed the CLA.

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Jan 29, 2019
@@ -13,7 +13,7 @@ This rule allows you to specify global variable names that you don't want to use

## Options

This rule takes a list of strings, where each string is a global to be restricted:
This rule takes a list of strings. The first string is the rule setting, such as "off", "warn", or "error". Each string after the rule setting is a global to be restricted:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The usage of options was documented here: https://eslint.org/docs/user-guide/configuring#configuring-rules. is there something worth to be added in that part?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although it is defined somewhere else, the original sentence is factually incorrect. Furthermore, if a developer doesn't read the page you linked, they will not realize that 'error' is not just a global.

We should be clear in the documentation so that developers won't get confused. What advantage is there in leaving the documentation incorrect?

@aladdin-add aladdin-add added enhancement This change enhances an existing feature of ESLint documentation Relates to ESLint's documentation 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 Jan 30, 2019
@ilyavolodin
Copy link
Member

Hmm.. This is a strange case. On one hand, your change makes it clearer to understand that rule takes a flat array of options, and the first one is control option. On the other hand, we always assume that it's clear that first item in the config array is always control option, and we never mention it in any other rule documentation.
In all honesty, I think I would much more prefer to change configuration for this rule to accept an array of strings as a second item. I.e. ["off", ["string1", "string2", ...]]. We would need to make it backwards compatible, so that it wouldn't be a breaking change, but I think a flat array is just confusing.

@vermiceli
Copy link
Contributor Author

Hmm.. This is a strange case. On one hand, your change makes it clearer to understand that rule takes a flat array of options, and the first one is control option. On the other hand, we always assume that it's clear that first item in the config array is always control option, and we never mention it in any other rule documentation.
In all honesty, I think I would much more prefer to change configuration for this rule to accept an array of strings as a second item. I.e. ["off", ["string1", "string2", ...]]. We would need to make it backwards compatible, so that it wouldn't be a breaking change, but I think a flat array is just confusing.

I agree with you that a single flat list is not the best design choice. When I made this pull request, I didn't realize this documentation oversight was pervasive across all documentation.

The reason I created this pull request is I was using a project that enabled eslint by default that had no-restricted-globals-update warnings. I simply found the docs for the rule and only read that page's documentation, which led me to think error was a global method/variable to ignore, which wasn't the case.

I think when writing documentation, we have to assume not everyone is going to start from the beginning. We should be as helpful as possible, which will make beginners starting with eslint have an easier time onboarding.

@ilyavolodin
Copy link
Member

@eslint/eslint-team What do you think? Should we merge this as a one-off, or should we update documentation everywhere (or leave everything as is)?

@platinumazure
Copy link
Member

I'd be okay with a one-off if it avoids confusion for this rule (which takes a variadic list of options); but I also think we should change our rule doc template to have a small sidebar reminding about rule configuration, maybe something that could be toggled to expand so it's not in users' way if they already know about the commonalities in rule configuration.

@mysticatea mysticatea removed the enhancement This change enhances an existing feature of ESLint label Mar 30, 2019
@platinumazure platinumazure added the tsc agenda This issue will be discussed by ESLint's TSC at the next meeting label Jun 8, 2019
@platinumazure
Copy link
Member

I'm going to add this to the TSC agenda to get visibility into the discussion (and ensure the TSC has a chance to consider the information architecture implications across the whole project).

TSC Summary

This PR was created due to confusion around the intersection of (1) how ESLint rule options work generally, and (2) the specific option schema for this rule, which is a variadic list that comes after the severity. This lead to user confusion (about whether "error" was a restricted global vs a severity). This PR definitely makes the documentation for this rule more clear, but there's a concern about whether this sets a precedent (i.e., whether we also need to update all rule docs to remind users about the severity option).

TSC Question

  1. Should we accept this PR?
  2. Should we establish a working group, or otherwise take on a task to improve information architecture around rule severity as part of (yet distinct from) rule options?

@not-an-aardvark
Copy link
Member

In the June 20th TSC meeting, the TSC decided that we don't want to have one-off explanations like this on individual rule pages -- if we want to make things more clear it would be better to have a blurb in the rule page template that automatically gets added for every rule. (Sorry about the delay in reporting the decision back on this issue.)

@not-an-aardvark not-an-aardvark removed the tsc agenda This issue will be discussed by ESLint's TSC at the next meeting label Aug 1, 2019
@vermiceli
Copy link
Contributor Author

I disagree with this result, but it's not my place. If the documentation template can be implemented to make rules more clear, I suppose it's an ok compromise.

Meanwhile, I made another pull request #12045 that contains the non-contentious code change to correct the incorrect parameter, which I believe shows that even an experienced eslint developer gets the rule setting and the globals confused due to their similarity.

@ilyavolodin
Copy link
Member

Closing this PR based on the TSC decision. A smaller change was already merged in, and we want to fix this issue in a broader way through documentation template or other means. Thanks for PR!

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Apr 23, 2020
@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 Apr 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion documentation Relates to ESLint's documentation evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants