10000 docs: update getting-started config to match default generated config… · eslint/eslint@17f2aae · GitHub
[go: up one dir, main page]

Skip to content

Commit 17f2aae

Browse files
authored
docs: update getting-started config to match default generated config (#19308)
* Docs: Update getting-started config example to match CLI output (#19283) Updated the config example to make it almost match with default config . * fix: correct punctuation and spacing issues * style: fixed spacing * fixed formatting * fix: improve clarity in getting-started documentation * fix: punctuation errors * chore: replace js with pluginJs Replaced all instance of js to pluginJs in the config. * feat: brief into to add rules in config file * fix: CI errors * chore: reword for better clarity * chore: remove unneccesary indentation
1 parent aae6717 commit 17f2aae

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

docs/src/use/getting-started.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,36 +51,31 @@ After that, you can run ESLint on any file or directory like this:
5151

5252
**Note:** If you are coming from a version before 9.0.0 please see the [migration guide](configure/migration-guide).
5353

54-
After running `npm init @eslint/config`, you'll have an `eslint.config.js` (or `eslint.config.mjs`) file in your directory. In it, you'll see some rules configured like this:
54+
When you run `npm init @eslint/config`, you'll be asked a series of questions to determine how you're using ESLint and what options should be included. After answering these questions, you'll have an `eslint.config.js` (or `eslint.config.mjs`) file created in your directory.
55+
56+
For example, one of the questions is "Where does your code run?" If you select "Browser" then your configuration file will contain the definitions for global variables found in web browsers. Here's an example:
5557

5658
```js
57-
// eslint.config.js
59+
import globals from "globals";
60+
import pluginJs from "@eslint/js";
61+
62+
63+
/** @type {import('eslint').Linter.Config[]} */
5864
export default [
59-
{
60-
rules: {
61-
"no-unused-vars": "error",
62-
"no-undef": "error"
63-
}
64-
}
65+
{languageOptions: { globals: globals.browser }},
66+
pluginJs.configs.recommended,
6567
];
6668
```
6769

68-
The names `"no-unused-vars"` and `"no-undef"` are the names of [rules](../rules) in ESLint. The first value is the error level of the rule and can be one of these values:
69-
70-
* `"off"` or `0` - turn the rule off
71-
* `"warn"` or `1` - turn the rule on as a warning (doesn't affect exit code)
72-
* `"error"` or `2` - turn the rule on as an error (exit code will be 1)
73-
74-
The three error levels allow you fine-grained control over how ESLint applies rules (for more configuration options and details, see the [configuration docs](configure/)).
70+
The `pluginJs.configs.recommended` object contains configuration to ensure that all of the rules marked as recommended on the [rules page](../rules) will be turned on. Alternatively, you can use configurations that others have created by searching for "eslint-config" on [npmjs.com](https://www.npmjs.com/search?q=eslint-config). ESLint will not lint your code unless you extend from a shared configuration or explicitly turn rules on in your configuration.
7571

76-
Your `eslint.config.js` configuration file will also include a recommended configuration, like this:
72+
You can configure rules individually by defining a new object with a `rules` key, as in this example:
7773

7874
```js
79-
// eslint.config.js
80-
import js from "@eslint/js";
75+
import pluginJs from "@eslint/js";
8176

8277
export default [
83-
js.configs.recommended,
78+
pluginJs.configs.recommended,
8479

8580
{
8681
rules: {
@@ -91,7 +86,13 @@ export default [
9186
];
9287
```
9388

94-
The `js.configs.recommended` object contains configuration to ensure that all of the rules marked as recommended on the [rules page](../rules) will be turned on. Alternatively, you can use configurations that others have created by searching for "eslint-config" on [npmjs.com](https://www.npmjs.com/search?q=eslint-config). ESLint will not lint your code unless you extend from a shared configuration or explicitly turn rules on in your configuration.
89+
The names `"no-unused-vars"` and `"no-undef"` are the names of [rules](../rules) in ESLint. The first value is the error level of the rule and can be one of these values:
90+
91+
* "off" or 0 - turn the rule off
92+
* "warn" or 1 - turn the rule on as a warning (doesn’t affect exit code)
93+
* "error" or 2 - turn the rule on as an error (exit code will be 1)
94+
95+
The three error levels allow you fine-grained control over how ESLint applies rules (for more configuration options and details, see the configuration docs).
9596

9697
## Global Install
9798

@@ -121,10 +122,10 @@ Before you begin, you must already have a `package.json` file. If you don't, mak
121122
1. Add configuration to the `eslint.config.js` file. Refer to the [Configure ESLint document 736A ation](configure/) to learn how to add rules, custom configurations, plugins, and more.
122123

123124
```js
124-
import js from "@eslint/js";
125+
import pluginJs from "@eslint/js";
125126

126127
export default [
127-
js.configs.recommended,
128+
pluginJs.configs.recommended,
128129

129130
{
130131
rules: {

0 commit comments

Comments
 (0)
0