PageSourceSearch

https://typescript-eslint.io/assets/js/13531353.e9c5bd93.js

js typescript-eslint.io collected 2026-10-02 02:16:26 UTC 10,733 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([["2740"],{43317(e,t,n){n.r(t),n.d(t,{metadata:()=>s,default:()=>h,frontMatter:()=>o,contentTitle:()=>c,toc:()=>d,assets:()=>u});var s=JSON.parse('{"id":"ban-tslint-comment","title":"ban-tslint-comment","description":"Disallow `// tslint:<rule-flag>` comments.","source":"@site/../eslint-plugin/docs/rules/ban-tslint-comment.mdx","sourceDirName":".","slug":"/ban-tslint-comment","permalink":"/rules/ban-tslint-comment","draft":false,"unlisted":false,"editUrl":"https://github.com/typescript-eslint/typescript-eslint/edit/main/packages/website/../eslint-plugin/docs/rules/ban-tslint-comment.mdx","tags":[],"version":"current","frontMatter":{"description":"Disallow `// tslint:<rule-flag>` comments.","image":"/img/og/rules/ban-tslint-comment.png"},"sidebar":"rulesSidebar","previous":{"title":"ban-ts-comment","permalink":"/rules/ban-ts-comment"},"next":{"title":"class-literal-property-style","permalink":"/rules/class-literal-property-style"}}'),l=n(65723),r=n(7143),i=n(70503),a=n(46742);let o={description:"Disallow `// tslint:<rule-flag>` comments.",image:"/img/og/rules/ban-tslint-comment.png"},c,u={},d=[{value:"Examples",id:"examples",level:2},{value:"Options",id:"options",level:2},{value:"When Not To Use It",id:"when-not-to-use-it",level:2},{value:"Resources",id:"resources",level:2}];function m(e){let t={a:"a",blockquote:"blockquote",code:"code",h2:"h2",li:"li",meta:"meta",p:"p",pre:"pre",ul:"ul",...(0,r.R)(),...e.components},{Head:n,RuleAttributes:s,TryInPlayground:o}=t;return n||p("Head",!0),s||p("RuleAttributes",!0),o||p("TryInPlayground",!0),(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(l.Fragment,{children:(0,l.jsxs)(t.blockquote,{children:["\n",(0,l.jsxs)(t.p,{children:["Disallow ",(0,l.jsx)(t.code,{children:"// tslint:<rule-flag>"})," comments."]}),"\n"]})}),"\n",(0,l.jsx)(s,{name:"ban-tslint-comment"}),"\n","\n",(0,l.jsxs)(t.p,{children:["Useful when migrating from TSLint to ESLint. Once TSLint has been removed, this rule helps locate TSLint annotations (e.g. ",(0,l.jsx)(t.code,{children:"// tslint:disable"}),")."]}),"\n",(0,l.jsxs)(t.blockquote,{children:["\n",(0,l.jsxs)(t.p,{children:["See the ",(0,l.jsx)(t.a,{href:"https://palantir.github.io/tslint/usage/rule-flags",children:"TSLint rule flags docs"})," for reference."]}),"\n"]}),"\n",(0,l.jsxs)(i.A,{children:[(0,l.jsx)(a.A,{value:"Flat Config",children:(0,l.jsx)(t.pre,{children:(0,l.jsx)(t.code,{className:"language-js",metastring:'title="eslint.config.mjs"',children:'export default defineConfig({\n  rules: {\n    "@typescript-eslint/ban-tslint-comment": "error"\n  }\n});\n'})})}),(0,l.jsx)(a.A,{value:"Legacy Config",children:(0,l.jsx)(t.pre,{children:(0,l.jsx)(t.code,{className:"language-js",metastring:'title=".eslintrc.cjs"',children:'module.exports = {\n  "rules": {\n    "@typescript-eslint/ban-tslint-comment": "error"\n  }\n};\n'})})})]}),"\n",(0,l.jsx)(o,{eslintrcHash:"N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6AIwEMnb9lGWtMgHsAtqMQt0URNGjDokcGAC+IFUA",children:(0,l.jsx)(t.p,{children:"Try this rule in the playground \u2197"})}),"\n",(0,l.jsx)(t.h2,{id:"examples",children:"Examples"}),"\n",(0,l.jsxs)(i.A,{children:[(0,l.jsx)(a.A,{value:"\u274C Incorrect",children:(0,l.jsx)(t.pre,{children:(0,l.jsx)(t.code,{className:"language-ts",metastring:'eslintrcHash="N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6AIwEMnb9lGWtMgHsAtqMQt0URNGjDokcGAC+IFUA"',children:"/* tslint:disable */\n/* tslint:enable */\n/* tslint:disable:rule1 rule2 rule3... */\n/* tslint:enable:rule1 rule2 rule3... */\n// tslint:disable-next-line\nsomeCode(); // tslint:disable-line\n// tslint:disable-next-line:rule1 rule2 rule3...\n"})})}),(0,l.jsx)(a.A,{value:"\u2705 Correct",children:(0,l.jsx)(t.pre,{children:(0,l.jsx)(t.code,{className:"language-ts",metastring:'eslintrcHash="N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6AIwEMnb9lGWtMgHsAtqMQt0URNGjDokcGAC+IFUA"',children:"// This is a comment that just happens to mention tslint\n/* This is a multiline comment that just happens to mention tslint */\nsomeCode(); // This is a comment that just happens to mention tslint\n"})})})]}),"\n",(0,l.jsx)(t.h2,{id:"options",children:"Options"}),"\n",(0,l.jsx)(l.Fragment,{children:(0,l.jsx)(t.p,{children:"This rule is not configurable."})}),"\n",(0,l.jsx)(t.h2,{id:"when-not-to-use-it",children:"When Not To Use It"}),"\n",(0,l.jsx)(t.p,{children:"If you are still using TSLint alongside ESLint."}),"\n",(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(t.h2,{id:"resources",children:"Resources"}),"\n",(0,l.jsxs)(t.ul,{children:["\n",(0,l.jsx)(t.li,{children:(0,l.jsx)(t.a,{href:"https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/rules/ban-tslint-comment.ts",children:"Rule source"})}),"\n",(0,l.jsx)(t.li,{children:(0,l.jsx)(t.a,{href:"https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/tests/rules/ban-tslint-comment.test.ts",children:"Test source"})}),"\n"]})]}),"\n",(0,l.jsx)(n,{children:(0,l.jsx)(t.meta,{content:"ban-tslint-comment: Disallow // tslint:<rule-flag> comments",name:"twitter:image:alt"})})]})}function h(e={}){let{wrapper:t}={...(0,r.R)(),...e.components};return t?(0,l.jsx)(t,{...e,children:(0,l.jsx)(m,{...e})}):m(e)}function p(e,t){throw Error("Expected "+(t?"component":"object")+" `"+e+"` to be defined: you likely forgot to import, pass, or provide it.")}},46742(e,t,n){n.d(t,{A:()=>a});var s=n(65723);n(22155);var l=n(70851),r=n(28226);function i({children:e,className:t,hidden:n}){return(0,s.jsx)("div",{role:"tabpanel",className:(0,l.A)("tabItem_eQ9s",t),hidden:n,children:e})}function a({children:e,className:t,value:n}){let{selectedValue:l,lazy:o}=(0,r.uc)(),c=n===l;return!c&&o?null:(0,s.jsx)(i,{className:t,hidden:!c,children:e})}},70503(e,t,n){n.d(t,{A:()=>m});var s=n(65723);n(22155);var l=n(70851),r=n(98838),i=n(28226),a=n(26309),o=n(29021);function c({className:e}){let{selectedValue:t,selectValue:n,tabValues:r,block:o}=(0,i.uc)(),u=[],{blockElementScrollPositionUntilNextRender:d}=(0,a.a_)(),m=e=>{let s=e.currentTarget,l=r[u.indexOf(s)].value;l!==t&&(d(s),n(l))},h=e=>{let t=null;switch(e.key){case"Enter":m(e);break;case"ArrowRight":{let n=u.indexOf(e.currentTarget)+1;t=u[n]??u[0];break}case"ArrowLeft":{let n=u.indexOf(e.currentTarget)-1;t=u[n]??u[u.length-1]}}t?.focus()};return(0,s.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,l.A)("tabs",{"tabs--block":o},e),children:r.map(({value:e,label:n,attributes:r})=>(0,s.jsx)("li",{role:"tab",tabIndex:t===e?0:-1,"aria-selected":t===e,ref:e=>{u.push(e)},onKeyDown:h,onClick:m,...r,className:(0,l.A)("tabs__item","tabItem_e1w9",r?.className,{"tabs__item--active":t===e}),children:n??e},e))})}function u({children:e}){return(0,s.jsx)("div",{className:"margin-top--md",children:e})}function d({className:e,children:t}){return(0,s.jsxs)("div",{className:(0,l.A)(r.G.tabs.container,"tabs-container","tabList_mVW_"),children:[(0,s.jsx)(c,{className:e}),(0,s.jsx)(u,{children:t})]})}function m(e){let t=(0,o.A)(),n=(0,i.OC)(e);return(0,s.jsx)(i.O_,{value:n,children:(0,s.jsx)(d,{className:e.className,children:(0,i.vT)(e.children)})},String(t))}}
1,28226(e,t,n){n.d(t,{OC:()=>m,O_:()=>b,uc:()=>p,vT:()=>u});var s=n(65723),l=n(22155),r=n(62934),i=n(24127),a=n(12910),o=n(22399),c=n(6660);function u(e){return l.Children.toArray(e).filter(e=>"\n"!==e)}function d({value:e,tabValues:t}){return t.some(t=>t.value===e)}function m(e){let t,{defaultValue:n,queryString:s=!1,groupId:u}=e,m=function(e){let{values:t,children:n}=e;return(0,l.useMemo)(()=>{let e=t??l.Children.toArray(n).flatMap(e=>{if(!e)return[];if((0,l.isValidElement)(e)&&function(e){let{props:t}=e;return!!t&&"object"==typeof t&&"value"in t}(e))return[e];let t="string"==typeof e.type?e.type:e.type.name;throw Error(`Docusaurus error: Bad <Tabs> child <${t}>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.
2If you do not want to pass on a "value" prop to the direct children of <Tabs>, you can also pass an explicit <Tabs values={...}> prop.`)}).map(({props:{value:e,label:t,attributes:n,default:s}})=>({value:e,label:t,attributes:n,default:s})),s=(0,o.XI)(e,(e,t)=>e.value===t.value);if(s.length>0)throw Error(`Docusaurus error: Duplicate values "${s.map(e=>`'${e.value}'`).join(", ")}" found in <Tabs>. Every value needs to be unique.`);return e},[t,n])}(e),[h,p]=(0,l.useState)(()=>(function({defaultValue:e,tabValues:t}){if(0===t.length)throw Error("Docusaurus error: the <Tabs> component requires at least one <TabItem> children component");if(e){if(!d({value:e,tabValues:t}))throw Error(`Docusaurus error: The <Tabs> has a defaultValue "${e}" but none of its children has the corresponding value. Available values are: ${t.map(e=>e.value).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return e}let n=t.find(e=>e.default)??t[0];if(!n)throw Error("Unexpected error: 0 tabValues");return n.value})({defaultValue:n,tabValues:m})),[b,f]=function({queryString:e=!1,groupId:t}){let n=(0,r.W6)(),s=function({queryString:e=!1,groupId:t}){if("string"==typeof e)return e;if(!1===e)return null;if(!0===e&&!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 t??null}({queryString:e,groupId:t});return[(0,a.aZ)(s),(0,l.useCallback)(e=>{if(!s)return;let t=new URLSearchParams(n.location.search);t.set(s,e),n.replace({...n.location,search:t.toString()})},[s,n])]}({queryString:s,groupId:u}),[x,g]=function({groupId:e}){let t=e?`docusaurus.tab.${e}`:null,[n,s]=(0,c.Dv)(t);return[n,(0,l.useCallback)(e=>{t&&s.set(e)},[t,s])]}({groupId:u}),j=d({value:t=b??x,tabValues:m})?t:null;return(0,i.A)(()=>{j&&p(j)},[j]),{selectedValue:h,selectValue:(0,l.useCallback)(e=>{if(!d({value:e,tabValues:m}))throw Error(`Can't select invalid tab value=${e}`);p(e),f(e),g(e)},[f,g,m]),tabValues:m,lazy:e.lazy??!1,block:e.block??!1}}let h=(0,l.createContext)(null);function p(){let e=l.useContext(h);if(!e)throw Error("useTabsContext() must be used within a Tabs component");return e}function b(e){return(0,s.jsx)(h.Provider,{value:e.value,children:e.children})}},7143(e,t,n){n.d(t,{R:()=>i,x:()=>a});var s=n(22155);let l={},r=s.createContext(l);function i(e){let t=s.useContext(r);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function a(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:i(e.components),s.createElement(r.Provider,{value:t},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.