mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-05 20:32:42 +02:00
1 line
No EOL
15 KiB
JavaScript
1 line
No EOL
15 KiB
JavaScript
"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":1729593657000,"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:"<a>"})," 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:"<hn>"})," 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<n;r++)t[r]=e[r];return t}function h(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var r,t,s=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=s){var a=[],l=!0,i=!1;try{for(s=s.call(e);!(l=(r=s.next()).done)&&(a.push(r.value),!n||a.length!==n);l=!0);}catch(e){i=!0,t=e}finally{try{!l&&null!=s.return&&s.return()}finally{if(i)throw t}}return a}}(e,n)||function(e,n){if(e){if("string"==typeof e)return p(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return p(e,n)}}(e,n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e){var n,r;return null!==(r=null===(n=s.Children.toArray(e).filter(function(e){return"\n"!==e}).map(function(e){var n,r;if(!e||(0,s.isValidElement)(e)&&(n=e.props)&&(void 0===n?"undefined":(r=n)&&"undefined"!=typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)=="object"&&"value"in n)return e;throw Error("Docusaurus error: Bad <Tabs> child <".concat("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.'))}))||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;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{},t=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),t.forEach(function(n){var t,s,a;t=e,s=n,a=r[n],s in t?Object.defineProperty(t,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[s]=a})}return e}function x(e,n){return n=null!=n?n:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):(function(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r})(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}),e}function y(e){var n=e.className,r=e.block,s=e.selectedValue,i=e.selectValue,u=e.tabValues,o=[],c=(0,l.o5)().blockElementScrollPositionUntilNextRender,d=function(e){var n=e.currentTarget,r=u[o.indexOf(n)].value;r!==s&&(c(n),i(r))},p=function(e){var n=null;switch(e.key){case"Enter":d(e);break;case"ArrowRight":var r,t=o.indexOf(e.currentTarget)+1;n=null!==(r=o[t])&&void 0!==r?r:o[0];break;case"ArrowLeft":var s,a=o.indexOf(e.currentTarget)-1;n=null!==(s=o[a])&&void 0!==s?s:o[o.length-1]}null==n||n.focus()};return(0,t.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,a.Z)("tabs",{"tabs--block":r},n),children:u.map(function(e){var n=e.value,r=e.label,l=e.attributes;return(0,t.jsx)("li",x(j({role:"tab",tabIndex:s===n?0:-1,"aria-selected":s===n,ref:function(e){return o.push(e)},onKeyDown:p,onClick:d},l),{className:(0,a.Z)("tabs__item",v,null==l?void 0:l.className,{"tabs__item--active":s===n}),children:null!=r?r:n}),n)})})}function O(e){var n=e.lazy,r=e.children,l=e.selectedValue,i=(Array.isArray(r)?r:[r]).filter(Boolean);if(n){var u=i.find(function(e){return e.props.value===l});return u?(0,s.cloneElement)(u,{className:(0,a.Z)("margin-top--md",u.props.className)}):null}return(0,t.jsx)("div",{className:"margin-top--md",children:i.map(function(e,n){return(0,s.cloneElement)(e,{key:n,hidden:e.props.value!==l})})})}function w(e){var n=function(e){var n,r,t,a,l,p,g,b,v,j,x,y,O,w,S=e.defaultValue,E=e.queryString,k=e.groupId;var P=(r=(n=e).values,t=n.children,(0,s.useMemo)(function(){var e=null!=r?r:f(t).map(function(e){var n=e.props;return{value:n.value,label:n.label,attributes:n.attributes,default:n.default}});return!function(e){var n=(0,c.lx)(e,function(e,n){return e.value===n.value});if(n.length>0)throw Error('Docusaurus error: Duplicate values "'.concat(n.map(function(e){return e.value}).join(", "),'" found in <Tabs>. 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 <Tabs> component requires at least one <TabItem> children component");if(r){if(!m({value:r,tabValues:t}))throw Error('Docusaurus error: The <Tabs> 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 <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 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<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{},t=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),t.forEach(function(n){var t,s,a;t=e,s=n,a=r[n],s in t?Object.defineProperty(t,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[s]=a})}return e}({},g.location),r=(r={search:t.toString()},r),Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):(function(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r})(Object(r)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),n))}},[b,g])]),2),V=A[0],T=A[1];var Z=h((j=(v=({groupId:k}).groupId)?"docusaurus.tab.".concat(v):null,y=(x=h((0,d.Nk)(j),2))[0],O=x[1],[y,(0,s.useCallback)(function(e){if(!!j)O.set(e)},[j,O])]),2),C=Z[0],q=Z[1];var M=m({value:w=null!=V?V:C,tabValues:P})?w:null;return(0,u.Z)(function(){M&&N(M)},[M]),{selectedValue:I,selectValue:(0,s.useCallback)(function(e){if(!m({value:e,tabValues:P}))throw Error("Can't select invalid tab value=".concat(e));N(e),T(e),q(e)},[T,q,P]),tabValues:P}}(e);return(0,t.jsxs)("div",{className:(0,a.Z)("tabs-container",b),children:[(0,t.jsx)(y,j({},n,e)),(0,t.jsx)(O,j({},n,e))]})}function S(e){var n=(0,g.Z)();return(0,t.jsx)(w,x(j({},e),{children:f(e.children)}),String(n))}},80980:function(e,n,r){r.d(n,{Z:function(){return i},a:function(){return l}});var t=r(27378);let s={},a=t.createContext(s);function l(e){let n=t.useContext(a);return t.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(s):e.components||s:l(e.components),t.createElement(a.Provider,{value:n},e.children)}}}]); |