Skip to content

Commit

Permalink
Docs: Added naming convention details to plugin usage (#12202)
Browse files Browse the repository at this point in the history
* Docs: Added naming convention details user guide

Added clarification about the answer regarding #12190.

* Docs: reverted markdown list style to the original
  • Loading branch information
hbarcelos authored and ilyavolodin committed Sep 14, 2019
1 parent f826eab commit 520c922
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/developer-guide/working-with-plugins.md
@@ -1,6 +1,6 @@
# Working with Plugins

Each plugin is an npm module with a name in the format of `eslint-plugin-<plugin-name>`, such as `eslint-plugin-jquery`. You can also use scoped packages in the format of `@<scope>/eslint-plugin-<plugin-name>` such as `@jquery/eslint-plugin-jquery`.
Each plugin is an npm module with a name in the format of `eslint-plugin-<plugin-name>`, such as `eslint-plugin-jquery`. You can also use scoped packages in the format of `@<scope>/eslint-plugin-<plugin-name>` such as `@jquery/eslint-plugin-jquery` or even `@<scope>/eslint-plugin` such as `@jquery/eslint-plugin`.

## Create a Plugin

Expand Down
65 changes: 65 additions & 0 deletions docs/user-guide/configuring.md
Expand Up @@ -323,6 +323,71 @@ And in YAML:

**Note:** Plugins are resolved relative to the current working directory of the ESLint process. In other words, ESLint will load the same plugin as a user would obtain by running `require('eslint-plugin-pluginname')` in a Node REPL from their project root.

### Naming Convention

#### Include a Plugin

The `eslint-plugin-` prefix can be omitted for non-scoped packages

```js
{
// ...
"plugins": [
"jquery", // means eslint-plugin-jquery
]
// ...
}
```

The same rule does apply to scoped packages:

```js
{
// ...
"plugins": [
"@jquery/jquery", // means @jquery/eslint-plugin-jquery
"@foobar" // means @foobar/eslint-plugin
]
// ...
}
```

#### Use a Plugin

When using rules, environments or configs defined by plugins, they must be referenced following the convention:

* `eslint-plugin-foo``foo/a-rule`
* `@foo/eslint-plugin``@foo/a-config`
* `@foo/eslint-plugin-bar``@foo/bar/a-environment`

For example:

```js
{
// ...
"plugins": [
"jquery", // eslint-plugin-jquery
"@foo/foo", // @foo/eslint-plugin-foo
"@bar" // @bar/eslint-plugin
],
"extends": [
"plugin:@foo/foo/recommended",
"plugin:@bar/recommended"
],
"rules": [
"jquery/a-rule": "error",
"@foo/foo/some-rule": "error",
"@bar/another-rule": "error"
],
"env": {
"jquery/jquery": true,
"@foo/foo/env-foo": true,
"@bar/env-bar": true,
}
// ...
}
```

## Configuring Rules

ESLint comes with a large number of rules. You can modify which rules your project uses either using configuration comments or configuration files. To change a rule setting, you must set the rule ID equal to one of these values:
Expand Down

0 comments on commit 520c922

Please sign in to comment.