Skip to content

Commit 2ba8a0d

Browse files
authored
docs: Add description of meta.namespace to plugin docs (#19798)
fixes #19655
1 parent eea3e7e commit 2ba8a0d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

docs/src/extend/plugins.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,15 @@ If you plan to distribute your plugin as an npm package, make sure that the modu
3939

4040
### Meta Data in Plugins
4141

42-
For easier debugging and more effective caching of plugins, it's recommended to provide a `name` and `version` in a `meta` object at the root of your plugin, like this:
42+
For easier debugging and more effective caching of plugins, it's recommended to provide a `name`, `version`, and `namespace` in a `meta` object at the root of your plugin, like this:
4343

4444
```js
4545
const plugin = {
4646
// preferred location of name and version
4747
meta: {
4848
name: "eslint-plugin-example",
4949
version: "1.2.3",
50+
namespace: "example",
5051
},
5152
rules: {
5253
// add rules here
@@ -60,7 +61,9 @@ export default plugin;
6061
module.exports = plugin;
6162
```
6263

63-
The `meta.name` property should match the npm package name for your plugin and the `meta.version` property should match the npm package version for your plugin. The easiest way to accomplish this is by reading this information from your `package.json`, as in this example:
64+
The `meta.name` property should match the npm package name for your plugin and the `meta.version` property should match the npm package version for your plugin. The `meta.namespace` property should match the prefix you'd like users to use for accessing the plugin's rules, processors, languages, and configs. The namespace is typically what comes after `eslint-plugin-` in your package name, which is why this example uses `"example"`. Providing a namespace allows the `defineConfig()` function to find your plugin even when a user assigns a different namespace in their config file.
65+
66+
The easiest way to add the name and version is by reading this information from your `package.json`, as in this example:
6467

6568
```js
6669
import fs from "fs";
@@ -74,6 +77,7 @@ const plugin = {
7477
meta: {
7578
name: pkg.name,
7679
version: pkg.version,
80+
namespace: "example",
7781
},
7882
rules: {
7983
// add rules here

0 commit comments

Comments
 (0)