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: Document extending plugin with new config (#16394)
* docs: Document extending plugin with new config
Document how to extend a plugin configuration using the new ESLint configuration file type system.
Fixes#16310
* incorporate @nzakas feedback
Copy file name to clipboardExpand all lines: docs/src/user-guide/configuring/configuration-files-new.md
+32-1Lines changed: 32 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -329,7 +329,13 @@ For historical reasons, the boolean value `false` and the string value `"readabl
329
329
330
330
### Using plugins in your configuration
331
331
332
-
Plugins are used to share rules, processors, configurations, parsers, and more across ESLint projects. Plugins are specified in a configuration object using the `plugins` key, which is an object where the name of the plugin is the property name and the value is the plugin object itself. Here's an example:
332
+
Plugins are used to share rules, processors, configurations, parsers, and more across ESLint projects.
333
+
334
+
#### Using plugin rules
335
+
336
+
You can use specific rules included in a plugin. To do this, specify the plugin
337
+
in a configuration object using the `plugins` key. The value for the `plugin` key
338
+
is an object where the name of the plugin is the property name and the value is the plugin object itself. Here's an example:
333
339
334
340
```js
335
341
importjsdocfrom"eslint-plugin-jsdoc";
@@ -390,6 +396,31 @@ export default [
390
396
391
397
This configuration object uses `jsd` as the prefix plugin instead of `jsdoc`.
392
398
399
+
#### Using configurations included in plugins
400
+
401
+
You can use a configuration included in a plugin by adding that configuration
402
+
directly to the `eslint.config.js` configurations array.
403
+
Often, you do this for a plugin's recommended configuration. Here's an example:
404
+
405
+
```js
406
+
importjsdocfrom"eslint-plugin-jsdoc";
407
+
408
+
exportdefault [
409
+
// configuration included in plugin
410
+
jsdoc.configs.recommended,
411
+
// other configuration objects...
412
+
{
413
+
files: ["**/*.js"],
414
+
plugins: {
415
+
jsdoc: jsdoc
416
+
}
417
+
rules: {
418
+
"jsdoc/require-description":"warn",
419
+
}
420
+
}
421
+
];
422
+
```
423
+
393
424
### Using processors
394
425
395
426
Processors allow ESLint to transform text into pieces of code that ESLint can lint. You can specify the processor to use for a given file type by defining a `processor` property that contains either the processor name in the format `"pluginName/processorName"` to reference a processor in a plugin or an object containing both a `preprocess()` and a `postprocess()` method. For example, to extract JavaScript code blocks from a Markdown file, you might add this to your configuration:
0 commit comments