Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eslint-plugin): add plugin to exported configs #8281

Merged
merged 2 commits into from Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/index.ts
Expand Up @@ -11,11 +11,13 @@ export = {
rules,
configs: {
recommended: {
plugins: ['@docusaurus'],
rules: {
'@docusaurus/string-literal-i18n-messages': 'error',
},
},
all: {
plugins: ['@docusaurus'],
rules: {
'@docusaurus/string-literal-i18n-messages': 'error',
'@docusaurus/no-untranslated-text': 'warn',
Expand Down
22 changes: 10 additions & 12 deletions website/docs/api/misc/eslint-plugin/README.md
Expand Up @@ -15,39 +15,38 @@ npm install --save-dev @docusaurus/eslint-plugin

## Usage

Add `@docusaurus` to the plugins section of your `.eslintrc` configuration file:
### Recommended config

```json title=".eslintrc"
{
"plugins": ["@docusaurus"]
}
```

Then, you can extend one of the configs (e.g. the `recommended` config):
Add `plugin:@docusaurus/recommended` to the `extends` section of your `.eslintrc` configuration file:

```json title=".eslintrc"
{
"extends": ["plugin:@docusaurus/recommended"]
}
```

Each config contains a set of rules. For more fine-grained control, you can also configure the rules you want to use directly:
This will enable the `@docusaurus` eslint plugin and use the `recommended` config. See [Supported rules](#supported-rules) below for a list of rules that this will enable.

### Manual config

For more fine-grained control, you can also enable the plugin manually and configure the rules you want to use directly:

```json title=".eslintrc"
{
"plugins": ["@docusaurus"],
"rules": {
"@docusaurus/string-literal-i18n-messages": "error",
"@docusaurus/no-untranslated-text": "warn"
}
}
```

## Supported Configs
## Supported configs

- Recommended: recommended rule set for most Docusaurus sites that should be extended from.
- All: **all** rules enabled. This will change between minor versions, so you should not use this if you want to avoid unexpected breaking changes.

## Supported Rules
## Supported rules

| Name | Description | |
| --- | --- | --- |
Expand All @@ -63,7 +62,6 @@ Here's an example configuration:
```js title=".eslintrc.js"
module.exports = {
extends: ['plugin:@docusaurus/recommended'],
plugins: ['@docusaurus'],
rules: {
'@docusaurus/no-untranslated-text': [
'warn',
Expand Down