docusaurus/assets/js/33bfb584.dbb65ed8.js
2025-12-04 14:19:59 +00:00

1 line
12 KiB
JavaScript

"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([["24931"],{41452:function(e,n,s){s.d(n,{A:()=>r});let r={tabItem:"tabItem_pnkT"}},18416:function(e,n,s){s.d(n,{A:()=>r});let r={tabList:"tabList_Qoir",tabItem:"tabItem_AQgk"}},70352:function(e,n,s){s.r(n),s.d(n,{assets:()=>c,contentTitle:()=>o,default:()=>p,frontMatter:()=>u,metadata:()=>r,toc:()=>d});var r=s(89783),t=s(74848),a=s(56151),l=s(14729),i=s(13899);let u={sidebar_position:1,slug:"/api/misc/@docusaurus/eslint-plugin"},o="\u{1F4E6} 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 h(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.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"-eslint-plugin",children:"\u{1F4E6} eslint-plugin"})}),"\n",(0,t.jsxs)(n.p,{children:[(0,t.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,t.jsx)(n.h2,{id:"installation",children:"Installation"}),"\n",(0,t.jsxs)(l.A,{groupId:"npm2yarn",children:[(0,t.jsx)(i.A,{value:"npm",children:(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"npm install --save-dev @docusaurus/eslint-plugin\n"})})}),(0,t.jsx)(i.A,{value:"yarn",label:"Yarn",children:(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"yarn add --dev @docusaurus/eslint-plugin\n"})})}),(0,t.jsx)(i.A,{value:"pnpm",label:"pnpm",children:(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"pnpm add --save-dev @docusaurus/eslint-plugin\n"})})}),(0,t.jsx)(i.A,{value:"bun",label:"Bun",children:(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-bash",children:"bun add --dev @docusaurus/eslint-plugin\n"})})})]}),"\n",(0,t.jsx)(n.h2,{id:"usage",children:"Usage"}),"\n",(0,t.jsx)(n.h3,{id:"recommended-config",children:"Recommended config"}),"\n",(0,t.jsxs)(n.p,{children:["Add ",(0,t.jsx)(n.code,{children:"plugin:@docusaurus/recommended"})," to the ",(0,t.jsx)(n.code,{children:"extends"})," section of your ",(0,t.jsx)(n.code,{children:".eslintrc"})," configuration file:"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-json",metastring:'title=".eslintrc"',children:'{\n "extends": ["plugin:@docusaurus/recommended"]\n}\n'})}),"\n",(0,t.jsxs)(n.p,{children:["This will enable the ",(0,t.jsx)(n.code,{children:"@docusaurus"})," eslint plugin and use the ",(0,t.jsx)(n.code,{children:"recommended"})," config. See ",(0,t.jsx)(n.a,{href:"#supported-rules",children:"Supported rules"})," below for a list of rules that this will enable."]}),"\n",(0,t.jsx)(n.h3,{id:"manual-config",children:"Manual config"}),"\n",(0,t.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,t.jsx)(n.pre,{children:(0,t.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,t.jsx)(n.h2,{id:"supported-configs",children:"Supported configs"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"Recommended: recommended rule set for most Docusaurus sites that should be extended from."}),"\n",(0,t.jsxs)(n.li,{children:["All: ",(0,t.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,t.jsx)(n.h2,{id:"supported-rules",children:"Supported rules"}),"\n",(0,t.jsxs)(n.table,{children:[(0,t.jsx)(n.thead,{children:(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.th,{children:"Name"}),(0,t.jsx)(n.th,{children:"Description"}),(0,t.jsx)(n.th,{})]})}),(0,t.jsxs)(n.tbody,{children:[(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{children:(0,t.jsx)(n.a,{href:"/docs/api/misc/@docusaurus/eslint-plugin/no-untranslated-text",children:(0,t.jsx)(n.code,{children:"@docusaurus/no-untranslated-text"})})}),(0,t.jsx)(n.td,{children:"Enforce text labels in JSX to be wrapped by translate calls"}),(0,t.jsx)(n.td,{})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{children:(0,t.jsx)(n.a,{href:"/docs/api/misc/@docusaurus/eslint-plugin/string-literal-i18n-messages",children:(0,t.jsx)(n.code,{children:"@docusaurus/string-literal-i18n-messages"})})}),(0,t.jsx)(n.td,{children:"Enforce translate APIs to be called on plain text labels"}),(0,t.jsx)(n.td,{children:"\u2705"})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{children:(0,t.jsx)(n.a,{href:"/docs/api/misc/@docusaurus/eslint-plugin/no-html-links",children:(0,t.jsx)(n.code,{children:"@docusaurus/no-html-links"})})}),(0,t.jsxs)(n.td,{children:["Ensures @docusaurus/Link is used instead of ",(0,t.jsx)(n.code,{children:"<a>"})," tags"]}),(0,t.jsx)(n.td,{children:"\u2705"})]}),(0,t.jsxs)(n.tr,{children:[(0,t.jsx)(n.td,{children:(0,t.jsx)(n.a,{href:"/docs/api/misc/@docusaurus/eslint-plugin/prefer-docusaurus-heading",children:(0,t.jsx)(n.code,{children:"@docusaurus/prefer-docusaurus-heading"})})}),(0,t.jsxs)(n.td,{children:["Ensures @theme/Heading is used instead of ",(0,t.jsx)(n.code,{children:"<hn>"})," tags for headings"]}),(0,t.jsx)(n.td,{children:"\u2705"})]})]})]}),"\n",(0,t.jsx)(n.p,{children:"\u2705 = recommended"}),"\n",(0,t.jsx)(n.h2,{id:"example-configuration",children:"Example configuration"}),"\n",(0,t.jsx)(n.p,{children:"Here's an example configuration:"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.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 p(e={}){let{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(h,{...e})}):h(e)}},13899:function(e,n,s){s.d(n,{A:()=>l});var r=s(74848);s(96540);var t=s(11118),a=s(41452);function l({children:e,hidden:n,className:s}){return(0,r.jsx)("div",{role:"tabpanel",className:(0,t.A)(a.A.tabItem,s),hidden:n,children:e})}},14729:function(e,n,s){s.d(n,{A:()=>m});var r=s(74848),t=s(96540),a=s(11118),l=s(85208),i=s(31191),u=s(17060),o=s(30926),c=s(18416);function d({className:e,block:n,selectedValue:s,selectValue:t,tabValues:l}){let u=[],{blockElementScrollPositionUntilNextRender:o}=(0,i.a_)(),d=e=>{let n=e.currentTarget,r=l[u.indexOf(n)].value;r!==s&&(o(n),t(r))},h=e=>{let n=null;switch(e.key){case"Enter":d(e);break;case"ArrowRight":{let s=u.indexOf(e.currentTarget)+1;n=u[s]??u[0];break}case"ArrowLeft":{let s=u.indexOf(e.currentTarget)-1;n=u[s]??u[u.length-1]}}n?.focus()};return(0,r.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,a.A)("tabs",{"tabs--block":n},e),children:l.map(({value:e,label:n,attributes:t})=>(0,r.jsx)("li",{role:"tab",tabIndex:s===e?0:-1,"aria-selected":s===e,ref:e=>{u.push(e)},onKeyDown:h,onClick:d,...t,className:(0,a.A)("tabs__item",c.A.tabItem,t?.className,{"tabs__item--active":s===e}),children:n??e},e))})}function h({lazy:e,children:n,selectedValue:s}){let l=(Array.isArray(n)?n:[n]).filter(Boolean);if(e){let e=l.find(e=>e.props.value===s);return e?(0,t.cloneElement)(e,{className:(0,a.A)("margin-top--md",e.props.className)}):null}return(0,r.jsx)("div",{className:"margin-top--md",children:l.map((e,n)=>(0,t.cloneElement)(e,{key:n,hidden:e.props.value!==s}))})}function p(e){let n=(0,u.u)(e);return(0,r.jsxs)("div",{className:(0,a.A)(l.G.tabs.container,"tabs-container",c.A.tabList),children:[(0,r.jsx)(d,{...n,...e}),(0,r.jsx)(h,{...n,...e})]})}function m(e){let n=(0,o.A)();return(0,r.jsx)(p,{...e,children:(0,u.v)(e.children)},String(n))}},17060:function(e,n,s){s.d(n,{u:()=>d,v:()=>o});var r=s(96540),t=s(49519),a=s(57190),l=s(11864),i=s(84329),u=s(34123);function o(e){return r.Children.toArray(e).filter(e=>"\n"!==e).map(e=>{if(!e||(0,r.isValidElement)(e)&&function(e){let{props:n}=e;return!!n&&"object"==typeof n&&"value"in n}(e))return e;throw Error(`Docusaurus error: Bad <Tabs> child <${"string"==typeof e.type?e.type:e.type.name}>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.`)})?.filter(Boolean)??[]}function c({value:e,tabValues:n}){return n.some(n=>n.value===e)}function d(e){let n,{defaultValue:s,queryString:d=!1,groupId:h}=e,p=function(e){let{values:n,children:s}=e;return(0,r.useMemo)(()=>{let e=n??o(s).map(({props:{value:e,label:n,attributes:s,default:r}})=>({value:e,label:n,attributes:s,default:r})),r=(0,i.XI)(e,(e,n)=>e.value===n.value);if(r.length>0)throw Error(`Docusaurus error: Duplicate values "${r.map(e=>e.value).join(", ")}" found in <Tabs>. Every value needs to be unique.`);return e},[n,s])}(e),[m,g]=(0,r.useState)(()=>(function({defaultValue:e,tabValues:n}){if(0===n.length)throw Error("Docusaurus error: the <Tabs> component requires at least one <TabItem> children component");if(e){if(!c({value:e,tabValues:n}))throw Error(`Docusaurus error: The <Tabs> has a defaultValue "${e}" but none of its children has the corresponding value. Available values are: ${n.map(e=>e.value).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return e}let s=n.find(e=>e.default)??n[0];if(!s)throw Error("Unexpected error: 0 tabValues");return s.value})({defaultValue:s,tabValues:p})),[f,x]=function({queryString:e=!1,groupId:n}){let s=(0,t.W6)(),a=function({queryString:e=!1,groupId:n}){if("string"==typeof e)return e;if(!1===e)return null;if(!0===e&&!n)throw Error('Docusaurus error: The <Tabs> 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 n??null}({queryString:e,groupId:n});return[(0,l.aZ)(a),(0,r.useCallback)(e=>{if(!a)return;let n=new URLSearchParams(s.location.search);n.set(a,e),s.replace({...s.location,search:n.toString()})},[a,s])]}({queryString:d,groupId:h}),[j,b]=function({groupId:e}){let n=e?`docusaurus.tab.${e}`:null,[s,t]=(0,u.Dv)(n);return[s,(0,r.useCallback)(e=>{n&&t.set(e)},[n,t])]}({groupId:h}),v=c({value:n=f??j,tabValues:p})?n:null;return(0,a.A)(()=>{v&&g(v)},[v]),{selectedValue:m,selectValue:(0,r.useCallback)(e=>{if(!c({value:e,tabValues:p}))throw Error(`Can't select invalid tab value=${e}`);g(e),x(e),b(e)},[x,b,p]),tabValues:p}}},56151:function(e,n,s){s.d(n,{R:()=>l,x:()=>i});var r=s(96540);let t={},a=r.createContext(t);function l(e){let n=r.useContext(a);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:l(e.components),r.createElement(a.Provider,{value:n},e.children)}},89783:function(e){e.exports=JSON.parse('{"id":"api/misc/eslint-plugin/README","title":"\u{1F4E6} 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":"dependabot[bot]","lastUpdatedAt":1764857819000,"sidebarPosition":1,"frontMatter":{"sidebar_position":1,"slug":"/api/misc/@docusaurus/eslint-plugin"},"sidebar":"api","previous":{"title":"\u{1F4E6} create-docusaurus","permalink":"/docs/api/misc/create-docusaurus"},"next":{"title":"no-html-links","permalink":"/docs/api/misc/@docusaurus/eslint-plugin/no-html-links"}}')}}]);