Skip to content

Commit 1f37442

Browse files
authored
docs: Add sections on non-npm plugin configuration (#17984)
1 parent bbf2b21 commit 1f37442

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

docs/src/use/configure/plugins.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,54 @@ export default [
4444
When creating a namespace for a plugin, the convention is to use the npm package name without the `eslint-plugin-` prefix. In the preceding example, `eslint-plugin-example` is assigned a namespace of `example`.
4545
:::
4646

47+
### Configure a Local Plugin
48+
49+
Plugins don't need to be published to npm for use with ESLint. You can also load plugins directly from a file, as in this example:
50+
51+
```js
52+
// eslint.config.js
53+
import local from "./my-local-plugin.js";
54+
55+
export default [
56+
{
57+
plugins: {
58+
local
59+
},
60+
rules: {
61+
"local/rule1": "warn"
62+
}
63+
}
64+
];
65+
```
66+
67+
Here, the namespace `local` is used, but you can also use any name you'd like instead.
68+
69+
### Configure a Virtual Plugin
70+
71+
Plugin definitions can be created virtually directly in your config. For example, suppose you have a rule contained in a file called `my-rule.js` that you'd like to enable in your config. You can define a virtual plugin to do so, as in this example:
72+
73+
```js
74+
// eslint.config.js
75+
import myRule from "./rules/my-rule.js";
76+
77+
export default [
78+
{
79+
plugins: {
80+
local: {
81+
rules: {
82+
"my-rule": myRule
83+
}
84+
}
85+
},
86+
rules: {
87+
"local/my-rule": "warn"
88+
}
89+
}
90+
];
91+
```
92+
93+
Here, the namespace `local` is used to define a virtual plugin. The rule `myRule` is then assigned a name of `my-rule` inside of the virtual plugin's `rules` object. (See [Create Plugins](../../extend/plugins) for the complete format of a plugin.) You can then reference the rule as `local/my-rule` to configure it.
94+
4795
## Use Plugin Rules
4896

4997
You can use specific rules included in a plugin. To do this, specify the plugin

0 commit comments

Comments
 (0)