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
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
Copy file name to clipboardExpand all lines: docs/src/use/getting-started.md
+23-22Lines changed: 23 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -51,36 +51,31 @@ After that, you can run ESLint on any file or directory like this:
51
51
52
52
**Note:** If you are coming from a version before 9.0.0 please see the [migration guide](configure/migration-guide).
53
53
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:
55
57
56
58
```js
57
-
// eslint.config.js
59
+
importglobalsfrom"globals";
60
+
importpluginJsfrom"@eslint/js";
61
+
62
+
63
+
/**@type{import('eslint').Linter.Config[]}*/
58
64
exportdefault [
59
-
{
60
-
rules: {
61
-
"no-unused-vars":"error",
62
-
"no-undef":"error"
63
-
}
64
-
}
65
+
{languageOptions: { globals:globals.browser }},
66
+
pluginJs.configs.recommended,
65
67
];
66
68
```
67
69
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.
75
71
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:
77
73
78
74
```js
79
-
// eslint.config.js
80
-
importjsfrom"@eslint/js";
75
+
importpluginJsfrom"@eslint/js";
81
76
82
77
exportdefault [
83
-
js.configs.recommended,
78
+
pluginJs.configs.recommended,
84
79
85
80
{
86
81
rules: {
@@ -91,7 +86,13 @@ export default [
91
86
];
92
87
```
93
88
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).
95
96
96
97
## Global Install
97
98
@@ -121,10 +122,10 @@ Before you begin, you must already have a `package.json` file. If you don't, mak
121
122
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.
0 commit comments