From 4a352a957ba9e721bec9f6f403b419a22b0ec423 Mon Sep 17 00:00:00 2001 From: Marcus Wyatt Date: Mon, 24 Apr 2023 14:56:37 -0400 Subject: [PATCH] docs: explain how to include predefined globals (#17114) * docs: explain how to include native globals * docs: line break * docs: explicitly state why `globals` is necessary * docs: link to `globals` package Co-authored-by: Francesco Trotta --------- Co-authored-by: Francesco Trotta --- .../use/configure/configuration-files-new.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/src/use/configure/configuration-files-new.md b/docs/src/use/configure/configuration-files-new.md index e153d9af5a0..ac9a54c374a 100644 --- a/docs/src/use/configure/configuration-files-new.md +++ b/docs/src/use/configure/configuration-files-new.md @@ -328,6 +328,24 @@ 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. +##### 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`](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"; + +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.