/
githubmirror
/
docusaurus
Обзор
Документация
Войти
/
githubmirror
/
docusaurus
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
website/docs/api/misc/eslint-plugin/README.mdx
104 строки
3 KB
Sébastien Lorber
break(eslint-plugin): Add ESLint flag configs, require ESLint `>= 8.57` (#12025)
15 май 2026, 20:09
Не верифицирован
15 май 2026, 20:09
1641a13
Код
Авторство
О чём код?
--- sidebar_position: 1 slug: /api/misc/@docusaurus/eslint-plugin --- # 📦 eslint-plugin [ESLint](https://eslint.org/) is a tool that statically analyzes your code and reports problems or suggests best practices through editor hints and command line. Docusaurus provides an ESLint plugin to enforce best Docusaurus practices. This ESLint plugin supports ESLint `>= 8.57.0`, flat configs and legacy configs. ## Installation {/* #installation */} ```bash npm2yarn npm install --save-dev @docusaurus/eslint-plugin ``` ## Supported configs {/* #supported-configs */} Both built-in configs exist in flat and legacy variants: - 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 | | | --- | --- | --- | | [`@docusaurus/no-untranslated-text`](./no-untranslated-text.mdx) | Enforce text labels in JSX to be wrapped by translate calls | | | [`@docusaurus/string-literal-i18n-messages`](./string-literal-i18n-messages.mdx) | Enforce translate APIs to be called on plain text labels | ✅ | | [`@docusaurus/no-html-links`](./no-html-links.mdx) | Ensures @docusaurus/Link is used instead of `<a>` tags | ✅ | | [`@docusaurus/prefer-docusaurus-heading`](./prefer-docusaurus-heading.mdx) | Ensures @theme/Heading is used instead of `<hn>` tags for headings | ✅ | ✅ = recommended ## Usage - Flat {/* #usage-flat */} ### Recommended config {/* #recommended-config-flat */} Import `@docusaurus/eslint-plugin` and add `docusaurus.configs.flat.recommended` to your flat config array: ```js title="eslint.config.js" import {defineConfig} from 'eslint/config'; // highlight-next-line import docusaurus from '@docusaurus/eslint-plugin'; export default defineConfig( // highlight-next-line docusaurus.configs.flat.recommended, { // Other config }, ); ``` This will enable the `@docusaurus` eslint plugin and use the `recommended` config. See [Supported rules](#supported-rules) above for a list of rules that this will enable. ### Manual config {/* #manual-config-flat */} For more fine-grained control, you can also enable the plugin manually and configure the rules you want to use directly: ```js title="eslint.config.js" import {defineConfig} from 'eslint/config'; // highlight-next-line import docusaurus from '@docusaurus/eslint-plugin'; export default defineConfig({ // highlight-start plugins: {docusaurus}, rules: { '@docusaurus/string-literal-i18n-messages': 'error', '@docusaurus/no-untranslated-text': 'warn', }, // highlight-end }); ``` ## Usage - Legacy {/* #usage-legacy */} ### Recommended config {/* #recommended-config-legacy */} Add `plugin:@docusaurus/recommended` to the `extends` section of your `.eslintrc` configuration file: ```json title=".eslintrc" { "extends": ["plugin:@docusaurus/recommended"] } ``` This will enable the `@docusaurus` eslint plugin and use the `recommended` config. See [Supported rules](#supported-rules) above for a list of rules that this will enable. ### Manual config {/* #manual-config-legacy */} 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" } } ```