mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-13 17:17:28 +02:00
feat(eslint-plugin): add plugin to exported configs (#8281)
Co-authored-by: Joshua Chen <sidachen2003@gmail.com> closes undefined Closes https://github.com/facebook/docusaurus/issues/8280
This commit is contained in:
parent
aa74b38209
commit
85d0b5674f
2 changed files with 12 additions and 12 deletions
|
@ -11,11 +11,13 @@ export = {
|
||||||
rules,
|
rules,
|
||||||
configs: {
|
configs: {
|
||||||
recommended: {
|
recommended: {
|
||||||
|
plugins: ['@docusaurus'],
|
||||||
rules: {
|
rules: {
|
||||||
'@docusaurus/string-literal-i18n-messages': 'error',
|
'@docusaurus/string-literal-i18n-messages': 'error',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
all: {
|
all: {
|
||||||
|
plugins: ['@docusaurus'],
|
||||||
rules: {
|
rules: {
|
||||||
'@docusaurus/string-literal-i18n-messages': 'error',
|
'@docusaurus/string-literal-i18n-messages': 'error',
|
||||||
'@docusaurus/no-untranslated-text': 'warn',
|
'@docusaurus/no-untranslated-text': 'warn',
|
||||||
|
|
|
@ -15,15 +15,9 @@ npm install --save-dev @docusaurus/eslint-plugin
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Add `@docusaurus` to the plugins section of your `.eslintrc` configuration file:
|
### Recommended config
|
||||||
|
|
||||||
```json title=".eslintrc"
|
Add `plugin:@docusaurus/recommended` to the `extends` section of your `.eslintrc` configuration file:
|
||||||
{
|
|
||||||
"plugins": ["@docusaurus"]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Then, you can extend one of the configs (e.g. the `recommended` config):
|
|
||||||
|
|
||||||
```json title=".eslintrc"
|
```json title=".eslintrc"
|
||||||
{
|
{
|
||||||
|
@ -31,10 +25,15 @@ Then, you can extend one of the configs (e.g. the `recommended` config):
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
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"
|
```json title=".eslintrc"
|
||||||
{
|
{
|
||||||
|
"plugins": ["@docusaurus"],
|
||||||
"rules": {
|
"rules": {
|
||||||
"@docusaurus/string-literal-i18n-messages": "error",
|
"@docusaurus/string-literal-i18n-messages": "error",
|
||||||
"@docusaurus/no-untranslated-text": "warn"
|
"@docusaurus/no-untranslated-text": "warn"
|
||||||
|
@ -42,12 +41,12 @@ Each config contains a set of rules. For more fine-grained control, you can also
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Supported Configs
|
## Supported configs
|
||||||
|
|
||||||
- Recommended: recommended rule set for most Docusaurus sites that should be extended from.
|
- 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.
|
- 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 | |
|
| Name | Description | |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
|
@ -63,7 +62,6 @@ Here's an example configuration:
|
||||||
```js title=".eslintrc.js"
|
```js title=".eslintrc.js"
|
||||||
module.exports = {
|
module.exports = {
|
||||||
extends: ['plugin:@docusaurus/recommended'],
|
extends: ['plugin:@docusaurus/recommended'],
|
||||||
plugins: ['@docusaurus'],
|
|
||||||
rules: {
|
rules: {
|
||||||
'@docusaurus/no-untranslated-text': [
|
'@docusaurus/no-untranslated-text': [
|
||||||
'warn',
|
'warn',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue