@ls-stack/extended-lint 0.37.0 → 0.38.0
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 yn=Object.create;var he=Object.defineProperty;var gn=Object.getOwnPropertyDescriptor;var hn=Object.getOwnPropertyNames;var Tn=Object.getPrototypeOf,Sn=Object.prototype.hasOwnProperty;var En=(e,t)=>{for(var n in t)he(e,n,{get:t[n],enumerable:!0})},ft=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of hn(t))!Sn.call(e,l)&&l!==n&&he(e,l,{get:()=>t[l],enumerable:!(r=gn(t,l))||r.enumerable});return e};var Pe=(e,t,n)=>(n=e!=null?yn(Tn(e)):{},ft(t||!e||!e.__esModule?he(n,"default",{value:e,enumerable:!0}):n,e)),bn=e=>ft(he({},"__esModule",{value:!0}),e);var Vr={};En(Vr,{extendedLintPlugin:()=>Wr});module.exports=bn(Vr);var V=require("@typescript-eslint/utils");var Ne=Symbol.for("optional");function $(e){return{...e,[Ne]:!0}}function Te(e,t){return{enum:e,...t}}function oe(e){return{...e,type:"boolean"}}function F(e){return{...e,type:"string"}}function J(e){return{...e,type:"number"}}function mt(e){return{...e,type:"integer"}}function H(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 r,l=[];for(r in e)e[r][Ne]?e[r][Ne]=void 0:l.push(r);l.length>0&&(n.required=l)}return n}function _e(...e){return{anyOf:e}}var xn=V.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),yt="react-compiler-extra",Cn=j({runOnlyWithEnableCompilerDirective:$(oe())}),In=/eslint +react-compiler\/react-compiler: +\["error/;function wn(e){return e.type===V.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===V.AST_NODE_TYPES.MemberExpression&&e.property.type===V.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var Rn=/\bthis[.[]/;function dt(e){return Rn.test(e)}var vn=xn({name:yt,meta:{type:"suggestion",fixable:"code",docs:{description:"Extra rules to enforce best practices when using the React compiler"},messages:{objectMethodIsNotSupported:"Object methods such as `{ method() {} }` have limited support to optimizations in the React compiler, use a function expression `{ method: () => {} }` instead.",replaceWithFunctionExpression:"Replace with function expression",thisKeywordInMethod:"Object method uses `this` keyword which would have different behavior if converted to an arrow function. Fix this manually."},hasSuggestions:!0,schema:[Cn]},defaultOptions:[{}],create(e,[t]){let n=!1;if(t.runOnlyWithEnableCompilerDirective){for(let f of e.sourceCode.getAllComments())if(In.test(f.value)){n=!0;break}if(!n)return{}}function r(f){for(let p of f.properties)if(p.type===V.AST_NODE_TYPES.Property&&p.method&&p.value.type===V.AST_NODE_TYPES.FunctionExpression){let i=e.sourceCode,o=i.getText(p.key),a=p.value,s=i.getText(a.body);if(dt(s))e.report({node:p,messageId:"thisKeywordInMethod"});else{let c=a.params.map(T=>i.getText(T)).join(", "),g="";a.generator?g=`${o}: function* (${c}) ${s}`:g=`${o}: (${c}) => ${s}`,e.report({node:p,messageId:"objectMethodIsNotSupported",fix:T=>T.replaceText(p,g)})}}}function l(f){for(let p of f.properties)if(p.type===V.AST_NODE_TYPES.Property&&p.value.type===V.AST_NODE_TYPES.ObjectExpression){for(let i of p.value.properties)if(i.type===V.AST_NODE_TYPES.Property&&i.method&&i.value.type===V.AST_NODE_TYPES.FunctionExpression){let a=e.sourceCode.getText(i.value.body);dt(a)&&e.report({node:i,messageId:"thisKeywordInMethod"})}}}return{CallExpression(f){if(wn(f.callee))for(let p of f.arguments){if(p.type===V.AST_NODE_TYPES.ObjectExpression&&(r(p),l(p)),p.type===V.AST_NODE_TYPES.ArrowFunctionExpression&&(p.body.type===V.AST_NODE_TYPES.ObjectExpression&&(r(p.body),l(p.body)),p.body.type===V.AST_NODE_TYPES.BlockStatement))for(let i of p.body.body)i.type===V.AST_NODE_TYPES.ReturnStatement&&i.argument?.type===V.AST_NODE_TYPES.ObjectExpression&&(r(i.argument),l(i.argument));if(p.type===V.AST_NODE_TYPES.FunctionExpression)for(let i of p.body.body)i.type===V.AST_NODE_TYPES.ReturnStatement&&i.argument?.type===V.AST_NODE_TYPES.ObjectExpression&&(r(i.argument),l(i.argument))}}}}}),De={name:yt,rule:vn};var ae=require("@typescript-eslint/utils");var kn=ae.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),An=j({disallow:$(H(j({selector:F(),message:F(),replace:$(_e(F(),j({regex:F(),with:F()}))),replaceType:$(Te(["suggestion","autofix"]))}))),__dev_simulateFileName:$(F()),mustMatchSyntax:$(H(j({includeRegex:F(),mustCallFn:H(j({anyCall:H(j({fn:F(),withArgs:H(j({atIndex:mt(),literal:_e(F(),J(),oe())}))})),message:$(F())}))})))}),Tt="advanced-no-restricted-syntax",On=kn({name:Tt,meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[An],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:r,__dev_simulateFileName:l,disallow:f}=t,p=l??e.filename,i=[],o=new Set;for(let{includeRegex:s,mustCallFn:c}of r??[]){let g=Pn(p,new RegExp(s));if(!g)continue;let T=S=>{let d=S;for(let{name:b,value:y}of g)d=d.replaceAll(b,y);return d};for(let{anyCall:S,message:d}of c){let b=`Expected file to call the function: ${S.map(({fn:y})=>y).join(" or ")}`;o.add(b),i.push(y=>{let{callee:N}=y;if(N.type===ae.AST_NODE_TYPES.Identifier){for(let{fn:v,withArgs:h}of S)if(N.name===v){o.delete(b);for(let w of h){let R=y.arguments[w.atIndex],k=typeof w.literal=="string"?T(w.literal):w.literal;if(!R){e.report({node:y,messageId:"default",data:{message:`Missing argument with value "${k}" at index ${w.atIndex}${d?`: ${T(d)}`:""}`}});continue}if(R.type!==ae.AST_NODE_TYPES.Literal){e.report({node:R,messageId:"default",data:{message:`Argument at position ${w.atIndex} should the literal "${k}"${d?`: ${T(d)}`:""}`}});continue}R.value!==k&&e.report({node:R,messageId:"default",data:{message:`Argument should have the value "${k}"${d?`: ${T(d)}`:""}`},fix:D=>D.replaceText(R,typeof k=="string"?`'${k}'`:String(k))})}break}}})}}for(let{selector:s,message:c,replace:g,replaceType:T="suggestion"}of f??[]){if(s==="CallExpression"){i.push(S=>{a(g,S,c,T)});continue}n[s]=S=>{a(g,S,c,T)}}return i.length>0&&(n.CallExpression=s=>{if(s.type===ae.AST_NODE_TYPES.CallExpression)for(let c of i)c(s)}),n["Program:exit"]=s=>{for(let c of o)e.report({node:s,messageId:"default",data:{message:`${c}`}})},n;function a(s,c,g,T){let S=d=>{if(!s)return null;if(typeof s=="string")return d.replaceText(c,s);{let b=new RegExp(s.regex),y=e.sourceCode.getText(c);return d.replaceText(c,y.replace(b,s.with))}};e.report({node:c,messageId:"default",data:{message:g},fix:s&&T==="autofix"?S:void 0,suggest:s&&T==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof s=="string"?s:s.with}"`},fix:S}]:void 0})}}});function Pn(e,t){let n=[],r=t.exec(e);if(!r)return null;let[l,...f]=r;n.push({name:"$0_lowercase",value:l.toLowerCase()}),n.push({name:"$0_capitalize",value:gt(l)}),n.push({name:"$0_uncapitalize",value:ht(l)}),n.push({name:"$0",value:l});for(let p=0;p<f.length;p++){let i=`$${p+1}`,o=f[p];n.push({name:`${i}_lowercase`,value:o.toLowerCase()}),n.push({name:`${i}_capitalize`,value:gt(o)}),n.push({name:`${i}_uncapitalize`,value:ht(o)}),n.push({name:i,value:o})}return n}function gt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ht(e){return e.charAt(0).toLowerCase()+e.slice(1)}var Le={name:Tt,rule:On};var _=require("@typescript-eslint/utils");var Nn=_.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Et="collapse-simple-objs-in-one-line",_n=j({maxLineLength:$(J()),maxProperties:$(J()),nestedObjMaxLineLength:$(J()),nestedObjMaxProperties:$(J()),ignoreTypesWithSuffix:$(H(F()))}),Dn=Nn({name:Et,meta:{type:"suggestion",fixable:"code",docs:{description:"Format simple objects and types in one line"},messages:{singleLineProp:"Object/type should be written in a single line"},schema:[_n]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode,r=t.ignoreTypesWithSuffix??[],l=t.maxProperties??2,f=t.nestedObjMaxLineLength??t.maxLineLength,p=t.nestedObjMaxProperties??3;function i(a){if(a.type===_.AST_NODE_TYPES.ObjectExpression){let s=a.parent.type===_.AST_NODE_TYPES.Property,c=s?p:l,g=a.properties.length;if(g>c)return!1;if(g===1){let S=a.properties[0];return S.type===_.AST_NODE_TYPES.Property&&S.value.type===_.AST_NODE_TYPES.ObjectExpression||S.type===_.AST_NODE_TYPES.Property&&S.value.type===_.AST_NODE_TYPES.ArrayExpression&&!S.value.elements.every(b=>b&&$e(b))?!1:{text:n.getText(S),isNested:s,propsSize:g}}let T=[];for(let S of a.properties){if(S.type===_.AST_NODE_TYPES.Property&&!$e(S.value))return!1;T.push(n.getText(S))}return{text:T.join(", "),isNested:s,propsSize:g}}else{let s=a.parent.parent?.type===_.AST_NODE_TYPES.TSPropertySignature,c=s?p:l,g=a.members.length;if(g>c)return!1;if(r.length>0&&a.parent.type===_.AST_NODE_TYPES.TSTypeAliasDeclaration){let S=a.parent.id.name;if(r.some(d=>S.endsWith(d)))return!1}if(g===1){let S=a.members[0];return S.type===_.AST_NODE_TYPES.TSPropertySignature&&S.typeAnnotation?.typeAnnotation.type===_.AST_NODE_TYPES.TSTypeLiteral?!1:{text:n.getText(S),isNested:s,propsSize:1}}if(a.parent.type===_.AST_NODE_TYPES.TSIntersectionType||a.parent.type===_.AST_NODE_TYPES.TSUnionType)return!1;let T=[];for(let S of a.members){if(S.type!==_.AST_NODE_TYPES.TSPropertySignature)return!1;let d=S.typeAnnotation?.typeAnnotation;if(!d||d.type===_.AST_NODE_TYPES.TSTypeLiteral||!St(d))return!1;if(d.type===_.AST_NODE_TYPES.TSTypeReference&&d.typeArguments){if(d.typeArguments.params.length>1)return!1;let y=d.typeArguments.params[0];if(!St(y))return!1}let b=n.getText(S).trim();(b.endsWith(";")||b.endsWith(","))&&(b=b.slice(0,-1)),T.push(b)}return{text:T.join("; "),isNested:s,propsSize:g}}}function o(a){if(a.loc.start.line===a.loc.end.line)return;if(a.parent.type!==_.AST_NODE_TYPES.JSXExpressionContainer){let d=0,b=n.getTokenAfter(a,{filter:y=>y.type!==_.AST_TOKEN_TYPES.Punctuator?!0:y.value===","||y.value===";"||y.value===")"||y.value==="}"?(d++,!1):!0});if(d>
|
|
1
|
+
"use strict";var yn=Object.create;var he=Object.defineProperty;var gn=Object.getOwnPropertyDescriptor;var hn=Object.getOwnPropertyNames;var Tn=Object.getPrototypeOf,Sn=Object.prototype.hasOwnProperty;var En=(e,t)=>{for(var n in t)he(e,n,{get:t[n],enumerable:!0})},ft=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of hn(t))!Sn.call(e,l)&&l!==n&&he(e,l,{get:()=>t[l],enumerable:!(r=gn(t,l))||r.enumerable});return e};var Pe=(e,t,n)=>(n=e!=null?yn(Tn(e)):{},ft(t||!e||!e.__esModule?he(n,"default",{value:e,enumerable:!0}):n,e)),bn=e=>ft(he({},"__esModule",{value:!0}),e);var Vr={};En(Vr,{extendedLintPlugin:()=>Wr});module.exports=bn(Vr);var V=require("@typescript-eslint/utils");var Ne=Symbol.for("optional");function $(e){return{...e,[Ne]:!0}}function Te(e,t){return{enum:e,...t}}function oe(e){return{...e,type:"boolean"}}function F(e){return{...e,type:"string"}}function J(e){return{...e,type:"number"}}function mt(e){return{...e,type:"integer"}}function H(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 r,l=[];for(r in e)e[r][Ne]?e[r][Ne]=void 0:l.push(r);l.length>0&&(n.required=l)}return n}function _e(...e){return{anyOf:e}}var xn=V.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),yt="react-compiler-extra",Cn=j({runOnlyWithEnableCompilerDirective:$(oe())}),In=/eslint +react-compiler\/react-compiler: +\["error/;function wn(e){return e.type===V.AST_NODE_TYPES.Identifier?e.name.startsWith("use"):e.type===V.AST_NODE_TYPES.MemberExpression&&e.property.type===V.AST_NODE_TYPES.Identifier?e.property.name.startsWith("use"):!1}var Rn=/\bthis[.[]/;function dt(e){return Rn.test(e)}var vn=xn({name:yt,meta:{type:"suggestion",fixable:"code",docs:{description:"Extra rules to enforce best practices when using the React compiler"},messages:{objectMethodIsNotSupported:"Object methods such as `{ method() {} }` have limited support to optimizations in the React compiler, use a function expression `{ method: () => {} }` instead.",replaceWithFunctionExpression:"Replace with function expression",thisKeywordInMethod:"Object method uses `this` keyword which would have different behavior if converted to an arrow function. Fix this manually."},hasSuggestions:!0,schema:[Cn]},defaultOptions:[{}],create(e,[t]){let n=!1;if(t.runOnlyWithEnableCompilerDirective){for(let f of e.sourceCode.getAllComments())if(In.test(f.value)){n=!0;break}if(!n)return{}}function r(f){for(let p of f.properties)if(p.type===V.AST_NODE_TYPES.Property&&p.method&&p.value.type===V.AST_NODE_TYPES.FunctionExpression){let i=e.sourceCode,o=i.getText(p.key),a=p.value,s=i.getText(a.body);if(dt(s))e.report({node:p,messageId:"thisKeywordInMethod"});else{let c=a.params.map(T=>i.getText(T)).join(", "),g="";a.generator?g=`${o}: function* (${c}) ${s}`:g=`${o}: (${c}) => ${s}`,e.report({node:p,messageId:"objectMethodIsNotSupported",fix:T=>T.replaceText(p,g)})}}}function l(f){for(let p of f.properties)if(p.type===V.AST_NODE_TYPES.Property&&p.value.type===V.AST_NODE_TYPES.ObjectExpression){for(let i of p.value.properties)if(i.type===V.AST_NODE_TYPES.Property&&i.method&&i.value.type===V.AST_NODE_TYPES.FunctionExpression){let a=e.sourceCode.getText(i.value.body);dt(a)&&e.report({node:i,messageId:"thisKeywordInMethod"})}}}return{CallExpression(f){if(wn(f.callee))for(let p of f.arguments){if(p.type===V.AST_NODE_TYPES.ObjectExpression&&(r(p),l(p)),p.type===V.AST_NODE_TYPES.ArrowFunctionExpression&&(p.body.type===V.AST_NODE_TYPES.ObjectExpression&&(r(p.body),l(p.body)),p.body.type===V.AST_NODE_TYPES.BlockStatement))for(let i of p.body.body)i.type===V.AST_NODE_TYPES.ReturnStatement&&i.argument?.type===V.AST_NODE_TYPES.ObjectExpression&&(r(i.argument),l(i.argument));if(p.type===V.AST_NODE_TYPES.FunctionExpression)for(let i of p.body.body)i.type===V.AST_NODE_TYPES.ReturnStatement&&i.argument?.type===V.AST_NODE_TYPES.ObjectExpression&&(r(i.argument),l(i.argument))}}}}}),De={name:yt,rule:vn};var ae=require("@typescript-eslint/utils");var kn=ae.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),An=j({disallow:$(H(j({selector:F(),message:F(),replace:$(_e(F(),j({regex:F(),with:F()}))),replaceType:$(Te(["suggestion","autofix"]))}))),__dev_simulateFileName:$(F()),mustMatchSyntax:$(H(j({includeRegex:F(),mustCallFn:H(j({anyCall:H(j({fn:F(),withArgs:H(j({atIndex:mt(),literal:_e(F(),J(),oe())}))})),message:$(F())}))})))}),Tt="advanced-no-restricted-syntax",On=kn({name:Tt,meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[An],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:r,__dev_simulateFileName:l,disallow:f}=t,p=l??e.filename,i=[],o=new Set;for(let{includeRegex:s,mustCallFn:c}of r??[]){let g=Pn(p,new RegExp(s));if(!g)continue;let T=S=>{let d=S;for(let{name:b,value:y}of g)d=d.replaceAll(b,y);return d};for(let{anyCall:S,message:d}of c){let b=`Expected file to call the function: ${S.map(({fn:y})=>y).join(" or ")}`;o.add(b),i.push(y=>{let{callee:N}=y;if(N.type===ae.AST_NODE_TYPES.Identifier){for(let{fn:v,withArgs:h}of S)if(N.name===v){o.delete(b);for(let w of h){let R=y.arguments[w.atIndex],k=typeof w.literal=="string"?T(w.literal):w.literal;if(!R){e.report({node:y,messageId:"default",data:{message:`Missing argument with value "${k}" at index ${w.atIndex}${d?`: ${T(d)}`:""}`}});continue}if(R.type!==ae.AST_NODE_TYPES.Literal){e.report({node:R,messageId:"default",data:{message:`Argument at position ${w.atIndex} should the literal "${k}"${d?`: ${T(d)}`:""}`}});continue}R.value!==k&&e.report({node:R,messageId:"default",data:{message:`Argument should have the value "${k}"${d?`: ${T(d)}`:""}`},fix:D=>D.replaceText(R,typeof k=="string"?`'${k}'`:String(k))})}break}}})}}for(let{selector:s,message:c,replace:g,replaceType:T="suggestion"}of f??[]){if(s==="CallExpression"){i.push(S=>{a(g,S,c,T)});continue}n[s]=S=>{a(g,S,c,T)}}return i.length>0&&(n.CallExpression=s=>{if(s.type===ae.AST_NODE_TYPES.CallExpression)for(let c of i)c(s)}),n["Program:exit"]=s=>{for(let c of o)e.report({node:s,messageId:"default",data:{message:`${c}`}})},n;function a(s,c,g,T){let S=d=>{if(!s)return null;if(typeof s=="string")return d.replaceText(c,s);{let b=new RegExp(s.regex),y=e.sourceCode.getText(c);return d.replaceText(c,y.replace(b,s.with))}};e.report({node:c,messageId:"default",data:{message:g},fix:s&&T==="autofix"?S:void 0,suggest:s&&T==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof s=="string"?s:s.with}"`},fix:S}]:void 0})}}});function Pn(e,t){let n=[],r=t.exec(e);if(!r)return null;let[l,...f]=r;n.push({name:"$0_lowercase",value:l.toLowerCase()}),n.push({name:"$0_capitalize",value:gt(l)}),n.push({name:"$0_uncapitalize",value:ht(l)}),n.push({name:"$0",value:l});for(let p=0;p<f.length;p++){let i=`$${p+1}`,o=f[p];n.push({name:`${i}_lowercase`,value:o.toLowerCase()}),n.push({name:`${i}_capitalize`,value:gt(o)}),n.push({name:`${i}_uncapitalize`,value:ht(o)}),n.push({name:i,value:o})}return n}function gt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ht(e){return e.charAt(0).toLowerCase()+e.slice(1)}var Le={name:Tt,rule:On};var _=require("@typescript-eslint/utils");var Nn=_.ESLintUtils.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Et="collapse-simple-objs-in-one-line",_n=j({maxLineLength:$(J()),maxProperties:$(J()),nestedObjMaxLineLength:$(J()),nestedObjMaxProperties:$(J()),ignoreTypesWithSuffix:$(H(F()))}),Dn=Nn({name:Et,meta:{type:"suggestion",fixable:"code",docs:{description:"Format simple objects and types in one line"},messages:{singleLineProp:"Object/type should be written in a single line"},schema:[_n]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode,r=t.ignoreTypesWithSuffix??[],l=t.maxProperties??2,f=t.nestedObjMaxLineLength??t.maxLineLength,p=t.nestedObjMaxProperties??3;function i(a){if(a.type===_.AST_NODE_TYPES.ObjectExpression){let s=a.parent.type===_.AST_NODE_TYPES.Property,c=s?p:l,g=a.properties.length;if(g>c)return!1;if(g===1){let S=a.properties[0];return S.type===_.AST_NODE_TYPES.Property&&S.value.type===_.AST_NODE_TYPES.ObjectExpression||S.type===_.AST_NODE_TYPES.Property&&S.value.type===_.AST_NODE_TYPES.ArrayExpression&&!S.value.elements.every(b=>b&&$e(b))?!1:{text:n.getText(S),isNested:s,propsSize:g}}let T=[];for(let S of a.properties){if(S.type===_.AST_NODE_TYPES.Property&&!$e(S.value))return!1;T.push(n.getText(S))}return{text:T.join(", "),isNested:s,propsSize:g}}else{let s=a.parent.parent?.type===_.AST_NODE_TYPES.TSPropertySignature,c=s?p:l,g=a.members.length;if(g>c)return!1;if(r.length>0&&a.parent.type===_.AST_NODE_TYPES.TSTypeAliasDeclaration){let S=a.parent.id.name;if(r.some(d=>S.endsWith(d)))return!1}if(g===1){let S=a.members[0];return S.type===_.AST_NODE_TYPES.TSPropertySignature&&S.typeAnnotation?.typeAnnotation.type===_.AST_NODE_TYPES.TSTypeLiteral?!1:{text:n.getText(S),isNested:s,propsSize:1}}if(a.parent.type===_.AST_NODE_TYPES.TSIntersectionType||a.parent.type===_.AST_NODE_TYPES.TSUnionType)return!1;let T=[];for(let S of a.members){if(S.type!==_.AST_NODE_TYPES.TSPropertySignature)return!1;let d=S.typeAnnotation?.typeAnnotation;if(!d||d.type===_.AST_NODE_TYPES.TSTypeLiteral||!St(d))return!1;if(d.type===_.AST_NODE_TYPES.TSTypeReference&&d.typeArguments){if(d.typeArguments.params.length>1)return!1;let y=d.typeArguments.params[0];if(!St(y))return!1}let b=n.getText(S).trim();(b.endsWith(";")||b.endsWith(","))&&(b=b.slice(0,-1)),T.push(b)}return{text:T.join("; "),isNested:s,propsSize:g}}}function o(a){if(a.loc.start.line===a.loc.end.line)return;if(a.parent.type!==_.AST_NODE_TYPES.JSXExpressionContainer){let d=0,b=n.getTokenAfter(a,{filter:y=>y.type!==_.AST_TOKEN_TYPES.Punctuator?!0:y.value===","||y.value===";"||y.value===")"||y.value==="}"?(d++,!1):!0});if(d>4||b?.loc.start.line===a.loc.end.line)return}let s=i(a);if(!s)return;let c=s.text;if(c.includes(`
|
|
2
2
|
`)||n.getCommentsInside(a).length>0)return;c.endsWith(";")&&(c=c.slice(0,-1));let g=`{ ${c} }`,T=$n(n,a),S=s.isNested&&s.propsSize>2?f:t.maxLineLength;S&&g.length+T.length+Ln(a,n)>S||e.report({node:a,messageId:"singleLineProp",fix:d=>d.replaceText(a,g)})}return{TSTypeLiteral:o,ObjectExpression:o}}});function St(e){return e.type===_.AST_NODE_TYPES.TSLiteralType||e.type===_.AST_NODE_TYPES.TSTypeReference||e.type===_.AST_NODE_TYPES.TSNumberKeyword||e.type===_.AST_NODE_TYPES.TSStringKeyword||e.type===_.AST_NODE_TYPES.TSBooleanKeyword||e.type===_.AST_NODE_TYPES.TSNullKeyword||e.type===_.AST_NODE_TYPES.TSUndefinedKeyword}function $e(e,t){return!!(e.type===_.AST_NODE_TYPES.Literal||e.type===_.AST_NODE_TYPES.Identifier||e.type===_.AST_NODE_TYPES.TemplateLiteral||e.type===_.AST_NODE_TYPES.TaggedTemplateExpression||!t&&e.type===_.AST_NODE_TYPES.ArrayExpression&&e.elements.every(n=>n&&$e(n,!0)))}function Ln(e,t){let n=t.getLastToken(e);if(!n)return 0;let r=t.text.indexOf(`
|
|
3
3
|
`,n.range[1]);return(r!==-1?r:t.text.length)-n.range[1]}function $n(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var Fe={name:Et,rule:Dn};var Fn=/eslint +react-compiler\/react-compiler: +\["error/,xt={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"?y=>n(y):y=>e.sourceCode.getText(y),r=typeof e.getScope=="function"?()=>r():y=>e.sourceCode.getScope(y),l=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,f=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,p={additionalHooks:l,enableDangerousAutofixThisMayCauseInfiniteLoops:f};function i(y){f&&Array.isArray(y.suggest)&&y.suggest.length>0&&(y.fix=y.suggest[0].fix),e.report(y)}let o=e.getSourceCode().scopeManager,a=new WeakMap,s=new WeakSet,c=new WeakMap,g=new WeakMap,T=new WeakSet;function S(y,N){return function(v){if(N.has(v))return N.get(v);let h=y(v);return N.set(v,h),h}}function d(y,N,v,h,w){w&&y.async&&i({node:y,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
|
|
4
4
|
|
package/dist/extended-lint.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{AST_NODE_TYPES as H,ESLintUtils as pn}from"@typescript-eslint/utils";var Ce=Symbol.for("optional");function D(e){return{...e,[Ce]:!0}}function fe(e,t){return{enum:e,...t}}function ne(e){return{...e,type:"boolean"}}function L(e){return{...e,type:"string"}}function J(e){return{...e,type:"number"}}function ot(e){return{...e,type:"integer"}}function V(e,t){return{...t,type:"array",items:e}}function $(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let r,l=[];for(r in e)e[r][Ce]?e[r][Ce]=void 0:l.push(r);l.length>0&&(n.required=l)}return n}function Ie(...e){return{anyOf:e}}var un=pn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),lt="react-compiler-extra",fn=$({runOnlyWithEnableCompilerDirective:D(ne())}),mn=/eslint +react-compiler\/react-compiler: +\["error/;function dn(e){return e.type===H.Identifier?e.name.startsWith("use"):e.type===H.MemberExpression&&e.property.type===H.Identifier?e.property.name.startsWith("use"):!1}var yn=/\bthis[.[]/;function at(e){return yn.test(e)}var gn=un({name:lt,meta:{type:"suggestion",fixable:"code",docs:{description:"Extra rules to enforce best practices when using the React compiler"},messages:{objectMethodIsNotSupported:"Object methods such as `{ method() {} }` have limited support to optimizations in the React compiler, use a function expression `{ method: () => {} }` instead.",replaceWithFunctionExpression:"Replace with function expression",thisKeywordInMethod:"Object method uses `this` keyword which would have different behavior if converted to an arrow function. Fix this manually."},hasSuggestions:!0,schema:[fn]},defaultOptions:[{}],create(e,[t]){let n=!1;if(t.runOnlyWithEnableCompilerDirective){for(let f of e.sourceCode.getAllComments())if(mn.test(f.value)){n=!0;break}if(!n)return{}}function r(f){for(let p of f.properties)if(p.type===H.Property&&p.method&&p.value.type===H.FunctionExpression){let i=e.sourceCode,o=i.getText(p.key),a=p.value,s=i.getText(a.body);if(at(s))e.report({node:p,messageId:"thisKeywordInMethod"});else{let c=a.params.map(T=>i.getText(T)).join(", "),g="";a.generator?g=`${o}: function* (${c}) ${s}`:g=`${o}: (${c}) => ${s}`,e.report({node:p,messageId:"objectMethodIsNotSupported",fix:T=>T.replaceText(p,g)})}}}function l(f){for(let p of f.properties)if(p.type===H.Property&&p.value.type===H.ObjectExpression){for(let i of p.value.properties)if(i.type===H.Property&&i.method&&i.value.type===H.FunctionExpression){let a=e.sourceCode.getText(i.value.body);at(a)&&e.report({node:i,messageId:"thisKeywordInMethod"})}}}return{CallExpression(f){if(dn(f.callee))for(let p of f.arguments){if(p.type===H.ObjectExpression&&(r(p),l(p)),p.type===H.ArrowFunctionExpression&&(p.body.type===H.ObjectExpression&&(r(p.body),l(p.body)),p.body.type===H.BlockStatement))for(let i of p.body.body)i.type===H.ReturnStatement&&i.argument?.type===H.ObjectExpression&&(r(i.argument),l(i.argument));if(p.type===H.FunctionExpression)for(let i of p.body.body)i.type===H.ReturnStatement&&i.argument?.type===H.ObjectExpression&&(r(i.argument),l(i.argument))}}}}}),we={name:lt,rule:gn};import{AST_NODE_TYPES as Re,ESLintUtils as hn}from"@typescript-eslint/utils";var Tn=hn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Sn=$({disallow:D(V($({selector:L(),message:L(),replace:D(Ie(L(),$({regex:L(),with:L()}))),replaceType:D(fe(["suggestion","autofix"]))}))),__dev_simulateFileName:D(L()),mustMatchSyntax:D(V($({includeRegex:L(),mustCallFn:V($({anyCall:V($({fn:L(),withArgs:V($({atIndex:ot(),literal:Ie(L(),J(),ne())}))})),message:D(L())}))})))}),ut="advanced-no-restricted-syntax",En=Tn({name:ut,meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[Sn],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:r,__dev_simulateFileName:l,disallow:f}=t,p=l??e.filename,i=[],o=new Set;for(let{includeRegex:s,mustCallFn:c}of r??[]){let g=bn(p,new RegExp(s));if(!g)continue;let T=S=>{let d=S;for(let{name:b,value:y}of g)d=d.replaceAll(b,y);return d};for(let{anyCall:S,message:d}of c){let b=`Expected file to call the function: ${S.map(({fn:y})=>y).join(" or ")}`;o.add(b),i.push(y=>{let{callee:N}=y;if(N.type===Re.Identifier){for(let{fn:v,withArgs:h}of S)if(N.name===v){o.delete(b);for(let w of h){let R=y.arguments[w.atIndex],k=typeof w.literal=="string"?T(w.literal):w.literal;if(!R){e.report({node:y,messageId:"default",data:{message:`Missing argument with value "${k}" at index ${w.atIndex}${d?`: ${T(d)}`:""}`}});continue}if(R.type!==Re.Literal){e.report({node:R,messageId:"default",data:{message:`Argument at position ${w.atIndex} should the literal "${k}"${d?`: ${T(d)}`:""}`}});continue}R.value!==k&&e.report({node:R,messageId:"default",data:{message:`Argument should have the value "${k}"${d?`: ${T(d)}`:""}`},fix:_=>_.replaceText(R,typeof k=="string"?`'${k}'`:String(k))})}break}}})}}for(let{selector:s,message:c,replace:g,replaceType:T="suggestion"}of f??[]){if(s==="CallExpression"){i.push(S=>{a(g,S,c,T)});continue}n[s]=S=>{a(g,S,c,T)}}return i.length>0&&(n.CallExpression=s=>{if(s.type===Re.CallExpression)for(let c of i)c(s)}),n["Program:exit"]=s=>{for(let c of o)e.report({node:s,messageId:"default",data:{message:`${c}`}})},n;function a(s,c,g,T){let S=d=>{if(!s)return null;if(typeof s=="string")return d.replaceText(c,s);{let b=new RegExp(s.regex),y=e.sourceCode.getText(c);return d.replaceText(c,y.replace(b,s.with))}};e.report({node:c,messageId:"default",data:{message:g},fix:s&&T==="autofix"?S:void 0,suggest:s&&T==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof s=="string"?s:s.with}"`},fix:S}]:void 0})}}});function bn(e,t){let n=[],r=t.exec(e);if(!r)return null;let[l,...f]=r;n.push({name:"$0_lowercase",value:l.toLowerCase()}),n.push({name:"$0_capitalize",value:ct(l)}),n.push({name:"$0_uncapitalize",value:pt(l)}),n.push({name:"$0",value:l});for(let p=0;p<f.length;p++){let i=`$${p+1}`,o=f[p];n.push({name:`${i}_lowercase`,value:o.toLowerCase()}),n.push({name:`${i}_capitalize`,value:ct(o)}),n.push({name:`${i}_uncapitalize`,value:pt(o)}),n.push({name:i,value:o})}return n}function ct(e){return e.charAt(0).toUpperCase()+e.slice(1)}function pt(e){return e.charAt(0).toLowerCase()+e.slice(1)}var ve={name:ut,rule:En};import{AST_NODE_TYPES as F,AST_TOKEN_TYPES as xn,ESLintUtils as Cn}from"@typescript-eslint/utils";var In=Cn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),mt="collapse-simple-objs-in-one-line",wn=$({maxLineLength:D(J()),maxProperties:D(J()),nestedObjMaxLineLength:D(J()),nestedObjMaxProperties:D(J()),ignoreTypesWithSuffix:D(V(L()))}),Rn=In({name:mt,meta:{type:"suggestion",fixable:"code",docs:{description:"Format simple objects and types in one line"},messages:{singleLineProp:"Object/type should be written in a single line"},schema:[wn]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode,r=t.ignoreTypesWithSuffix??[],l=t.maxProperties??2,f=t.nestedObjMaxLineLength??t.maxLineLength,p=t.nestedObjMaxProperties??3;function i(a){if(a.type===F.ObjectExpression){let s=a.parent.type===F.Property,c=s?p:l,g=a.properties.length;if(g>c)return!1;if(g===1){let S=a.properties[0];return S.type===F.Property&&S.value.type===F.ObjectExpression||S.type===F.Property&&S.value.type===F.ArrayExpression&&!S.value.elements.every(b=>b&&ke(b))?!1:{text:n.getText(S),isNested:s,propsSize:g}}let T=[];for(let S of a.properties){if(S.type===F.Property&&!ke(S.value))return!1;T.push(n.getText(S))}return{text:T.join(", "),isNested:s,propsSize:g}}else{let s=a.parent.parent?.type===F.TSPropertySignature,c=s?p:l,g=a.members.length;if(g>c)return!1;if(r.length>0&&a.parent.type===F.TSTypeAliasDeclaration){let S=a.parent.id.name;if(r.some(d=>S.endsWith(d)))return!1}if(g===1){let S=a.members[0];return S.type===F.TSPropertySignature&&S.typeAnnotation?.typeAnnotation.type===F.TSTypeLiteral?!1:{text:n.getText(S),isNested:s,propsSize:1}}if(a.parent.type===F.TSIntersectionType||a.parent.type===F.TSUnionType)return!1;let T=[];for(let S of a.members){if(S.type!==F.TSPropertySignature)return!1;let d=S.typeAnnotation?.typeAnnotation;if(!d||d.type===F.TSTypeLiteral||!ft(d))return!1;if(d.type===F.TSTypeReference&&d.typeArguments){if(d.typeArguments.params.length>1)return!1;let y=d.typeArguments.params[0];if(!ft(y))return!1}let b=n.getText(S).trim();(b.endsWith(";")||b.endsWith(","))&&(b=b.slice(0,-1)),T.push(b)}return{text:T.join("; "),isNested:s,propsSize:g}}}function o(a){if(a.loc.start.line===a.loc.end.line)return;if(a.parent.type!==F.JSXExpressionContainer){let d=0,b=n.getTokenAfter(a,{filter:y=>y.type!==xn.Punctuator?!0:y.value===","||y.value===";"||y.value===")"||y.value==="}"?(d++,!1):!0});if(d>
|
|
1
|
+
import{AST_NODE_TYPES as H,ESLintUtils as pn}from"@typescript-eslint/utils";var Ce=Symbol.for("optional");function D(e){return{...e,[Ce]:!0}}function fe(e,t){return{enum:e,...t}}function ne(e){return{...e,type:"boolean"}}function L(e){return{...e,type:"string"}}function J(e){return{...e,type:"number"}}function ot(e){return{...e,type:"integer"}}function V(e,t){return{...t,type:"array",items:e}}function $(e,t){let n={...t,type:"object",properties:e};if(e&&(n.additionalProperties||=!1,!n.required)){let r,l=[];for(r in e)e[r][Ce]?e[r][Ce]=void 0:l.push(r);l.length>0&&(n.required=l)}return n}function Ie(...e){return{anyOf:e}}var un=pn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),lt="react-compiler-extra",fn=$({runOnlyWithEnableCompilerDirective:D(ne())}),mn=/eslint +react-compiler\/react-compiler: +\["error/;function dn(e){return e.type===H.Identifier?e.name.startsWith("use"):e.type===H.MemberExpression&&e.property.type===H.Identifier?e.property.name.startsWith("use"):!1}var yn=/\bthis[.[]/;function at(e){return yn.test(e)}var gn=un({name:lt,meta:{type:"suggestion",fixable:"code",docs:{description:"Extra rules to enforce best practices when using the React compiler"},messages:{objectMethodIsNotSupported:"Object methods such as `{ method() {} }` have limited support to optimizations in the React compiler, use a function expression `{ method: () => {} }` instead.",replaceWithFunctionExpression:"Replace with function expression",thisKeywordInMethod:"Object method uses `this` keyword which would have different behavior if converted to an arrow function. Fix this manually."},hasSuggestions:!0,schema:[fn]},defaultOptions:[{}],create(e,[t]){let n=!1;if(t.runOnlyWithEnableCompilerDirective){for(let f of e.sourceCode.getAllComments())if(mn.test(f.value)){n=!0;break}if(!n)return{}}function r(f){for(let p of f.properties)if(p.type===H.Property&&p.method&&p.value.type===H.FunctionExpression){let i=e.sourceCode,o=i.getText(p.key),a=p.value,s=i.getText(a.body);if(at(s))e.report({node:p,messageId:"thisKeywordInMethod"});else{let c=a.params.map(T=>i.getText(T)).join(", "),g="";a.generator?g=`${o}: function* (${c}) ${s}`:g=`${o}: (${c}) => ${s}`,e.report({node:p,messageId:"objectMethodIsNotSupported",fix:T=>T.replaceText(p,g)})}}}function l(f){for(let p of f.properties)if(p.type===H.Property&&p.value.type===H.ObjectExpression){for(let i of p.value.properties)if(i.type===H.Property&&i.method&&i.value.type===H.FunctionExpression){let a=e.sourceCode.getText(i.value.body);at(a)&&e.report({node:i,messageId:"thisKeywordInMethod"})}}}return{CallExpression(f){if(dn(f.callee))for(let p of f.arguments){if(p.type===H.ObjectExpression&&(r(p),l(p)),p.type===H.ArrowFunctionExpression&&(p.body.type===H.ObjectExpression&&(r(p.body),l(p.body)),p.body.type===H.BlockStatement))for(let i of p.body.body)i.type===H.ReturnStatement&&i.argument?.type===H.ObjectExpression&&(r(i.argument),l(i.argument));if(p.type===H.FunctionExpression)for(let i of p.body.body)i.type===H.ReturnStatement&&i.argument?.type===H.ObjectExpression&&(r(i.argument),l(i.argument))}}}}}),we={name:lt,rule:gn};import{AST_NODE_TYPES as Re,ESLintUtils as hn}from"@typescript-eslint/utils";var Tn=hn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),Sn=$({disallow:D(V($({selector:L(),message:L(),replace:D(Ie(L(),$({regex:L(),with:L()}))),replaceType:D(fe(["suggestion","autofix"]))}))),__dev_simulateFileName:D(L()),mustMatchSyntax:D(V($({includeRegex:L(),mustCallFn:V($({anyCall:V($({fn:L(),withArgs:V($({atIndex:ot(),literal:Ie(L(),J(),ne())}))})),message:D(L())}))})))}),ut="advanced-no-restricted-syntax",En=Tn({name:ut,meta:{type:"suggestion",docs:{description:"Disallow specific syntax patterns"},schema:[Sn],messages:{default:"{{message}}"},fixable:"code",hasSuggestions:!0},defaultOptions:[{disallow:[]}],create(e,[t]){let n={},{mustMatchSyntax:r,__dev_simulateFileName:l,disallow:f}=t,p=l??e.filename,i=[],o=new Set;for(let{includeRegex:s,mustCallFn:c}of r??[]){let g=bn(p,new RegExp(s));if(!g)continue;let T=S=>{let d=S;for(let{name:b,value:y}of g)d=d.replaceAll(b,y);return d};for(let{anyCall:S,message:d}of c){let b=`Expected file to call the function: ${S.map(({fn:y})=>y).join(" or ")}`;o.add(b),i.push(y=>{let{callee:N}=y;if(N.type===Re.Identifier){for(let{fn:v,withArgs:h}of S)if(N.name===v){o.delete(b);for(let w of h){let R=y.arguments[w.atIndex],k=typeof w.literal=="string"?T(w.literal):w.literal;if(!R){e.report({node:y,messageId:"default",data:{message:`Missing argument with value "${k}" at index ${w.atIndex}${d?`: ${T(d)}`:""}`}});continue}if(R.type!==Re.Literal){e.report({node:R,messageId:"default",data:{message:`Argument at position ${w.atIndex} should the literal "${k}"${d?`: ${T(d)}`:""}`}});continue}R.value!==k&&e.report({node:R,messageId:"default",data:{message:`Argument should have the value "${k}"${d?`: ${T(d)}`:""}`},fix:_=>_.replaceText(R,typeof k=="string"?`'${k}'`:String(k))})}break}}})}}for(let{selector:s,message:c,replace:g,replaceType:T="suggestion"}of f??[]){if(s==="CallExpression"){i.push(S=>{a(g,S,c,T)});continue}n[s]=S=>{a(g,S,c,T)}}return i.length>0&&(n.CallExpression=s=>{if(s.type===Re.CallExpression)for(let c of i)c(s)}),n["Program:exit"]=s=>{for(let c of o)e.report({node:s,messageId:"default",data:{message:`${c}`}})},n;function a(s,c,g,T){let S=d=>{if(!s)return null;if(typeof s=="string")return d.replaceText(c,s);{let b=new RegExp(s.regex),y=e.sourceCode.getText(c);return d.replaceText(c,y.replace(b,s.with))}};e.report({node:c,messageId:"default",data:{message:g},fix:s&&T==="autofix"?S:void 0,suggest:s&&T==="suggestion"?[{messageId:"default",data:{message:`Replace with "${typeof s=="string"?s:s.with}"`},fix:S}]:void 0})}}});function bn(e,t){let n=[],r=t.exec(e);if(!r)return null;let[l,...f]=r;n.push({name:"$0_lowercase",value:l.toLowerCase()}),n.push({name:"$0_capitalize",value:ct(l)}),n.push({name:"$0_uncapitalize",value:pt(l)}),n.push({name:"$0",value:l});for(let p=0;p<f.length;p++){let i=`$${p+1}`,o=f[p];n.push({name:`${i}_lowercase`,value:o.toLowerCase()}),n.push({name:`${i}_capitalize`,value:ct(o)}),n.push({name:`${i}_uncapitalize`,value:pt(o)}),n.push({name:i,value:o})}return n}function ct(e){return e.charAt(0).toUpperCase()+e.slice(1)}function pt(e){return e.charAt(0).toLowerCase()+e.slice(1)}var ve={name:ut,rule:En};import{AST_NODE_TYPES as F,AST_TOKEN_TYPES as xn,ESLintUtils as Cn}from"@typescript-eslint/utils";var In=Cn.RuleCreator(e=>`https://github.com/lucasols/extended-lint#${e}`),mt="collapse-simple-objs-in-one-line",wn=$({maxLineLength:D(J()),maxProperties:D(J()),nestedObjMaxLineLength:D(J()),nestedObjMaxProperties:D(J()),ignoreTypesWithSuffix:D(V(L()))}),Rn=In({name:mt,meta:{type:"suggestion",fixable:"code",docs:{description:"Format simple objects and types in one line"},messages:{singleLineProp:"Object/type should be written in a single line"},schema:[wn]},defaultOptions:[{}],create(e,[t]){let n=e.sourceCode,r=t.ignoreTypesWithSuffix??[],l=t.maxProperties??2,f=t.nestedObjMaxLineLength??t.maxLineLength,p=t.nestedObjMaxProperties??3;function i(a){if(a.type===F.ObjectExpression){let s=a.parent.type===F.Property,c=s?p:l,g=a.properties.length;if(g>c)return!1;if(g===1){let S=a.properties[0];return S.type===F.Property&&S.value.type===F.ObjectExpression||S.type===F.Property&&S.value.type===F.ArrayExpression&&!S.value.elements.every(b=>b&&ke(b))?!1:{text:n.getText(S),isNested:s,propsSize:g}}let T=[];for(let S of a.properties){if(S.type===F.Property&&!ke(S.value))return!1;T.push(n.getText(S))}return{text:T.join(", "),isNested:s,propsSize:g}}else{let s=a.parent.parent?.type===F.TSPropertySignature,c=s?p:l,g=a.members.length;if(g>c)return!1;if(r.length>0&&a.parent.type===F.TSTypeAliasDeclaration){let S=a.parent.id.name;if(r.some(d=>S.endsWith(d)))return!1}if(g===1){let S=a.members[0];return S.type===F.TSPropertySignature&&S.typeAnnotation?.typeAnnotation.type===F.TSTypeLiteral?!1:{text:n.getText(S),isNested:s,propsSize:1}}if(a.parent.type===F.TSIntersectionType||a.parent.type===F.TSUnionType)return!1;let T=[];for(let S of a.members){if(S.type!==F.TSPropertySignature)return!1;let d=S.typeAnnotation?.typeAnnotation;if(!d||d.type===F.TSTypeLiteral||!ft(d))return!1;if(d.type===F.TSTypeReference&&d.typeArguments){if(d.typeArguments.params.length>1)return!1;let y=d.typeArguments.params[0];if(!ft(y))return!1}let b=n.getText(S).trim();(b.endsWith(";")||b.endsWith(","))&&(b=b.slice(0,-1)),T.push(b)}return{text:T.join("; "),isNested:s,propsSize:g}}}function o(a){if(a.loc.start.line===a.loc.end.line)return;if(a.parent.type!==F.JSXExpressionContainer){let d=0,b=n.getTokenAfter(a,{filter:y=>y.type!==xn.Punctuator?!0:y.value===","||y.value===";"||y.value===")"||y.value==="}"?(d++,!1):!0});if(d>4||b?.loc.start.line===a.loc.end.line)return}let s=i(a);if(!s)return;let c=s.text;if(c.includes(`
|
|
2
2
|
`)||n.getCommentsInside(a).length>0)return;c.endsWith(";")&&(c=c.slice(0,-1));let g=`{ ${c} }`,T=kn(n,a),S=s.isNested&&s.propsSize>2?f:t.maxLineLength;S&&g.length+T.length+vn(a,n)>S||e.report({node:a,messageId:"singleLineProp",fix:d=>d.replaceText(a,g)})}return{TSTypeLiteral:o,ObjectExpression:o}}});function ft(e){return e.type===F.TSLiteralType||e.type===F.TSTypeReference||e.type===F.TSNumberKeyword||e.type===F.TSStringKeyword||e.type===F.TSBooleanKeyword||e.type===F.TSNullKeyword||e.type===F.TSUndefinedKeyword}function ke(e,t){return!!(e.type===F.Literal||e.type===F.Identifier||e.type===F.TemplateLiteral||e.type===F.TaggedTemplateExpression||!t&&e.type===F.ArrayExpression&&e.elements.every(n=>n&&ke(n,!0)))}function vn(e,t){let n=t.getLastToken(e);if(!n)return 0;let r=t.text.indexOf(`
|
|
3
3
|
`,n.range[1]);return(r!==-1?r:t.text.length)-n.range[1]}function kn(e,t){return e.text.slice(t.range[0]-t.loc.start.column,t.range[0])}var Ae={name:mt,rule:Rn};var An=/eslint +react-compiler\/react-compiler: +\["error/,yt={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"?y=>n(y):y=>e.sourceCode.getText(y),r=typeof e.getScope=="function"?()=>r():y=>e.sourceCode.getScope(y),l=e.options&&e.options[0]&&e.options[0].additionalHooks?new RegExp(e.options[0].additionalHooks):void 0,f=e.options&&e.options[0]&&e.options[0].enableDangerousAutofixThisMayCauseInfiniteLoops||!1,p={additionalHooks:l,enableDangerousAutofixThisMayCauseInfiniteLoops:f};function i(y){f&&Array.isArray(y.suggest)&&y.suggest.length>0&&(y.fix=y.suggest[0].fix),e.report(y)}let o=e.getSourceCode().scopeManager,a=new WeakMap,s=new WeakSet,c=new WeakMap,g=new WeakMap,T=new WeakSet;function S(y,N){return function(v){if(N.has(v))return N.get(v);let h=y(v);return N.set(v,h),h}}function d(y,N,v,h,w){w&&y.async&&i({node:y,message:`Effect callbacks are synchronous to prevent race conditions. Put the async function inside:
|
|
4
4
|
|