@ls-stack/extended-lint 0.25.1 → 0.25.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extended-lint.js +1 -1
- package/dist/extended-lint.mjs +1 -1
- package/package.json +1 -1
package/dist/extended-lint.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var zt=Object.create;var ue=Object.defineProperty;var Bt=Object.getOwnPropertyDescriptor;var Xt=Object.getOwnPropertyNames;var Gt=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var qt=(e,t)=>{for(var n in t)ue(e,n,{get:t[n],enumerable:!0})},Je=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Xt(t))!Jt.call(e,o)&&o!==n&&ue(e,o,{get:()=>t[o],enumerable:!(i=Bt(t,o))||i.enumerable});return e};var Kt=(e,t,n)=>(n=e!=null?zt(Gt(e)):{},Je(t||!e||!e.__esModule?ue(n,"default",{value:e,enumerable:!0}):n,e)),Zt=e=>Je(ue({},"__esModule",{value:!0}),e);var tr={};qt(tr,{extendedLintPlugin:()=>er});module.exports=Zt(tr);var te=require("@typescript-eslint/utils");var be=Symbol.for("optional");function H(e){return{...e,[be]:!0}}function qe(e,t){return{enum:e,...t}}function pe(e){return{...e,type:"boolean"}}function F(e){return{...e,type:"string"}}function Z(e){return{...e,type:"number"}}function Ke(e){return{...e,type:"integer"}}function Y(e,t){return{...t,type:"array",items:e}}function M(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let i,o=[];for(i in e)e[i][be]?e[i][be]=void 0:o.push(i);o.length>0&&(n.required=o)}return n}function xe(...e){return{anyOf:e}}var Qt=te.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),en=M({disallow:H(Y(M({selector:F(),message:F(),replace:H(xe(F(),M({regex:F(),with:F()}))),replaceType:H(qe(["suggestion","autofix"]))}))),__dev_simulateFileName:H(F()),mustMatchSyntax:H(Y(M({includeRegex:F(),mustCallFn:Y(M({anyCall:Y(M({fn:F(),withArgs:Y(M({atIndex:Ke(),literal:xe(F(),Z(),pe())}))})),message:H(F())}))})))}),et="advanced-no-restricted-syntax",tn=Qt({name:et,meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[en],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:i,__dev_simulateFileName:o,disallow:u}=t,m=o??e.filename,l=[],r=new Set;for(let{includeRegex:s,mustCallFn:f}of i??[]){let R=nn(m,new RegExp(s));if(!R)continue;let v=$=>{let E=$;for(let{name:C,value:g}of R)E=E.replaceAll(C,g);return E};for(let{anyCall:$,message:E}of f){let C=`Expected file to call the function: ${$.map(({fn:g})=>g).join(" or ")}`;r.add(C),l.push(g=>{let{callee:O}=g;if(O.type===te.AST_NODE_TYPES.Identifier){for(let{fn:I,withArgs:d}of $)if(O.name===I){r.delete(C);for(let b of d){let x=g.arguments[b.atIndex],w=typeof b.literal=="string"?v(b.literal):b.literal;if(!x){e.report({node:g,messageId:"default",data:{message:`Missing argument with value "${w}" at index ${b.atIndex}${E?`: ${v(E)}`:""}`}});continue}if(x.type!==te.AST_NODE_TYPES.Literal){e.report({node:x,messageId:"default",data:{message:`Argument at position ${b.atIndex} should the literal "${w}"${E?`: ${v(E)}`:""}`}});continue}x.value!==w&&e.report({node:x,messageId:"default",data:{message:`Argument should have the value "${w}"${E?`: ${v(E)}`:""}`},fix:D=>D.replaceText(x,typeof w=="string"?`'${w}'`:String(w))})}break}}})}}for(let{selector:s,message:f,replace:R,replaceType:v="suggestion"}of u??[]){if(s==="CallExpression"){l.push($=>{c(R,$,f,v)});continue}n[s]=$=>{c(R,$,f,v)}}return l.length>0&&(n.CallExpression=s=>{if(s.type===te.AST_NODE_TYPES.CallExpression)for(let f of l)f(s)}),n["Program:exit"]=s=>{for(let f of r)e.report({node:s,messageId:"default",data:{message:`${f}`}})},n;function c(s,f,R,v){let $=E=>{if(!s)return null;if(typeof s=="string")return E.replaceText(f,s);{let C=new RegExp(s.regex),g=e.sourceCode.getText(f);return E.replaceText(f,g.replace(C,s.with))}};e.report({node:f,messageId:"default",data:{message:R},fix:s&&v==="autofix"?$:void 0,suggest:s&&v==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof s=="string"?s:s.with}"`},fix:$}]:void 0})}}});function nn(e,t){let n=[],i=t.exec(e);if(!i)return null;let[o,...u]=i;n.push({name:"$0_lowercase",value:o.toLowerCase()}),n.push({name:"$0_capitalize",value:Ze(o)}),n.push({name:"$0_uncapitalize",value:Qe(o)}),n.push({name:"$0",value:o});for(let m=0;m<u.length;m++){let l=`$${m+1}`,r=u[m];n.push({name:`${l}_lowercase`,value:r.toLowerCase()}),n.push({name:`${l}_capitalize`,value:Ze(r)}),n.push({name:`${l}_uncapitalize`,value:Qe(r)}),n.push({name:l,value:r})}return n}function Ze(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Qe(e){return e.charAt(0).toLowerCase()+e.slice(1)}var Ie={name:et,rule:tn};var V=require("@typescript-eslint/utils");var rn=V.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),tt="collapse-obj-with-single-
|
|
1
|
+
"use strict";var zt=Object.create;var ue=Object.defineProperty;var Bt=Object.getOwnPropertyDescriptor;var Xt=Object.getOwnPropertyNames;var Gt=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var qt=(e,t)=>{for(var n in t)ue(e,n,{get:t[n],enumerable:!0})},Je=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Xt(t))!Jt.call(e,o)&&o!==n&&ue(e,o,{get:()=>t[o],enumerable:!(i=Bt(t,o))||i.enumerable});return e};var Kt=(e,t,n)=>(n=e!=null?zt(Gt(e)):{},Je(t||!e||!e.__esModule?ue(n,"default",{value:e,enumerable:!0}):n,e)),Zt=e=>Je(ue({},"__esModule",{value:!0}),e);var tr={};qt(tr,{extendedLintPlugin:()=>er});module.exports=Zt(tr);var te=require("@typescript-eslint/utils");var be=Symbol.for("optional");function H(e){return{...e,[be]:!0}}function qe(e,t){return{enum:e,...t}}function pe(e){return{...e,type:"boolean"}}function F(e){return{...e,type:"string"}}function Z(e){return{...e,type:"number"}}function Ke(e){return{...e,type:"integer"}}function Y(e,t){return{...t,type:"array",items:e}}function M(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let i,o=[];for(i in e)e[i][be]?e[i][be]=void 0:o.push(i);o.length>0&&(n.required=o)}return n}function xe(...e){return{anyOf:e}}var Qt=te.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),en=M({disallow:H(Y(M({selector:F(),message:F(),replace:H(xe(F(),M({regex:F(),with:F()}))),replaceType:H(qe(["suggestion","autofix"]))}))),__dev_simulateFileName:H(F()),mustMatchSyntax:H(Y(M({includeRegex:F(),mustCallFn:Y(M({anyCall:Y(M({fn:F(),withArgs:Y(M({atIndex:Ke(),literal:xe(F(),Z(),pe())}))})),message:H(F())}))})))}),et="advanced-no-restricted-syntax",tn=Qt({name:et,meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[en],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:i,__dev_simulateFileName:o,disallow:u}=t,m=o??e.filename,l=[],r=new Set;for(let{includeRegex:s,mustCallFn:f}of i??[]){let R=nn(m,new RegExp(s));if(!R)continue;let v=$=>{let E=$;for(let{name:C,value:g}of R)E=E.replaceAll(C,g);return E};for(let{anyCall:$,message:E}of f){let C=`Expected file to call the function: ${$.map(({fn:g})=>g).join(" or ")}`;r.add(C),l.push(g=>{let{callee:O}=g;if(O.type===te.AST_NODE_TYPES.Identifier){for(let{fn:I,withArgs:d}of $)if(O.name===I){r.delete(C);for(let b of d){let x=g.arguments[b.atIndex],w=typeof b.literal=="string"?v(b.literal):b.literal;if(!x){e.report({node:g,messageId:"default",data:{message:`Missing argument with value "${w}" at index ${b.atIndex}${E?`: ${v(E)}`:""}`}});continue}if(x.type!==te.AST_NODE_TYPES.Literal){e.report({node:x,messageId:"default",data:{message:`Argument at position ${b.atIndex} should the literal "${w}"${E?`: ${v(E)}`:""}`}});continue}x.value!==w&&e.report({node:x,messageId:"default",data:{message:`Argument should have the value "${w}"${E?`: ${v(E)}`:""}`},fix:D=>D.replaceText(x,typeof w=="string"?`'${w}'`:String(w))})}break}}})}}for(let{selector:s,message:f,replace:R,replaceType:v="suggestion"}of u??[]){if(s==="CallExpression"){l.push($=>{c(R,$,f,v)});continue}n[s]=$=>{c(R,$,f,v)}}return l.length>0&&(n.CallExpression=s=>{if(s.type===te.AST_NODE_TYPES.CallExpression)for(let f of l)f(s)}),n["Program:exit"]=s=>{for(let f of r)e.report({node:s,messageId:"default",data:{message:`${f}`}})},n;function c(s,f,R,v){let $=E=>{if(!s)return null;if(typeof s=="string")return E.replaceText(f,s);{let C=new RegExp(s.regex),g=e.sourceCode.getText(f);return E.replaceText(f,g.replace(C,s.with))}};e.report({node:f,messageId:"default",data:{message:R},fix:s&&v==="autofix"?$:void 0,suggest:s&&v==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof s=="string"?s:s.with}"`},fix:$}]:void 0})}}});function nn(e,t){let n=[],i=t.exec(e);if(!i)return null;let[o,...u]=i;n.push({name:"$0_lowercase",value:o.toLowerCase()}),n.push({name:"$0_capitalize",value:Ze(o)}),n.push({name:"$0_uncapitalize",value:Qe(o)}),n.push({name:"$0",value:o});for(let m=0;m<u.length;m++){let l=`$${m+1}`,r=u[m];n.push({name:`${l}_lowercase`,value:r.toLowerCase()}),n.push({name:`${l}_capitalize`,value:Ze(r)}),n.push({name:`${l}_uncapitalize`,value:Qe(r)}),n.push({name:l,value:r})}return n}function Ze(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Qe(e){return e.charAt(0).toLowerCase()+e.slice(1)}var Ie={name:et,rule:tn};var V=require("@typescript-eslint/utils");var rn=V.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),tt="collapse-obj-with-single-prop",sn=M({maxLineLength:H(Z())}),on=rn({name:tt,meta:{type:"suggestion",fixable:"code",docs:{description:"Format single prop objects and types in one line"},messages:{singleLineProp:"Single prop object/type should be written in a single line"},schema:[sn]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode;function i(u){let m;if(u.type===V.AST_NODE_TYPES.ObjectExpression){if(u.properties.length!==1||(m=u.properties[0],m.type===V.AST_NODE_TYPES.Property&&m.value.type===V.AST_NODE_TYPES.ObjectExpression))return!1}else if(u.members.length!==1||(m=u.members[0],m.type===V.AST_NODE_TYPES.TSPropertySignature&&m.typeAnnotation?.typeAnnotation.type===V.AST_NODE_TYPES.TSTypeLiteral))return!1;return n.getText(m)}function o(u){if(u.loc.start.line===u.loc.end.line||n.getTokenAfter(u,{filter:s=>{let f=s.type===V.AST_TOKEN_TYPES.Punctuator&&s.value===",",R=s.type===V.AST_TOKEN_TYPES.Punctuator&&s.value===";";return!f&&!R}})?.loc.start.line===u.loc.end.line)return;let l=i(u);if(!l||l.includes(`
|
|
2
2
|
`)||n.getCommentsInside(u).length>0)return;l.endsWith(";")&&(l=l.slice(0,-1));let r=`{ ${l} }`,c=ln(n,u);t.maxLineLength&&r.length+c.length+(an(u,n)?1:0)>t.maxLineLength||e.report({node:u,messageId:"singleLineProp",fix:s=>s.replaceText(u,r)})}return{TSTypeLiteral:o,ObjectExpression:o}}});function an(e,t){let n=t.getTokenAfter(e);return n?.type===V.AST_TOKEN_TYPES.Punctuator&&(n.value===","||n.value===";")&&n.loc.start.line===e.loc.end.line}function ln(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var we={name:tt,rule:on};var cn=/eslint +react-compiler\/react-compiler: +\["error/,rt={meta:{type:"suggestion",docs:{description:"verifies the list of dependencies for Hooks like useEffect and similar",recommended:!0,url:"https://github.com/facebook/react/issues/14920"},fixable:"code",hasSuggestions:!0,schema:[{type:"object",additionalProperties:!1,ignoreIfReactCompilerIsEnabled:!1,enableDangerousAutofixThisMayCauseInfiniteLoops:!1,properties:{additionalHooks:{type:"string"},ignoreIfReactCompilerIsEnabled:{type:"boolean"},enableDangerousAutofixThisMayCauseInfiniteLoops:{type:"boolean"}}}]},create(e){let t=!1,n=typeof e.getSource=="function"?g=>n(g):g=>e.sourceCode.getText(g),i=typeof e.getScope=="function"?()=>i():g=>e.sourceCode.getScope(g),o=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,u=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,m={additionalHooks:o,enableDangerousAutofixThisMayCauseInfiniteLoops:u};function l(g){u&&Array.isArray(g.suggest)&&g.suggest.length>0&&(g.fix=g.suggest[0].fix),e.report(g)}let r=e.getSourceCode().scopeManager,c=new WeakMap,s=new WeakSet,f=new WeakMap,R=new WeakMap,v=new WeakSet;function $(g,O){return function(I){if(O.has(I))return O.get(I);let d=g(I);return O.set(I,d),d}}function E(g,O,I,d,b){b&&g.async&&l({node:g,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
|
|
3
3
|
|
|
4
4
|
useEffect(() => {
|
package/dist/extended-lint.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{AST_NODE_TYPES as ye,ESLintUtils as Ht}from"@typescript-eslint/utils";var me=Symbol.for("optional");function M(e){return{...e,[me]:!0}}function ze(e,t){return{enum:e,...t}}function oe(e){return{...e,type:"boolean"}}function F(e){return{...e,type:"string"}}function q(e){return{...e,type:"number"}}function Be(e){return{...e,type:"integer"}}function Y(e,t){return{...t,type:"array",items:e}}function j(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let s,o=[];for(s in e)e[s][me]?e[s][me]=void 0:o.push(s);o.length>0&&(n.required=o)}return n}function de(...e){return{anyOf:e}}var Wt=Ht.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ut=j({disallow:M(Y(j({selector:F(),message:F(),replace:M(de(F(),j({regex:F(),with:F()}))),replaceType:M(ze(["suggestion","autofix"]))}))),__dev_simulateFileName:M(F()),mustMatchSyntax:M(Y(j({includeRegex:F(),mustCallFn:Y(j({anyCall:Y(j({fn:F(),withArgs:Y(j({atIndex:Be(),literal:de(F(),q(),oe())}))})),message:M(F())}))})))}),Je="advanced-no-restricted-syntax",Yt=Wt({name:Je,meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[Ut],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:s,__dev_simulateFileName:o,disallow:u}=t,m=o??e.filename,l=[],r=new Set;for(let{includeRegex:i,mustCallFn:f}of s??[]){let R=Vt(m,new RegExp(i));if(!R)continue;let v=_=>{let E=_;for(let{name:C,value:g}of R)E=E.replaceAll(C,g);return E};for(let{anyCall:_,message:E}of f){let C=`Expected file to call the function: ${_.map(({fn:g})=>g).join(" or ")}`;r.add(C),l.push(g=>{let{callee:O}=g;if(O.type===ye.Identifier){for(let{fn:I,withArgs:d}of _)if(O.name===I){r.delete(C);for(let b of d){let x=g.arguments[b.atIndex],w=typeof b.literal=="string"?v(b.literal):b.literal;if(!x){e.report({node:g,messageId:"default",data:{message:`Missing argument with value "${w}" at index ${b.atIndex}${E?`: ${v(E)}`:""}`}});continue}if(x.type!==ye.Literal){e.report({node:x,messageId:"default",data:{message:`Argument at position ${b.atIndex} should the literal "${w}"${E?`: ${v(E)}`:""}`}});continue}x.value!==w&&e.report({node:x,messageId:"default",data:{message:`Argument should have the value "${w}"${E?`: ${v(E)}`:""}`},fix:D=>D.replaceText(x,typeof w=="string"?`'${w}'`:String(w))})}break}}})}}for(let{selector:i,message:f,replace:R,replaceType:v="suggestion"}of u??[]){if(i==="CallExpression"){l.push(_=>{c(R,_,f,v)});continue}n[i]=_=>{c(R,_,f,v)}}return l.length>0&&(n.CallExpression=i=>{if(i.type===ye.CallExpression)for(let f of l)f(i)}),n["Program:exit"]=i=>{for(let f of r)e.report({node:i,messageId:"default",data:{message:`${f}`}})},n;function c(i,f,R,v){let _=E=>{if(!i)return null;if(typeof i=="string")return E.replaceText(f,i);{let C=new RegExp(i.regex),g=e.sourceCode.getText(f);return E.replaceText(f,g.replace(C,i.with))}};e.report({node:f,messageId:"default",data:{message:R},fix:i&&v==="autofix"?_:void 0,suggest:i&&v==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof i=="string"?i:i.with}"`},fix:_}]:void 0})}}});function Vt(e,t){let n=[],s=t.exec(e);if(!s)return null;let[o,...u]=s;n.push({name:"$0_lowercase",value:o.toLowerCase()}),n.push({name:"$0_capitalize",value:Xe(o)}),n.push({name:"$0_uncapitalize",value:Ge(o)}),n.push({name:"$0",value:o});for(let m=0;m<u.length;m++){let l=`$${m+1}`,r=u[m];n.push({name:`${l}_lowercase`,value:r.toLowerCase()}),n.push({name:`${l}_capitalize`,value:Xe(r)}),n.push({name:`${l}_uncapitalize`,value:Ge(r)}),n.push({name:l,value:r})}return n}function Xe(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ge(e){return e.charAt(0).toLowerCase()+e.slice(1)}var ge={name:Je,rule:Yt};import{AST_NODE_TYPES as ne,AST_TOKEN_TYPES as he,ESLintUtils as zt}from"@typescript-eslint/utils";var Bt=zt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),qe="collapse-obj-with-single-
|
|
1
|
+
import{AST_NODE_TYPES as ye,ESLintUtils as Ht}from"@typescript-eslint/utils";var me=Symbol.for("optional");function M(e){return{...e,[me]:!0}}function ze(e,t){return{enum:e,...t}}function oe(e){return{...e,type:"boolean"}}function F(e){return{...e,type:"string"}}function q(e){return{...e,type:"number"}}function Be(e){return{...e,type:"integer"}}function Y(e,t){return{...t,type:"array",items:e}}function j(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let s,o=[];for(s in e)e[s][me]?e[s][me]=void 0:o.push(s);o.length>0&&(n.required=o)}return n}function de(...e){return{anyOf:e}}var Wt=Ht.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Ut=j({disallow:M(Y(j({selector:F(),message:F(),replace:M(de(F(),j({regex:F(),with:F()}))),replaceType:M(ze(["suggestion","autofix"]))}))),__dev_simulateFileName:M(F()),mustMatchSyntax:M(Y(j({includeRegex:F(),mustCallFn:Y(j({anyCall:Y(j({fn:F(),withArgs:Y(j({atIndex:Be(),literal:de(F(),q(),oe())}))})),message:M(F())}))})))}),Je="advanced-no-restricted-syntax",Yt=Wt({name:Je,meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[Ut],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:s,__dev_simulateFileName:o,disallow:u}=t,m=o??e.filename,l=[],r=new Set;for(let{includeRegex:i,mustCallFn:f}of s??[]){let R=Vt(m,new RegExp(i));if(!R)continue;let v=_=>{let E=_;for(let{name:C,value:g}of R)E=E.replaceAll(C,g);return E};for(let{anyCall:_,message:E}of f){let C=`Expected file to call the function: ${_.map(({fn:g})=>g).join(" or ")}`;r.add(C),l.push(g=>{let{callee:O}=g;if(O.type===ye.Identifier){for(let{fn:I,withArgs:d}of _)if(O.name===I){r.delete(C);for(let b of d){let x=g.arguments[b.atIndex],w=typeof b.literal=="string"?v(b.literal):b.literal;if(!x){e.report({node:g,messageId:"default",data:{message:`Missing argument with value "${w}" at index ${b.atIndex}${E?`: ${v(E)}`:""}`}});continue}if(x.type!==ye.Literal){e.report({node:x,messageId:"default",data:{message:`Argument at position ${b.atIndex} should the literal "${w}"${E?`: ${v(E)}`:""}`}});continue}x.value!==w&&e.report({node:x,messageId:"default",data:{message:`Argument should have the value "${w}"${E?`: ${v(E)}`:""}`},fix:D=>D.replaceText(x,typeof w=="string"?`'${w}'`:String(w))})}break}}})}}for(let{selector:i,message:f,replace:R,replaceType:v="suggestion"}of u??[]){if(i==="CallExpression"){l.push(_=>{c(R,_,f,v)});continue}n[i]=_=>{c(R,_,f,v)}}return l.length>0&&(n.CallExpression=i=>{if(i.type===ye.CallExpression)for(let f of l)f(i)}),n["Program:exit"]=i=>{for(let f of r)e.report({node:i,messageId:"default",data:{message:`${f}`}})},n;function c(i,f,R,v){let _=E=>{if(!i)return null;if(typeof i=="string")return E.replaceText(f,i);{let C=new RegExp(i.regex),g=e.sourceCode.getText(f);return E.replaceText(f,g.replace(C,i.with))}};e.report({node:f,messageId:"default",data:{message:R},fix:i&&v==="autofix"?_:void 0,suggest:i&&v==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof i=="string"?i:i.with}"`},fix:_}]:void 0})}}});function Vt(e,t){let n=[],s=t.exec(e);if(!s)return null;let[o,...u]=s;n.push({name:"$0_lowercase",value:o.toLowerCase()}),n.push({name:"$0_capitalize",value:Xe(o)}),n.push({name:"$0_uncapitalize",value:Ge(o)}),n.push({name:"$0",value:o});for(let m=0;m<u.length;m++){let l=`$${m+1}`,r=u[m];n.push({name:`${l}_lowercase`,value:r.toLowerCase()}),n.push({name:`${l}_capitalize`,value:Xe(r)}),n.push({name:`${l}_uncapitalize`,value:Ge(r)}),n.push({name:l,value:r})}return n}function Xe(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ge(e){return e.charAt(0).toLowerCase()+e.slice(1)}var ge={name:Je,rule:Yt};import{AST_NODE_TYPES as ne,AST_TOKEN_TYPES as he,ESLintUtils as zt}from"@typescript-eslint/utils";var Bt=zt.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),qe="collapse-obj-with-single-prop",Xt=j({maxLineLength:M(q())}),Gt=Bt({name:qe,meta:{type:"suggestion",fixable:"code",docs:{description:"Format single prop objects and types in one line"},messages:{singleLineProp:"Single prop object/type should be written in a single line"},schema:[Xt]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode;function s(u){let m;if(u.type===ne.ObjectExpression){if(u.properties.length!==1||(m=u.properties[0],m.type===ne.Property&&m.value.type===ne.ObjectExpression))return!1}else if(u.members.length!==1||(m=u.members[0],m.type===ne.TSPropertySignature&&m.typeAnnotation?.typeAnnotation.type===ne.TSTypeLiteral))return!1;return n.getText(m)}function o(u){if(u.loc.start.line===u.loc.end.line||n.getTokenAfter(u,{filter:i=>{let f=i.type===he.Punctuator&&i.value===",",R=i.type===he.Punctuator&&i.value===";";return!f&&!R}})?.loc.start.line===u.loc.end.line)return;let l=s(u);if(!l||l.includes(`
|
|
2
2
|
`)||n.getCommentsInside(u).length>0)return;l.endsWith(";")&&(l=l.slice(0,-1));let r=`{ ${l} }`,c=qt(n,u);t.maxLineLength&&r.length+c.length+(Jt(u,n)?1:0)>t.maxLineLength||e.report({node:u,messageId:"singleLineProp",fix:i=>i.replaceText(u,r)})}return{TSTypeLiteral:o,ObjectExpression:o}}});function Jt(e,t){let n=t.getTokenAfter(e);return n?.type===he.Punctuator&&(n.value===","||n.value===";")&&n.loc.start.line===e.loc.end.line}function qt(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var Se={name:qe,rule:Gt};var Kt=/eslint +react-compiler\/react-compiler: +\["error/,Ze={meta:{type:"suggestion",docs:{description:"verifies the list of dependencies for Hooks like useEffect and similar",recommended:!0,url:"https://github.com/facebook/react/issues/14920"},fixable:"code",hasSuggestions:!0,schema:[{type:"object",additionalProperties:!1,ignoreIfReactCompilerIsEnabled:!1,enableDangerousAutofixThisMayCauseInfiniteLoops:!1,properties:{additionalHooks:{type:"string"},ignoreIfReactCompilerIsEnabled:{type:"boolean"},enableDangerousAutofixThisMayCauseInfiniteLoops:{type:"boolean"}}}]},create(e){let t=!1,n=typeof e.getSource=="function"?g=>n(g):g=>e.sourceCode.getText(g),s=typeof e.getScope=="function"?()=>s():g=>e.sourceCode.getScope(g),o=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,u=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,m={additionalHooks:o,enableDangerousAutofixThisMayCauseInfiniteLoops:u};function l(g){u&&Array.isArray(g.suggest)&&g.suggest.length>0&&(g.fix=g.suggest[0].fix),e.report(g)}let r=e.getSourceCode().scopeManager,c=new WeakMap,i=new WeakSet,f=new WeakMap,R=new WeakMap,v=new WeakSet;function _(g,O){return function(I){if(O.has(I))return O.get(I);let d=g(I);return O.set(I,d),d}}function E(g,O,I,d,b){b&&g.async&&l({node:g,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
|
|
3
3
|
|
|
4
4
|
useEffect(() => {
|