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
Conversation
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.
@@ -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: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
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. |
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 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. |
@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)? |
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. |
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 SummaryThis 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 TSC Question
|
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.) |
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. |
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! |
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