Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit94178ad

Browse files
antfunzakasTanujkanti4441mdjermanovic
authored
docs: mention aboutname field in flat config (#18252)
* docs: mention about `name` field in flat config* Update docs/src/use/configure/configuration-files.mdCo-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com>* Update docs/src/use/configure/configuration-files.mdCo-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com>* Update docs/src/use/configure/configuration-files.md* chore: update examples* Update docs/src/use/configure/configuration-files.mdCo-authored-by: Tanuj Kanti <86398394+Tanujkanti4441@users.noreply.github.com>* Update configuration-files.mdCo-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com>* Update docs/src/use/configure/configuration-files.mdCo-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>* docs: update convention about uniqueness* docs: wording* Apply suggestions from code reviewCo-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com>---------Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com>Co-authored-by: Tanuj Kanti <86398394+Tanujkanti4441@users.noreply.github.com>Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
1 parent1765c24 commit94178ad

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

‎docs/src/use/configure/configuration-files.md‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ module.exports = [
5656

5757
Each configuration object contains all of the information ESLint needs to execute on a set of files. Each configuration object is made up of these properties:
5858

59+
*`name` - A name for the configuration object. This is used in error messages and config inspector to help identify which configuration object is being used. ([Naming Convention](#configuration-naming-conventions))
5960
*`files` - An array of glob patterns indicating the files that the configuration object should apply to. If not specified, the configuration object applies to all files matched by any other configuration object.
6061
*`ignores` - An array of glob patterns indicating the files that the configuration object should not apply to. If not specified, the configuration object applies to all files matched by`files`.
6162
*`languageOptions` - An object containing settings related to how JavaScript is configured for linting.
@@ -342,6 +343,57 @@ Here, the `js.configs.recommended` predefined configuration is applied first and
342343

343344
For more information on how to combine predefined configs with your preferences, please see[Combine Configs](combine-configs).
344345

346+
###Configuration Naming Conventions
347+
348+
The`name` property is optional, but it is recommended to provide a name for each configuration object, especially when you are creating shared configurations. The name is used in error messages and the config inspector to help identify which configuration object is being used.
349+
350+
The name should be descriptive of the configuration object's purpose and scoped with the configuration name or plugin name using`/` as a separator. ESLint does not enforce the names to be unique at runtime, but it is recommended that unique names be set to avoid confusion.
351+
352+
For example, if you are creating a configuration object for a plugin named`eslint-plugin-example`, you might add`name` to the configuration objects with the`example/` prefix:
353+
354+
```js
355+
exportdefault {
356+
configs: {
357+
recommended: {
358+
name:"example/recommended",
359+
rules: {
360+
"no-unused-vars":"warn"
361+
}
362+
},
363+
strict: {
364+
name:"example/strict",
365+
rules: {
366+
"no-unused-vars":"error"
367+
}
368+
}
369+
}
370+
};
371+
```
372+
373+
When exposing arrays of configuration objects, the`name` may have extra scoping levels to help identify the configuration object. For example:
374+
375+
```js
376+
exportdefault {
377+
configs: {
378+
strict: [
379+
{
380+
name:"example/strict/language-setup",
381+
languageOptions: {
382+
ecmaVersion:2024
383+
}
384+
},
385+
{
386+
name:"example/strict/sub-config",
387+
file: ["src/**/*.js"],
388+
rules: {
389+
"no-unused-vars":"error"
390+
}
391+
}
392+
]
393+
}
394+
}
395+
```
396+
345397
##Using a Shareable Configuration Package
346398

347399
A sharable configuration is an npm package that exports a configuration object or array. This package should be installed as a dependency in your project and then referenced from inside of your`eslint.config.js` file. For example, to use a shareable configuration named`eslint-config-example`, your configuration file would look like this:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp