1:HL["/_next/static/css/275839517c59c532.css",{"as":"style"}] 2:HL["/_next/static/css/bdb880d990e879b6.css",{"as":"style"}] 0:[[["",{"children":["post",{"children":[["slug","eslint-rules-specific-to-your-project","d"],{"children":["__PAGE__?{\"slug\":\"eslint-rules-specific-to-your-project\"}",{}]}]}]},"$undefined","$undefined",true],"$L3",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/275839517c59c532.css","precedence":"next"}],["$","link","1",{"rel":"stylesheet","href":"/_next/static/css/bdb880d990e879b6.css","precedence":"next"}]],["$L4",null]]]] 5:HL["/_next/static/css/95c7fb627fba8423.css",{"as":"style"}] 6:HL["/_next/static/css/477df780fc5cb593.css",{"as":"style"}] 7:HL["/_next/static/css/c40a92e7f996f910.css",{"as":"style"}] 3:["$L8",null] 4:[["$","meta","0",{"charSet":"utf-8"}],["$","title","1",{"children":"针对项目定制的 ESLint Rules"}],["$","meta","2",{"name":"description","content":"针对项目定制的 ESLint Rules"}],["$","link","3",{"rel":"manifest","href":"/manifest.json"}],["$","meta","4",{"name":"generator","content":"Hexo.js & Next.js"}],["$","meta","5",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","6",{"property":"og:title","content":"针对项目定制的 ESLint Rules"}],["$","meta","7",{"property":"og:description","content":"针对项目定制的 ESLint Rules"}],["$","meta","8",{"name":"twitter:card","content":"summary"}],["$","meta","9",{"name":"twitter:title","content":"针对项目定制的 ESLint Rules"}],["$","meta","10",{"name":"twitter:description","content":"针对项目定制的 ESLint Rules"}]] 9:I{"id":"7477","chunks":["194:static/chunks/194-26e3c21be498c0ce.js","859:static/chunks/859-ea023633456a13f8.js","355:static/chunks/app/tags/[slug]/page-257dc97429efd72a.js"],"name":"","async":false} a:I{"id":"92","chunks":["194:static/chunks/194-26e3c21be498c0ce.js","92:static/chunks/92-371a458fbe090447.js","284:static/chunks/284-b1d21b691d3eabee.js","605:static/chunks/app/post/[slug]/page-0339b76e369b6af8.js"],"name":"","async":false} b:I{"id":"2449","chunks":["194:static/chunks/194-26e3c21be498c0ce.js","92:static/chunks/92-371a458fbe090447.js","185:static/chunks/app/layout-4eab34e1c4d9af8d.js"],"name":"","async":false} c:I{"id":"3211","chunks":["272:static/chunks/webpack-7471fa70de6bdb29.js","253:static/chunks/bce60fc1-2413e66000a5dd8f.js","769:static/chunks/769-2bf088c0a421e73d.js"],"name":"","async":false} d:I{"id":"5767","chunks":["272:static/chunks/webpack-7471fa70de6bdb29.js","253:static/chunks/bce60fc1-2413e66000a5dd8f.js","769:static/chunks/769-2bf088c0a421e73d.js"],"name":"","async":false} f:I{"id":"6424","chunks":["194:static/chunks/194-26e3c21be498c0ce.js","92:static/chunks/92-371a458fbe090447.js","185:static/chunks/app/layout-4eab34e1c4d9af8d.js"],"name":"GaLite","async":false} 10:I{"id":"9869","chunks":["194:static/chunks/194-26e3c21be498c0ce.js","92:static/chunks/92-371a458fbe090447.js","185:static/chunks/app/layout-4eab34e1c4d9af8d.js"],"name":"SpeedInsights","async":false} 11:I{"id":"7148","chunks":["194:static/chunks/194-26e3c21be498c0ce.js","92:static/chunks/92-371a458fbe090447.js","185:static/chunks/app/layout-4eab34e1c4d9af8d.js"],"name":"Analytics","async":false} 8:["$","html",null,{"lang":"zh-CN","children":[["$","link",null,{"rel":"icon","href":"/images/icons/icon-72x72.png","type":"image/x-icon"}],["$","link",null,{"rel":"preconnect","href":"https://vip2.loli.io"}],["$","link",null,{"rel":"dns-prefetch","href":"https://vip2.loli.io"}],["$","link",null,{"rel":"alternate","type":"application/atom+xml","href":"/atom.xml"}],["$","body",null,{"children":["$","div",null,{"className":"kbCXHY jdraHW eqrBPF kEFtPS bNzOWQ juexza kXMrYr ","children":[["$","header",null,{"className":"doNOqr WhAZY cRUUAa cwMEsi dpJmjl bsTuZj iRietU JCsMI fONtwf eEsPgn gWUoqV kazZiE fsKTUV dkPCxO gdGTeM ","children":[["$","div",null,{"className":"doNOqr WhAZY hrtgtE iYRJzs iJGxaV jlwzhw ","children":[["$","$L9",null,{"className":"icyDkI gSBWlu foGVKH IVbXa kooHYa JxWnH cVJMrm hyoqRt jlijat kUpitc gdtkYW iDPWLw kayxZK hCkclF cneMsd gYPNzh ","href":"/","children":[["$","div",null,{"className":"eSltVp cpOcAb caItCN cyerGB dSxtaa lbEyiT kUPESX Pmecg ldtSOY ","children":["$","$La",null,{"src":"https://vip2.loli.io/2023/03/09/2tAMcy694lE3IZX.jpg","blurDataURL":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAIAAAACDbGyAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAW0lEQVR4nAFQAK//AAAAAA0MCD08JoiyXkqWNQBPSDHtwYf/86ehuWNAeS4Aep9O+bt9/9aWxbtzETMSAClqHld9MqambcuqdgMOAwBCaS1Mdzd/hFE4PCMEEAS4ex049PWXOAAAAABJRU5ErkJggg==","alt":"avatar","width":200,"height":200,"layout":"responsive","className":"jWjrEQ eKtERL BRobm iovjFN ","placeholder":"blur","priority":true}]}],["$","h1",null,{"className":"evYdWj cpOcAb XEVlt huiurs ","children":"fengkx's Blog"}]]}],["$","h2",null,{"id":"name","className":"hrtgtE fcXWHl ","children":"fengkx"}],["$","h3",null,{"id":"title","className":"hrtgtE fcXWHl ","children":"Student & Coder"}],["$","div",null,{"className":"fONtwf fcXWHl foGVKH IVbXa dPVLzs fkrGAA cvCecb jJGIjV ","children":[["$","svg",null,{"stroke":"currentColor","fill":"none","strokeWidth":"2","viewBox":"0 0 24 24","strokeLinecap":"round","strokeLinejoin":"round","children":["$undefined",[["$","path","0",{"d":"M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z","children":"$undefined"}],["$","circle","1",{"cx":"12","cy":"10","r":"3","children":"$undefined"}]]],"className":"$undefined","style":{"color":"$undefined"},"height":"1em","width":"1em","xmlns":"http://www.w3.org/2000/svg"}],["$","span",null,{"className":"gUpJEt ","children":"Guangzhou, China"}]]}],["$","nav",null,{"className":"hrtgtE jlwzhw gSBWlu IVbXa kKRHCo jzaqKj ehqwGF ","children":[["$","div",null,{"className":"kooHYa ","children":["$","$L9",null,{"className":"gSBWlu foGVKH fPWmiY JxWnH cVJMrm OqOoD jJbtJp ihIJmy bgUfpT AsNjI kwISoH gdPTUr eLDTYY dmKgnC dPFrWx bmQfsF krqYva kXurrt ","href":"/","children":[["$","svg",null,{"stroke":"currentColor","fill":"none","strokeWidth":"2","viewBox":"0 0 24 24","strokeLinecap":"round","strokeLinejoin":"round","className":"jJhMtm fcXWHl gdPTUr dCiVRS TTRIX ","children":["$undefined",[["$","path","0",{"d":"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z","children":"$undefined"}],["$","polyline","1",{"points":"9 22 9 12 15 12 15 22","children":"$undefined"}]]],"style":{"color":"$undefined"},"height":"1em","width":"1em","xmlns":"http://www.w3.org/2000/svg"}],["$","span",null,{"className":"","children":"首页"}]]}]}],["$","div",null,{"className":"kooHYa ","children":["$","$L9",null,{"className":"gSBWlu foGVKH fPWmiY JxWnH cVJMrm OqOoD jJbtJp ihIJmy bgUfpT AsNjI kwISoH gdPTUr eLDTYY dmKgnC dPFrWx bmQfsF krqYva kXurrt ","href":"/archives","children":[["$","svg",null,{"stroke":"currentColor","fill":"none","strokeWidth":"2","viewBox":"0 0 24 24","strokeLinecap":"round","strokeLinejoin":"round","className":"jJhMtm fcXWHl gdPTUr dCiVRS TTRIX ","children":["$undefined",[["$","polyline","0",{"points":"21 8 21 21 3 21 3 8","children":"$undefined"}],["$","rect","1",{"x":"1","y":"3","width":"22","height":"5","children":"$undefined"}],["$","line","2",{"x1":"10","y1":"12","x2":"14","y2":"12","children":"$undefined"}]]],"style":{"color":"$undefined"},"height":"1em","width":"1em","xmlns":"http://www.w3.org/2000/svg"}],["$","span",null,{"className":"","children":"归档"}]]}]}],["$","div",null,{"className":"kooHYa ","children":["$","$L9",null,{"className":"gSBWlu foGVKH fPWmiY JxWnH cVJMrm OqOoD jJbtJp ihIJmy bgUfpT AsNjI kwISoH gdPTUr eLDTYY dmKgnC dPFrWx bmQfsF krqYva kXurrt ","href":"/tags","children":[["$","svg",null,{"stroke":"currentColor","fill":"none","strokeWidth":"2","viewBox":"0 0 24 24","strokeLinecap":"round","strokeLinejoin":"round","className":"jJhMtm fcXWHl gdPTUr dCiVRS TTRIX ","children":["$undefined",[["$","path","0",{"d":"M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z","children":"$undefined"}],["$","line","1",{"x1":"7","y1":"7","x2":"7.01","y2":"7","children":"$undefined"}]]],"style":{"color":"$undefined"},"height":"1em","width":"1em","xmlns":"http://www.w3.org/2000/svg"}],["$","span",null,{"className":"","children":"标签"}]]}]}],["$","div",null,{"className":"kooHYa ","children":["$","$L9",null,{"className":"gSBWlu foGVKH fPWmiY JxWnH cVJMrm OqOoD jJbtJp ihIJmy bgUfpT AsNjI kwISoH gdPTUr eLDTYY dmKgnC dPFrWx bmQfsF krqYva kXurrt ","href":"/links","children":[["$","svg",null,{"stroke":"currentColor","fill":"none","strokeWidth":"2","viewBox":"0 0 24 24","strokeLinecap":"round","strokeLinejoin":"round","className":"jJhMtm fcXWHl gdPTUr dCiVRS TTRIX ","children":["$undefined",[["$","path","0",{"d":"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2","children":"$undefined"}],["$","circle","1",{"cx":"9","cy":"7","r":"4","children":"$undefined"}],["$","path","2",{"d":"M23 21v-2a4 4 0 0 0-3-3.87","children":"$undefined"}],["$","path","3",{"d":"M16 3.13a4 4 0 0 1 0 7.75","children":"$undefined"}]]],"style":{"color":"$undefined"},"height":"1em","width":"1em","xmlns":"http://www.w3.org/2000/svg"}],["$","span",null,{"className":"","children":"友链"}]]}]}],["$","div",null,{"className":"kooHYa ","children":["$","$L9",null,{"className":"gSBWlu foGVKH fPWmiY JxWnH cVJMrm OqOoD jJbtJp ihIJmy bgUfpT AsNjI kwISoH gdPTUr eLDTYY dmKgnC dPFrWx bmQfsF krqYva kXurrt ","href":"/about","children":[["$","svg",null,{"stroke":"currentColor","fill":"none","strokeWidth":"2","viewBox":"0 0 24 24","strokeLinecap":"round","strokeLinejoin":"round","className":"jJhMtm fcXWHl gdPTUr dCiVRS TTRIX ","children":["$undefined",[["$","path","0",{"d":"M18 8h1a4 4 0 0 1 0 8h-1","children":"$undefined"}],["$","path","1",{"d":"M2 8h16v9a4 4 0 0 1-4 4H6a4 4 0 0 1-4-4V8z","children":"$undefined"}],["$","line","2",{"x1":"6","y1":"1","x2":"6","y2":"4","children":"$undefined"}],["$","line","3",{"x1":"10","y1":"1","x2":"10","y2":"4","children":"$undefined"}],["$","line","4",{"x1":"14","y1":"1","x2":"14","y2":"4","children":"$undefined"}]]],"style":{"color":"$undefined"},"height":"1em","width":"1em","xmlns":"http://www.w3.org/2000/svg"}],["$","span",null,{"className":"","children":"关于"}]]}]}],["$","div",null,{"className":"kooHYa ","children":["$","$L9",null,{"className":"gSBWlu foGVKH fPWmiY JxWnH cVJMrm OqOoD jJbtJp ihIJmy bgUfpT AsNjI kwISoH gdPTUr eLDTYY dmKgnC dPFrWx bmQfsF krqYva kXurrt ","href":"/search","children":[["$","svg",null,{"stroke":"currentColor","fill":"none","strokeWidth":"2","viewBox":"0 0 24 24","strokeLinecap":"round","strokeLinejoin":"round","className":"cpOcAb gdPTUr dCiVRS TTRIX ","children":["$undefined",[["$","circle","0",{"cx":"11","cy":"11","r":"8","children":"$undefined"}],["$","line","1",{"x1":"21","y1":"21","x2":"16.65","y2":"16.65","children":"$undefined"}]]],"style":{"color":"$undefined"},"height":"1em","width":"1em","xmlns":"http://www.w3.org/2000/svg"}],["$","span",null,{"className":"jJhMtm fcXWHl ","children":"搜索"}]]}]}],["$","div",null,{"className":"kooHYa evYdWj ","children":["$","$L9",null,{"className":"gSBWlu foGVKH fPWmiY JxWnH cVJMrm OqOoD jJbtJp ihIJmy bgUfpT AsNjI kwISoH gdPTUr eLDTYY dmKgnC dPFrWx bmQfsF krqYva kXurrt ","href":"/atom.xml","prefetch":false,"children":[["$","svg",null,{"stroke":"currentColor","fill":"none","strokeWidth":"2","viewBox":"0 0 24 24","strokeLinecap":"round","strokeLinejoin":"round","className":"cpOcAb gdPTUr dCiVRS TTRIX ","children":["$undefined",[["$","path","0",{"d":"M4 11a9 9 0 0 1 9 9","children":"$undefined"}],["$","path","1",{"d":"M4 4a16 16 0 0 1 16 16","children":"$undefined"}],["$","circle","2",{"cx":"5","cy":"19","r":"1","children":"$undefined"}]]],"style":{"color":"$undefined"},"height":"1em","width":"1em","xmlns":"http://www.w3.org/2000/svg"}],["$","span",null,{"className":"jJhMtm fcXWHl ","children":"RSS"}]]}]}]]}]]}],["$","div",null,{"className":"doNOqr hrtgtE fcXWHl iigETV bMSzLf XEVlt jmezSN izetJs kdrTtD bLIxaN ","children":[["$","div",null,{"className":"iLYBKc gSBWlu zEGrF evYWGf hDdCaA ","children":[["$","$L9",null,{"title":"fengkx's GitHub","href":"https://github.com/fengkx","prefetch":false,"children":["$","svg",null,{"stroke":"currentColor","fill":"none","strokeWidth":"2","viewBox":"0 0 24 24","strokeLinecap":"round","strokeLinejoin":"round","children":["$undefined",[["$","path","0",{"d":"M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22","children":"$undefined"}]]],"className":"$undefined","style":{"color":"$undefined"},"height":"1em","width":"1em","xmlns":"http://www.w3.org/2000/svg"}]}],["$","$L9",null,{"title":"fengkx's Telegram","href":"https://t.me/fengkx","prefetch":false,"children":["$","svg",null,{"stroke":"currentColor","fill":"none","strokeWidth":"2","viewBox":"0 0 24 24","strokeLinecap":"round","strokeLinejoin":"round","children":["$undefined",[["$","line","0",{"x1":"22","y1":"2","x2":"11","y2":"13","children":"$undefined"}],["$","polygon","1",{"points":"22 2 15 22 11 13 2 9 22 2","children":"$undefined"}]]],"className":"$undefined","style":{"color":"$undefined"},"height":"1em","width":"1em","xmlns":"http://www.w3.org/2000/svg"}]}],["$","$L9",null,{"href":"https://mstdn.social/@fengkx","rel":"me","prefetch":false,"children":["$","svg",null,{"stroke":"currentColor","fill":"none","strokeWidth":"2","viewBox":"0 0 24 24","strokeLinecap":"round","strokeLinejoin":"round","children":["$undefined",[["$","path","0",{"stroke":"none","d":"M0 0h24v24H0z","fill":"none","children":"$undefined"}],["$","path","1",{"d":"M18.648 15.254c-1.816 1.763 -6.648 1.626 -6.648 1.626a18.262 18.262 0 0 1 -3.288 -.256c1.127 1.985 4.12 2.81 8.982 2.475c-1.945 2.013 -13.598 5.257 -13.668 -7.636l-.026 -1.154c0 -3.036 .023 -4.115 1.352 -5.633c1.671 -1.91 6.648 -1.666 6.648 -1.666s4.977 -.243 6.648 1.667c1.329 1.518 1.352 2.597 1.352 5.633s-.456 4.074 -1.352 4.944z","children":"$undefined"}],["$","path","2",{"d":"M12 11.204v-2.926c0 -1.258 -.895 -2.278 -2 -2.278s-2 1.02 -2 2.278v4.722m4 -4.722c0 -1.258 .895 -2.278 2 -2.278s2 1.02 2 2.278v4.722","children":"$undefined"}]]],"className":"$undefined","style":{"color":"$undefined"},"height":"1em","width":"1em","xmlns":"http://www.w3.org/2000/svg"}]}],["$","$L9",null,{"title":"RSS feed","href":"/atom.xml","prefetch":false,"children":["$","svg",null,{"stroke":"currentColor","fill":"none","strokeWidth":"2","viewBox":"0 0 24 24","strokeLinecap":"round","strokeLinejoin":"round","children":["$undefined",[["$","path","0",{"d":"M4 11a9 9 0 0 1 9 9","children":"$undefined"}],["$","path","1",{"d":"M4 4a16 16 0 0 1 16 16","children":"$undefined"}],["$","circle","2",{"cx":"5","cy":"19","r":"1","children":"$undefined"}]]],"className":"$undefined","style":{"color":"$undefined"},"height":"1em","width":"1em","xmlns":"http://www.w3.org/2000/svg"}]}]]}],["$","div",null,{"className":"hrtgtE fcXWHl cyerGB kKRHCo ","children":["Build with ",["$","$L9",null,{"title":"Hexo official site","rel":"noopener noreferrer external nofollow","href":"https://hexo.io","children":"Hexo"}]," ","and"," ",["$","$L9",null,{"title":"Next.js official site","href":"https://nextjs.org","rel":"noopener noreferrer external nofollow","children":"Next.js"}]]}]]}]]}],["$","$Lb",null,{"children":["$","$Lc",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"template":["$","$Ld",null,{}],"templateStyles":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","childProp":{"current":["$","$Lc",null,{"parallelRouterKey":"children","segmentPath":["children","post","children"],"error":"$undefined","errorStyles":"$undefined","loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"template":["$","$Ld",null,{}],"templateStyles":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","childProp":{"current":["$","$Lc",null,{"parallelRouterKey":"children","segmentPath":["children","post","children",["slug","eslint-rules-specific-to-your-project","d"],"children"],"error":"$undefined","errorStyles":"$undefined","loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"template":["$","$Ld",null,{}],"templateStyles":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","childProp":{"current":["$Le",null],"segment":"__PAGE__?{\"slug\":\"eslint-rules-specific-to-your-project\"}"},"styles":[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/275839517c59c532.css","precedence":"next"}],["$","link","1",{"rel":"stylesheet","href":"/_next/static/css/95c7fb627fba8423.css","precedence":"next"}],["$","link","2",{"rel":"stylesheet","href":"/_next/static/css/477df780fc5cb593.css","precedence":"next"}],["$","link","3",{"rel":"stylesheet","href":"/_next/static/css/c40a92e7f996f910.css","precedence":"next"}]]}],"segment":["slug","eslint-rules-specific-to-your-project","d"]},"styles":[]}],"segment":"post"},"styles":[]}]}],["$","$Lf",null,{"uaId":"UA-103237573-1"}],["$","$L10",null,{}],["$","$L11",null,{}]]}]}]]}] 13:I{"id":"5307","chunks":["194:static/chunks/194-26e3c21be498c0ce.js","92:static/chunks/92-371a458fbe090447.js","284:static/chunks/284-b1d21b691d3eabee.js","605:static/chunks/app/post/[slug]/page-0339b76e369b6af8.js"],"name":"TocTitle","async":false} e:[false,["$","main",null,{"className":"prose eUUCKp kTeytq jmezSN cjScYX eqrBPF jdraHW cRUUAa DOWJl hgvoZN iZwowi jGHqUK kwISoH AsNjI","children":[["$","h1",null,{"className":"EKhXX ","children":"针对项目定制的 ESLint Rules"}],"$L12"]}],["$","aside",null,{"className":"cwMEsi dpJmjl gWUoqV kazZiE fsKTUV dkPCxO fcXWHl hrtgtE icKiSN eeREmo fZMRmg hRjOno ","children":["$","div",null,{"className":"doNOqr gepZXl AsideContainer_asideContainer___FNWl","children":["$","div",null,{"className":"bKqOie lkcNSa doNOqr dNtEOi ","children":[["$","div",null,{"className":"hlBtvm ckBWJI XEVlt ","children":"文章目录"}],["$","div",null,{"className":"$undefined","children":["$","ol",null,{"className":"jOeduE ","children":[["$","li",null,{"children":[["$","$L13",null,{"id":"自定义-rules","text":"自定义 rules"}],["$","ol",null,{"className":"jOeduE iDuqPI ","children":[["$","li",null,{"children":[["$","$L13",null,{"id":"例子:小程序自定义组件中防止额外触发内置事件","text":"例子:小程序自定义组件中防止额外触发内置事件"}],false]}]]}]]}],["$","li",null,{"children":[["$","$L13",null,{"id":"rulesdir","text":"rulesdir"}],false]}]]}]}]]}]}]}]] 14:I{"id":"4998","chunks":["194:static/chunks/194-26e3c21be498c0ce.js","92:static/chunks/92-371a458fbe090447.js","284:static/chunks/284-b1d21b691d3eabee.js","605:static/chunks/app/post/[slug]/page-0339b76e369b6af8.js"],"name":"ArticleContentClient","async":false} 15:I{"id":"7974","chunks":["194:static/chunks/194-26e3c21be498c0ce.js","92:static/chunks/92-371a458fbe090447.js","284:static/chunks/284-b1d21b691d3eabee.js","605:static/chunks/app/post/[slug]/page-0339b76e369b6af8.js"],"name":"H2","async":false} 19:I{"id":"7974","chunks":["194:static/chunks/194-26e3c21be498c0ce.js","92:static/chunks/92-371a458fbe090447.js","284:static/chunks/284-b1d21b691d3eabee.js","605:static/chunks/app/post/[slug]/page-0339b76e369b6af8.js"],"name":"H3","async":false} 12:["$","$L14",null,{"permalink":"https://www.fengkx.top/post/eslint-rules-specific-to-your-project/","dateString":"2022-06-26","comments":true,"aplayer":false,"showCopyright":true,"children":[["$","p","1240",{"children":["现在写 JavaScript 项目,ESlint 可以说是标配。静态检查虽不执行代码,主要检查 AST 和文件路径,但也可以检查出很多东西。比如说 import 的文件是否真是存在,React Hooks 用法有没有问题等等。有时候一些项目写法上有特殊的限制,也可以通过 eslint 来自动化代码检查。这时就需要自定义 eslint rules。"]}],"\n",["$","$L15","1241",{"id":"自定义-rules","children":["自定义 rules"]}],"\n",["$","p","1247",{"children":["rules 的写法详细的可以看","$L16",",不再赘述。",["$","br","1243",{}],"\n最重要的地方就是 export 的对象的 create 对象。在 create 对象中,key 是一个","$L17",",value 则是对应的 handler,在 handler 就可以通过",["$","code","1245",{"children":["context.report"]}],"来对有问题的代码报错。语法树可以用","$L18","来看。"]}],"\n",["$","$L19","1248",{"id":"例子:小程序自定义组件中防止额外触发内置事件","children":["例子:小程序自定义组件中防止额外触发内置事件"]}],"\n",["$","p","1255",{"children":["在小程序自定义组件可以通过",["$","code","1249",{"children":["this.triggerEvent('eventName', ...)"]}],"来触发",["$","code","1250",{"children":["eventName"]}],"事件。但是有一些内置事件是不需要额外触发的,比如",["$","code","1251",{"children":["tap"]}],", ",["$","code","1252",{"children":["longpress"]}]," 之类的。我们就而可以写一个 rule 来禁止手动触发这些事件。",["$","br","1253",{}],"\n根据","$L1a",",可以写出下面这个 rule。"]}],"\n",["$","pre","1446",{"className":"shiki github-light","style":{"backgroundColor":"#fff","color":"#24292e"},"tabindex":"0","children":[["$","code","1445",{"className":"language-javascript","children":[["$","span","1257",{"className":"line","children":[["$","span","1256",{"style":{"color":"#6A737D"},"children":["// 内置事件"]}]]}],"\n",["$","span","1262",{"className":"line","children":[["$","span","1258",{"style":{"color":"#D73A49"},"children":["const"]}],["$","span","1259",{"style":{"color":"#005CC5"},"children":[" bulidinEvents"]}],["$","span","1260",{"style":{"color":"#D73A49"},"children":[" ="]}],["$","span","1261",{"style":{"color":"#24292E"},"children":[" ["]}]]}],"\n",["$","span","1265",{"className":"line","children":[["$","span","1263",{"style":{"color":"#032F62"},"children":[" 'tap'"]}],["$","span","1264",{"style":{"color":"#24292E"},"children":[","]}]]}],"\n",["$","span","1268",{"className":"line","children":[["$","span","1266",{"style":{"color":"#032F62"},"children":[" 'longpress'"]}],["$","span","1267",{"style":{"color":"#24292E"},"children":[","]}]]}],"\n",["$","span","1271",{"className":"line","children":[["$","span","1269",{"style":{"color":"#032F62"},"children":[" 'longtap'"]}],["$","span","1270",{"style":{"color":"#24292E"},"children":[","]}]]}],"\n",["$","span","1273",{"className":"line","children":[["$","span","1272",{"style":{"color":"#6A737D"},"children":[" // ..."]}]]}],"\n",["$","span","1275",{"className":"line","children":[["$","span","1274",{"style":{"color":"#24292E"},"children":[" ];"]}]]}],"\n",["$","span","1276",{"className":"line","children":[]}],"\n",["$","span","1281",{"className":"line","children":[["$","span","1277",{"style":{"color":"#6A737D"},"children":["/** "]}],["$","span","1278",{"style":{"color":"#D73A49"},"children":["@type"]}],["$","span","1279",{"style":{"color":"#6F42C1"},"children":[" {import('eslint').Rule.RuleModule}"]}],["$","span","1280",{"style":{"color":"#6A737D"},"children":[" */"]}]]}],"\n",["$","span","1287",{"className":"line","children":[["$","span","1282",{"style":{"color":"#005CC5"},"children":["module"]}],["$","span","1283",{"style":{"color":"#24292E"},"children":["."]}],["$","span","1284",{"style":{"color":"#005CC5"},"children":["exports"]}],["$","span","1285",{"style":{"color":"#D73A49"},"children":[" ="]}],["$","span","1286",{"style":{"color":"#24292E"},"children":[" {"]}]]}],"\n",["$","span","1289",{"className":"line","children":[["$","span","1288",{"style":{"color":"#24292E"},"children":[" meta: {"]}]]}],"\n",["$","span","1293",{"className":"line","children":[["$","span","1290",{"style":{"color":"#24292E"},"children":[" type: "]}],["$","span","1291",{"style":{"color":"#032F62"},"children":["'problem'"]}],["$","span","1292",{"style":{"color":"#24292E"},"children":[","]}]]}],"\n",["$","span","1294",{"className":"line","children":[]}],"\n",["$","span","1296",{"className":"line","children":[["$","span","1295",{"style":{"color":"#24292E"},"children":[" docs: {"]}]]}],"\n",["$","span","1300",{"className":"line","children":[["$","span","1297",{"style":{"color":"#24292E"},"children":[" description: "]}],["$","span","1298",{"style":{"color":"#032F62"},"children":["'disallow trigger builtin events manually in miniprogram'"]}],["$","span","1299",{"style":{"color":"#24292E"},"children":[","]}]]}],"\n",["$","span","1304",{"className":"line","children":[["$","span","1301",{"style":{"color":"#24292E"},"children":[" category: "]}],["$","span","1302",{"style":{"color":"#032F62"},"children":["'Possible Errors'"]}],["$","span","1303",{"style":{"color":"#24292E"},"children":[","]}]]}],"\n",["$","span","1308",{"className":"line","children":[["$","span","1305",{"style":{"color":"#24292E"},"children":[" recommended: "]}],["$","span","1306",{"style":{"color":"#005CC5"},"children":["true"]}],["$","span","1307",{"style":{"color":"#24292E"},"children":[","]}]]}],"\n",["$","span","1310",{"className":"line","children":[["$","span","1309",{"style":{"color":"#24292E"},"children":[" },"]}]]}],"\n",["$","span","1312",{"className":"line","children":[["$","span","1311",{"style":{"color":"#24292E"},"children":[" schema: ["]}]]}],"\n",["$","span","1314",{"className":"line","children":[["$","span","1313",{"style":{"color":"#24292E"},"children":[" {"]}]]}],"\n",["$","span","1320",{"className":"line","children":[["$","span","1315",{"style":{"color":"#24292E"},"children":[" enum: ["]}],["$","span","1316",{"style":{"color":"#032F62"},"children":["'always'"]}],["$","span","1317",{"style":{"color":"#24292E"},"children":[", "]}],["$","span","1318",{"style":{"color":"#032F62"},"children":["'never'"]}],["$","span","1319",{"style":{"color":"#24292E"},"children":["],"]}]]}],"\n",["$","span","1322",{"className":"line","children":[["$","span","1321",{"style":{"color":"#24292E"},"children":[" },"]}]]}],"\n",["$","span","1324",{"className":"line","children":[["$","span","1323",{"style":{"color":"#24292E"},"children":[" ],"]}]]}],"\n",["$","span","1326",{"className":"line","children":[["$","span","1325",{"style":{"color":"#24292E"},"children":[" },"]}]]}],"\n",["$","span","1333",{"className":"line","children":[["$","span","1327",{"style":{"color":"#6F42C1"},"children":[" create"]}],["$","span","1328",{"style":{"color":"#24292E"},"children":[": "]}],["$","span","1329",{"style":{"color":"#D73A49"},"children":["function"]}],["$","span","1330",{"style":{"color":"#24292E"},"children":[" ("]}],["$","span","1331",{"style":{"color":"#E36209"},"children":["context"]}],["$","span","1332",{"style":{"color":"#24292E"},"children":[") {"]}]]}],"\n",["$","span","1336",{"className":"line","children":[["$","span","1334",{"style":{"color":"#D73A49"},"children":[" return"]}],["$","span","1335",{"style":{"color":"#24292E"},"children":[" {"]}]]}],"\n",["$","span","1343",{"className":"line","children":[["$","span","1337",{"style":{"color":"#6F42C1"},"children":[" CallExpression"]}],["$","span","1338",{"style":{"color":"#24292E"},"children":[": "]}],["$","span","1339",{"style":{"color":"#D73A49"},"children":["function"]}],["$","span","1340",{"style":{"color":"#24292E"},"children":[" ("]}],["$","span","1341",{"style":{"color":"#E36209"},"children":["node"]}],["$","span","1342",{"style":{"color":"#24292E"},"children":[") {"]}]]}],"\n",["$","span","1354",{"className":"line","children":[["$","span","1344",{"style":{"color":"#D73A49"},"children":[" const"]}],["$","span","1345",{"style":{"color":"#24292E"},"children":[" { "]}],["$","span","1346",{"style":{"color":"#005CC5"},"children":["callee"]}],["$","span","1347",{"style":{"color":"#24292E"},"children":[", "]}],["$","span","1348",{"style":{"color":"#E36209"},"children":["arguments"]}],["$","span","1349",{"style":{"color":"#24292E"},"children":[": "]}],["$","span","1350",{"style":{"color":"#005CC5"},"children":["args"]}],["$","span","1351",{"style":{"color":"#24292E"},"children":[" } "]}],["$","span","1352",{"style":{"color":"#D73A49"},"children":["="]}],["$","span","1353",{"style":{"color":"#24292E"},"children":[" node;"]}]]}],"\n",["$","span","1360",{"className":"line","children":[["$","span","1355",{"style":{"color":"#D73A49"},"children":[" if"]}],["$","span","1356",{"style":{"color":"#24292E"},"children":[" (callee.type "]}],["$","span","1357",{"style":{"color":"#D73A49"},"children":["==="]}],["$","span","1358",{"style":{"color":"#032F62"},"children":[" 'MemberExpression'"]}],["$","span","1359",{"style":{"color":"#24292E"},"children":[") {"]}]]}],"\n",["$","span","1369",{"className":"line","children":[["$","span","1361",{"style":{"color":"#D73A49"},"children":[" const"]}],["$","span","1362",{"style":{"color":"#24292E"},"children":[" { "]}],["$","span","1363",{"style":{"color":"#005CC5"},"children":["object"]}],["$","span","1364",{"style":{"color":"#24292E"},"children":[", "]}],["$","span","1365",{"style":{"color":"#005CC5"},"children":["property"]}],["$","span","1366",{"style":{"color":"#24292E"},"children":[" } "]}],["$","span","1367",{"style":{"color":"#D73A49"},"children":["="]}],["$","span","1368",{"style":{"color":"#24292E"},"children":[" callee;"]}]]}],"\n",["$","span","1375",{"className":"line","children":[["$","span","1370",{"style":{"color":"#D73A49"},"children":[" if"]}],["$","span","1371",{"style":{"color":"#24292E"},"children":[" (object.type "]}],["$","span","1372",{"style":{"color":"#D73A49"},"children":["==="]}],["$","span","1373",{"style":{"color":"#032F62"},"children":[" 'ThisExpression'"]}],["$","span","1374",{"style":{"color":"#24292E"},"children":[") {"]}]]}],"\n",["$","span","1378",{"className":"line","children":[["$","span","1376",{"style":{"color":"#D73A49"},"children":[" if"]}],["$","span","1377",{"style":{"color":"#24292E"},"children":[" ("]}]]}],"\n",["$","span","1383",{"className":"line","children":[["$","span","1379",{"style":{"color":"#24292E"},"children":[" property.type "]}],["$","span","1380",{"style":{"color":"#D73A49"},"children":["==="]}],["$","span","1381",{"style":{"color":"#032F62"},"children":[" 'Identifier'"]}],["$","span","1382",{"style":{"color":"#D73A49"},"children":[" &&"]}]]}],"\n",["$","span","1387",{"className":"line","children":[["$","span","1384",{"style":{"color":"#24292E"},"children":[" property.name "]}],["$","span","1385",{"style":{"color":"#D73A49"},"children":["==="]}],["$","span","1386",{"style":{"color":"#032F62"},"children":[" 'triggerEvent'"]}]]}],"\n",["$","span","1389",{"className":"line","children":[["$","span","1388",{"style":{"color":"#24292E"},"children":[" ) {"]}]]}],"\n",["$","span","1396",{"className":"line","children":[["$","span","1390",{"style":{"color":"#D73A49"},"children":[" if"]}],["$","span","1391",{"style":{"color":"#24292E"},"children":[" (args."]}],["$","span","1392",{"style":{"color":"#005CC5"},"children":["length"]}],["$","span","1393",{"style":{"color":"#D73A49"},"children":[" >"]}],["$","span","1394",{"style":{"color":"#005CC5"},"children":[" 0"]}],["$","span","1395",{"style":{"color":"#24292E"},"children":[") {"]}]]}],"\n",["$","span","1403",{"className":"line","children":[["$","span","1397",{"style":{"color":"#D73A49"},"children":[" const"]}],["$","span","1398",{"style":{"color":"#005CC5"},"children":[" firstArgrament"]}],["$","span","1399",{"style":{"color":"#D73A49"},"children":[" ="]}],["$","span","1400",{"style":{"color":"#24292E"},"children":[" args["]}],["$","span","1401",{"style":{"color":"#005CC5"},"children":["0"]}],["$","span","1402",{"style":{"color":"#24292E"},"children":["];"]}]]}],"\n",["$","span","1408",{"className":"line","children":[["$","span","1404",{"style":{"color":"#D73A49"},"children":[" const"]}],["$","span","1405",{"style":{"color":"#005CC5"},"children":[" eventName"]}],["$","span","1406",{"style":{"color":"#D73A49"},"children":[" ="]}],["$","span","1407",{"style":{"color":"#24292E"},"children":[" firstArgrament.value;"]}]]}],"\n",["$","span","1413",{"className":"line","children":[["$","span","1409",{"style":{"color":"#D73A49"},"children":[" if"]}],["$","span","1410",{"style":{"color":"#24292E"},"children":[" (bulidinEvents."]}],["$","span","1411",{"style":{"color":"#6F42C1"},"children":["includes"]}],["$","span","1412",{"style":{"color":"#24292E"},"children":["(eventName)) {"]}]]}],"\n",["$","span","1417",{"className":"line","children":[["$","span","1414",{"style":{"color":"#24292E"},"children":[" context."]}],["$","span","1415",{"style":{"color":"#6F42C1"},"children":["report"]}],["$","span","1416",{"style":{"color":"#24292E"},"children":["({"]}]]}],"\n",["$","span","1419",{"className":"line","children":[["$","span","1418",{"style":{"color":"#24292E"},"children":[" node,"]}]]}],"\n",["$","span","1423",{"className":"line","children":[["$","span","1420",{"style":{"color":"#24292E"},"children":[" message: "]}],["$","span","1421",{"style":{"color":"#032F62"},"children":["`trigger builtin events manually in miniprogram is forbidden`"]}],["$","span","1422",{"style":{"color":"#24292E"},"children":[","]}]]}],"\n",["$","span","1425",{"className":"line","children":[["$","span","1424",{"style":{"color":"#24292E"},"children":[" });"]}]]}],"\n",["$","span","1427",{"className":"line","children":[["$","span","1426",{"style":{"color":"#24292E"},"children":[" }"]}]]}],"\n",["$","span","1429",{"className":"line","children":[["$","span","1428",{"style":{"color":"#24292E"},"children":[" }"]}]]}],"\n",["$","span","1431",{"className":"line","children":[["$","span","1430",{"style":{"color":"#24292E"},"children":[" }"]}]]}],"\n",["$","span","1433",{"className":"line","children":[["$","span","1432",{"style":{"color":"#24292E"},"children":[" }"]}]]}],"\n",["$","span","1435",{"className":"line","children":[["$","span","1434",{"style":{"color":"#24292E"},"children":[" }"]}]]}],"\n",["$","span","1437",{"className":"line","children":[["$","span","1436",{"style":{"color":"#24292E"},"children":[" },"]}]]}],"\n",["$","span","1439",{"className":"line","children":[["$","span","1438",{"style":{"color":"#24292E"},"children":[" };"]}]]}],"\n",["$","span","1441",{"className":"line","children":[["$","span","1440",{"style":{"color":"#24292E"},"children":[" },"]}]]}],"\n",["$","span","1443",{"className":"line","children":[["$","span","1442",{"style":{"color":"#24292E"},"children":["};"]}]]}],"\n",["$","span","1444",{"className":"line","children":[]}]]}]]}],"\n",["$","$L15","1447",{"id":"rulesdir","children":["rulesdir"]}],"\n",["$","p","1450",{"children":["要让 rule 生效最简单的方式就是使用","$L1b",",但是不是任何时候我们都有机会去加",["$","code","1449",{"children":["--rules"]}],"。例如在一些集成度比较高的框架中比如 CRA 之类,只提供了修改 config 的方式,不支持修改命令行参数。"]}],"\n",["$","p","1451",{"children":["如果为了项目特异的规则专门发一个 plugin 的 npm 包,不仅显得有些小题大做,还不好维护。最好还是能把 rules 放在主项目内。"]}],"\n",["$","p","1454",{"children":["这里我们可以用","$L1c",", 它利用了 eslint plugin 的机制,在 rules getter 中获取某个目录内的所有 JS 文件作为 rules, 这样们就能在 rules 配置中通过",["$","code","1453",{"children":["rulesdir/"]}],"来使用自定义的 rules 了。"]}],"\n",["$","p","1456",{"children":["比如将上面我们写的 rule 命名为",["$","code","1455",{"children":["no-trigger-builtin-events-manually.js"]}],",放到对应目录中,就而可以配置"]}],"\n",["$","pre","1465",{"className":"shiki github-light","style":{"backgroundColor":"#fff","color":"#24292e"},"tabindex":"0","children":[["$","code","1464",{"className":"language-javascript","children":[["$","span","1463",{"className":"line","children":[["$","span","1457",{"style":{"color":"#032F62"},"children":["'rulesdir/no-trigger-builtin-events-manually'"]}],["$","span","1458",{"style":{"color":"#24292E"},"children":[": ["]}],["$","span","1459",{"style":{"color":"#032F62"},"children":["'error'"]}],["$","span","1460",{"style":{"color":"#24292E"},"children":[", "]}],["$","span","1461",{"style":{"color":"#032F62"},"children":["'always'"]}],["$","span","1462",{"style":{"color":"#24292E"},"children":["]"]}]]}]]}]]}],"\n",["$","p","1466",{"children":["来禁用多余的手动事件触发。"]}],"\n"]}] 16:["$","a",null,{"href":"https://eslint.org/docs/latest/developer-guide/working-with-rules","children":["ESLint 文档"],"target":"_blank","rel":"noopener noreferrer external nofollow"}] 17:["$","a",null,{"href":"https://eslint.org/docs/latest/developer-guide/selectors","children":["selector"],"target":"_blank","rel":"noopener noreferrer external nofollow"}] 18:["$","a",null,{"href":"https://astexplorer.net/","children":["AST Explorer"],"target":"_blank","rel":"noopener noreferrer external nofollow"}] 1a:["$","a",null,{"href":"https://astexplorer.net/#/gist/7b2e6f4b59d997c8550ecca78b7eed21/37e3d4d68ed2a9b444b4ffbdee999a55892e17d9","children":["AST"],"target":"_blank","rel":"noopener noreferrer external nofollow"}] 1b:["$","a",null,{"href":"https://eslint.org/docs/latest/developer-guide/working-with-rules#runtime-rules","children":["runtime rule 的机制"],"target":"_blank","rel":"noopener noreferrer external nofollow"}] 1c:["$","a",null,{"href":"https://github.com/not-an-aardvark/eslint-plugin-rulesdir","children":["eslint-plugin-rulesdir"],"target":"_blank","rel":"noopener noreferrer external nofollow"}]