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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/rules/no-restricted-globals.md
Expand Up @@ -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?


```json
{
Expand Down Expand Up @@ -77,7 +77,7 @@ Examples of **incorrect** code for a sample `"event"` global variable name, alon

```js
/*global event*/
/* eslint no-restricted-globals: ["error", { name: "error", message: "Use local parameter instead." }] */
/* eslint no-restricted-globals: ["error", { name: "event", message: "Use local parameter instead." }] */

function onClick() {
console.log(event); // Unexpected global variable 'event'. Use local parameter instead.
Expand Down