From 0ddcfca3a19758178c1577b0c566dec54c0a24da Mon Sep 17 00:00:00 2001 From: Marcus Wyatt Date: Mon, 24 Apr 2023 05:46:51 -0700 Subject: [PATCH 1/4] docs: explain how to include native globals --- .../use/configure/configuration-files-new.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/src/use/configure/configuration-files-new.md b/docs/src/use/configure/configuration-files-new.md index e153d9af5a0..fcde3d6354c 100644 --- a/docs/src/use/configure/configuration-files-new.md +++ b/docs/src/use/configure/configuration-files-new.md @@ -328,6 +328,23 @@ export default [ For historical reasons, the boolean value `false` and the string value `"readable"` are equivalent to `"readonly"`. Similarly, the boolean value `true` and the string value `"writeable"` are equivalent to `"writable"`. However, the use of older values is deprecated. +#### Using native globals variables + +To enable native variables, like `console` (browser) or `$` (jQuery), you must use the `globals` package directly. For example, here is how you can add `console`, amongst other browser globals, into your configuration. + +```js +import globals from "globals"; +export default [ + { + languageOptions: { + globals: { + ...globals.browser, + } + } + } +]; +``` + ### Using plugins in your configuration Plugins are used to share rules, processors, configurations, parsers, and more across ESLint projects. From 0af67d3db0ce9b0cdc2c7c73e5783351bdce06cd Mon Sep 17 00:00:00 2001 From: Marcus Wyatt Date: Mon, 24 Apr 2023 06:06:58 -0700 Subject: [PATCH 2/4] docs: line break --- docs/src/use/configure/configuration-files-new.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/src/use/configure/configuration-files-new.md b/docs/src/use/configure/configuration-files-new.md index fcde3d6354c..33a543b9450 100644 --- a/docs/src/use/configure/configuration-files-new.md +++ b/docs/src/use/configure/configuration-files-new.md @@ -334,6 +334,7 @@ To enable native variables, like `console` (browser) or `$` (jQuery), you must u ```js import globals from "globals"; + export default [ { languageOptions: { From 628f76c770d4e7e0c5909dc867005083e19bef68 Mon Sep 17 00:00:00 2001 From: Marcus Wyatt Date: Mon, 24 Apr 2023 07:45:15 -0700 Subject: [PATCH 3/4] docs: explicitly state why `globals` is necessary --- docs/src/use/configure/configuration-files-new.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/src/use/configure/configuration-files-new.md b/docs/src/use/configure/configuration-files-new.md index 33a543b9450..67eacb9e731 100644 --- a/docs/src/use/configure/configuration-files-new.md +++ b/docs/src/use/configure/configuration-files-new.md @@ -328,9 +328,9 @@ export default [ For historical reasons, the boolean value `false` and the string value `"readable"` are equivalent to `"readonly"`. Similarly, the boolean value `true` and the string value `"writeable"` are equivalent to `"writable"`. However, the use of older values is deprecated. -#### Using native globals variables +##### Predefined global variables -To enable native variables, like `console` (browser) or `$` (jQuery), you must use the `globals` package directly. For example, here is how you can add `console`, amongst other browser globals, into your configuration. +Apart from the ECMAScript standard built-in globals, which are automatically enabled based on the configured `languageOptions.ecmaVersion`, ESLint doesn't provide predefined sets of global variables. You can use the `globals` package to additionally enable all globals for a specific environment. For example, here is how you can add `console`, amongst other browser globals, into your configuration. ```js import globals from "globals"; @@ -339,7 +339,7 @@ export default [ { languageOptions: { globals: { - ...globals.browser, + ...globals.browser } } } From 3186a2fe4d638a48672a2fe860ffa618139b3cfd Mon Sep 17 00:00:00 2001 From: Marcus Wyatt Date: Mon, 24 Apr 2023 08:02:51 -0700 Subject: [PATCH 4/4] docs: link to `globals` package Co-authored-by: Francesco Trotta --- docs/src/use/configure/configuration-files-new.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/use/configure/configuration-files-new.md b/docs/src/use/configure/configuration-files-new.md index 67eacb9e731..ac9a54c374a 100644 --- a/docs/src/use/configure/configuration-files-new.md +++ b/docs/src/use/configure/configuration-files-new.md @@ -330,7 +330,7 @@ For historical reasons, the boolean value `false` and the string value `"readabl ##### Predefined global variables -Apart from the ECMAScript standard built-in globals, which are automatically enabled based on the configured `languageOptions.ecmaVersion`, ESLint doesn't provide predefined sets of global variables. You can use the `globals` package to additionally enable all globals for a specific environment. For example, here is how you can add `console`, amongst other browser globals, into your configuration. +Apart from the ECMAScript standard built-in globals, which are automatically enabled based on the configured `languageOptions.ecmaVersion`, ESLint doesn't provide predefined sets of global variables. You can use the [`globals`](https://www.npmjs.com/package/globals) package to additionally enable all globals for a specific environment. For example, here is how you can add `console`, amongst other browser globals, into your configuration. ```js import globals from "globals";