"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([["7809"],{68480:function(e,n,r){r.r(n),r.d(n,{metadata:()=>t,contentTitle:()=>o,default:()=>h,assets:()=>c,toc:()=>d,frontMatter:()=>u});var t=JSON.parse('{"id":"api/misc/eslint-plugin/README","title":"\uD83D\uDCE6 eslint-plugin","description":"ESLint 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.","source":"@site/docs/api/misc/eslint-plugin/README.mdx","sourceDirName":"api/misc/eslint-plugin","slug":"/api/misc/@docusaurus/eslint-plugin","permalink":"/docs/api/misc/@docusaurus/eslint-plugin","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/edit/main/website/docs/api/misc/eslint-plugin/README.mdx","tags":[],"version":"current","lastUpdatedBy":"S\xe9bastien Lorber","lastUpdatedAt":1728636624000,"sidebarPosition":1,"frontMatter":{"sidebar_position":1,"slug":"/api/misc/@docusaurus/eslint-plugin"},"sidebar":"api","previous":{"title":"\uD83D\uDCE6 create-docusaurus","permalink":"/docs/api/misc/create-docusaurus"},"next":{"title":"no-html-links","permalink":"/docs/api/misc/@docusaurus/eslint-plugin/no-html-links"}}'),s=r("24246"),a=r("80980"),l=r("15398"),i=r("58636");let u={sidebar_position:1,slug:"/api/misc/@docusaurus/eslint-plugin"},o="\uD83D\uDCE6 eslint-plugin",c={},d=[{value:"Installation",id:"installation",level:2},{value:"Usage",id:"usage",level:2},{value:"Recommended config",id:"recommended-config",level:3},{value:"Manual config",id:"manual-config",level:3},{value:"Supported configs",id:"supported-configs",level:2},{value:"Supported rules",id:"supported-rules",level:2},{value:"Example configuration",id:"example-configuration",level:2}];function p(e){let n={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,a.a)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"-eslint-plugin",children:"\uD83D\uDCE6 eslint-plugin"})}),"\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.a,{href:"https://eslint.org/",children:"ESLint"})," 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."]}),"\n",(0,s.jsx)(n.h2,{id:"installation",children:"Installation"}),"\n",(0,s.jsxs)(l.Z,{groupId:"npm2yarn",children:[(0,s.jsx)(i.Z,{value:"npm",children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"npm install --save-dev @docusaurus/eslint-plugin\n"})})}),(0,s.jsx)(i.Z,{value:"yarn",label:"Yarn",children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"yarn add --dev @docusaurus/eslint-plugin\n"})})}),(0,s.jsx)(i.Z,{value:"pnpm",label:"pnpm",children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"pnpm add --save-dev @docusaurus/eslint-plugin\n"})})})]}),"\n",(0,s.jsx)(n.h2,{id:"usage",children:"Usage"}),"\n",(0,s.jsx)(n.h3,{id:"recommended-config",children:"Recommended config"}),"\n",(0,s.jsxs)(n.p,{children:["Add ",(0,s.jsx)(n.code,{children:"plugin:@docusaurus/recommended"})," to the ",(0,s.jsx)(n.code,{children:"extends"})," section of your ",(0,s.jsx)(n.code,{children:".eslintrc"})," configuration file:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-json",metastring:'title=".eslintrc"',children:'{\n "extends": ["plugin:@docusaurus/recommended"]\n}\n'})}),"\n",(0,s.jsxs)(n.p,{children:["This will enable the ",(0,s.jsx)(n.code,{children:"@docusaurus"})," eslint plugin and use the ",(0,s.jsx)(n.code,{children:"recommended"})," config. See ",(0,s.jsx)(n.a,{href:"#supported-rules",children:"Supported rules"})," below for a list of rules that this will enable."]}),"\n",(0,s.jsx)(n.h3,{id:"manual-config",children:"Manual config"}),"\n",(0,s.jsx)(n.p,{children:"For more fine-grained control, you can also enable the plugin manually and configure the rules you want to use directly:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-json",metastring:'title=".eslintrc"',children:'{\n "plugins": ["@docusaurus"],\n "rules": {\n "@docusaurus/string-literal-i18n-messages": "error",\n "@docusaurus/no-untranslated-text": "warn"\n }\n}\n'})}),"\n",(0,s.jsx)(n.h2,{id:"supported-configs",children:"Supported configs"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"Recommended: recommended rule set for most Docusaurus sites that should be extended from."}),"\n",(0,s.jsxs)(n.li,{children:["All: ",(0,s.jsx)(n.strong,{children:"all"})," rules enabled. This will change between minor versions, so you should not use this if you want to avoid unexpected breaking changes."]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"supported-rules",children:"Supported rules"}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Name"}),(0,s.jsx)(n.th,{children:"Description"}),(0,s.jsx)(n.th,{})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.a,{href:"/docs/api/misc/@docusaurus/eslint-plugin/no-untranslated-text",children:(0,s.jsx)(n.code,{children:"@docusaurus/no-untranslated-text"})})}),(0,s.jsx)(n.td,{children:"Enforce text labels in JSX to be wrapped by translate calls"}),(0,s.jsx)(n.td,{})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.a,{href:"/docs/api/misc/@docusaurus/eslint-plugin/string-literal-i18n-messages",children:(0,s.jsx)(n.code,{children:"@docusaurus/string-literal-i18n-messages"})})}),(0,s.jsx)(n.td,{children:"Enforce translate APIs to be called on plain text labels"}),(0,s.jsx)(n.td,{children:"\u2705"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.a,{href:"/docs/api/misc/@docusaurus/eslint-plugin/no-html-links",children:(0,s.jsx)(n.code,{children:"@docusaurus/no-html-links"})})}),(0,s.jsxs)(n.td,{children:["Ensures @docusaurus/Link is used instead of ",(0,s.jsx)(n.code,{children:""})," tags"]}),(0,s.jsx)(n.td,{children:"\u2705"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.a,{href:"/docs/api/misc/@docusaurus/eslint-plugin/prefer-docusaurus-heading",children:(0,s.jsx)(n.code,{children:"@docusaurus/prefer-docusaurus-heading"})})}),(0,s.jsxs)(n.td,{children:["Ensures @theme/Heading is used instead of ",(0,s.jsx)(n.code,{children:""})," tags for headings"]}),(0,s.jsx)(n.td,{children:"\u2705"})]})]})]}),"\n",(0,s.jsx)(n.p,{children:"\u2705 = recommended"}),"\n",(0,s.jsx)(n.h2,{id:"example-configuration",children:"Example configuration"}),"\n",(0,s.jsx)(n.p,{children:"Here's an example configuration:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-js",metastring:'title=".eslintrc.js"',children:"module.exports = {\n extends: ['plugin:@docusaurus/recommended'],\n rules: {\n '@docusaurus/no-untranslated-text': [\n 'warn',\n {ignoredStrings: ['\xb7', '\u2014', '\xd7']},\n ],\n },\n};\n"})})]})}function h(e={}){let{wrapper:n}={...(0,a.a)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(p,{...e})}):p(e)}},58636:function(e,n,r){r.d(n,{Z:()=>l});var t=r("24246");r("27378");var s=r("90496");let a="tabItem_pnkT";function l(e){var n=e.children,r=e.hidden,l=e.className;return(0,t.jsx)("div",{role:"tabpanel",className:(0,s.Z)(a,l),hidden:r,children:n})}},15398:function(e,n,r){r.d(n,{Z:()=>S});var t=r("24246"),s=r("27378"),a=r("90496"),l=r("54947"),i=r("3620"),u=r("844"),o=r("97486"),c=r("32263"),d=r("16971");function p(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=Array(n);r child <".concat("string"==typeof e.type?e.type:e.type.name,'>: all children of the component should be , and every should have a unique "value" prop.'))}))||void 0===n?void 0:n.filter(Boolean))&&void 0!==r?r:[]}function m(e){var n=e.value;return e.tabValues.some(function(e){return e.value===n})}var g=r("71607");let b="tabList_Qoir",v="tabItem_AQgk";function j(e){for(var n=1;n0)throw Error('Docusaurus error: Duplicate values "'.concat(n.map(function(e){return e.value}).join(", "),'" found in . Every value needs to be unique.'))}(e),e},[r,t])),D=h((0,s.useState)(function(){return function(e){var n,r=e.defaultValue,t=e.tabValues;if(0===t.length)throw Error("Docusaurus error: the component requires at least one children component");if(r){if(!m({value:r,tabValues:t}))throw Error('Docusaurus error: The has a defaultValue "'.concat(r,'" but none of its children has the corresponding value. Available values are: ').concat(t.map(function(e){return e.value}).join(", "),". If you intend to show no default tab, use defaultValue={null} instead."));return r}var s=null!==(n=t.find(function(e){return e.default}))&&void 0!==n?n:t[0];if(!s)throw Error("Unexpected error: 0 tabValues");return s.value}({defaultValue:S,tabValues:P})}),2),I=D[0],N=D[1];var A=h((l=(a={queryString:void 0!==E&&E,groupId:k}).queryString,p=a.groupId,g=(0,i.k6)(),b=function(e){var n=e.queryString,r=void 0!==n&&n,t=e.groupId;if("string"==typeof r)return r;if(!1===r)return null;if(!0===r&&!t)throw Error('Docusaurus error: The component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return null!=t?t:null}({queryString:void 0!==l&&l,groupId:p}),[(0,o._X)(b),(0,s.useCallback)(function(e){if(!!b){var n,r,t=new URLSearchParams(g.location.search);t.set(b,e),g.replace((n=function(e){for(var n=1;n