You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/user-guide/configuring/language-options.md
+12-12Lines changed: 12 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,8 @@ eleventyNavigation:
8
8
9
9
---
10
10
11
+
The JavaScript ecosystem has a variety of runtimes, versions, extensions, and frameworks. Each of these can have different supported syntax and global variables. ESLint lets you configure language options specific to the JavaScript used in your project, like custom global variables. You can also use plugins to extend ESLint to support your project's language options.
12
+
11
13
## Specifying Environments
12
14
13
15
An environment provides predefined global variables. The available environments are:
@@ -51,7 +53,7 @@ Environments can be specified inside of a file, in configuration files or using
51
53
52
54
### Using configuration comments
53
55
54
-
To specify environments using a comment inside of your JavaScript file, use the following format:
56
+
To specify environments with a comment inside of a JavaScript file, use the following format:
55
57
56
58
```js
57
59
/* eslint-env node, mocha */
@@ -61,7 +63,7 @@ This enables Node.js and Mocha environments.
61
63
62
64
### Using configuration files
63
65
64
-
To specify environments in a configuration file, use the `env` key and specify which environments you want to enable by setting each to `true`. For example, the following enables the browser and Node.js environments:
66
+
To specify environments in a configuration file, use the `env` key. Specify which environments you want to enable by setting each to `true`. For example, the following enables the browser and Node.js environments:
65
67
66
68
```json
67
69
{
@@ -166,7 +168,7 @@ And in YAML:
166
168
167
169
These examples allow `var1` to be overwritten in your code, but disallow it for `var2`.
168
170
169
-
Globals can be disabled with the string `"off"`. For example, in an environment where most ES2015 globals are available but `Promise` is unavailable, you might use this config:
171
+
Globals can be disabled by setting their value to `"off"`. For example, in an environment where most ES2015 globals are available but `Promise` is unavailable, you might use this config:
170
172
171
173
```json
172
174
{
@@ -179,21 +181,19 @@ Globals can be disabled with the string `"off"`. For example, in an environment
179
181
}
180
182
```
181
183
182
-
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.
184
+
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 these older values is deprecated.
183
185
184
186
## Specifying Parser Options
185
187
186
-
ESLint allows you to specify the JavaScript language options you want to support. By default, ESLint expects ECMAScript 5 syntax. You can override that setting to enable support for other ECMAScript versions as well as JSX by using parser options.
188
+
ESLint allows you to specify the JavaScript language options you want to support. By default, ESLint expects ECMAScript 5 syntax. You can override that setting to enable support for other ECMAScript versions and JSX using parser options.
189
+
190
+
Please note that supporting JSX syntax is not the same as supporting React. React applies specific semantics to JSX syntax that ESLint doesn't recognize. We recommend using [eslint-plugin-react](https://github.com/yannickcr/eslint-plugin-react) if you are using React.
187
191
188
-
Please note that supporting JSX syntax is not the same as supporting React. React applies specific semantics to JSX syntax that ESLint doesn't recognize. We recommend using [eslint-plugin-react](https://github.com/yannickcr/eslint-plugin-react) if you are using React and want React semantics.
189
-
By the same token, supporting ES6 syntax is not the same as supporting new ES6 globals (e.g., new types such as
190
-
`Set`).
191
-
For ES6 syntax, use `{ "parserOptions": { "ecmaVersion": 6 } }`; for new ES6 global variables, use `{ "env":
192
-
{ "es6": true } }`. `{ "env": { "es6": true } }` enables ES6 syntax automatically, but `{ "parserOptions": { "ecmaVersion": 6 } }` does not enable ES6 globals automatically.
192
+
By the same token, supporting ES6 syntax is not the same as supporting new ES6 globals (e.g., new types such as `Set`). For ES6 syntax, use `{ "parserOptions": { "ecmaVersion": 6 } }`; for new ES6 global variables, use `{ "env": { "es6": true } }`. Setting `{ "env": { "es6": true } }` enables ES6 syntax automatically, but `{ "parserOptions": { "ecmaVersion": 6 } }` does not enable ES6 globals automatically.
193
193
194
-
Parser options are set in your `.eslintrc.*` file by using the `parserOptions` property. The available options are:
194
+
Parser options are set in your `.eslintrc.*` file with the `parserOptions` property. The available options are:
195
195
196
-
* `ecmaVersion` - set to 3, 5 (default), 6, 7, 8, 9, 10, 11, 12, 13, or 14 to specify the version of ECMAScript syntax you want to use. You can also set to 2015 (same as 6), 2016 (same as 7), 2017 (same as 8), 2018 (same as 9), 2019 (same as 10), 2020 (same as 11), 2021 (same as 12), 2022 (same as 13), or 2023 (same as 14) to use the year-based naming. You can also set "latest" to use the most recently supported version.
196
+
* `ecmaVersion` - set to 3, 5 (default), 6, 7, 8, 9, 10, 11, 12, 13, or 14 to specify the version of ECMAScript syntax you want to use. You can also set it to 2015 (same as 6), 2016 (same as 7), 2017 (same as 8), 2018 (same as 9), 2019 (same as 10), 2020 (same as 11), 2021 (same as 12), 2022 (same as 13), or 2023 (same as 14) to use the year-based naming. You can also set `"latest"` to use the most recently supported version.
197
197
* `sourceType` - set to `"script"` (default) or `"module"` if your code is in ECMAScript modules.
198
198
* `allowReserved` - allow the use of reserved words as identifiers (if `ecmaVersion` is 3).
199
199
* `ecmaFeatures` - an object indicating which additional language features you'd like to use:
0 commit comments