eslint-plugin-functype 2.127.2 → 2.200.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/README.md +82 -76
- package/dist/cli/list-rules.js.map +1 -1
- package/dist/configs/recommended.d.ts +40 -46
- package/dist/configs/recommended.js +1 -1
- package/dist/configs/recommended.js.map +1 -1
- package/dist/configs/tests.d.ts +8 -5
- package/dist/configs/tests.js +1 -1
- package/dist/configs/tests.js.map +1 -1
- package/dist/index.d.ts +1 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/rules/collection-naming.d.ts +1 -4
- package/dist/rules/collection-naming.js.map +1 -1
- package/dist/rules/index.d.ts +1 -4
- package/dist/rules/index.js.map +1 -1
- package/dist/rules/must-fold-on-component-return.d.ts +1 -4
- package/dist/rules/must-fold-on-component-return.js.map +1 -1
- package/dist/rules/no-array-mutation.d.ts +1 -4
- package/dist/rules/no-array-mutation.js +1 -1
- package/dist/rules/no-array-mutation.js.map +1 -1
- package/dist/rules/no-floating-io.d.ts +1 -4
- package/dist/rules/no-floating-io.js.map +1 -1
- package/dist/rules/no-floating-result.d.ts +1 -4
- package/dist/rules/no-floating-result.js.map +1 -1
- package/dist/rules/no-get-unsafe.d.ts +1 -4
- package/dist/rules/no-get-unsafe.js +1 -1
- package/dist/rules/no-get-unsafe.js.map +1 -1
- package/dist/rules/no-getOrThrow-in-render.d.ts +1 -4
- package/dist/rules/no-getOrThrow-in-render.js +1 -1
- package/dist/rules/no-getOrThrow-in-render.js.map +1 -1
- package/dist/rules/no-imperative-loops.d.ts +1 -4
- package/dist/rules/no-imperative-loops.js +1 -1
- package/dist/rules/no-imperative-loops.js.map +1 -1
- package/dist/rules/no-let.d.ts +1 -4
- package/dist/rules/no-let.js.map +1 -1
- package/dist/rules/no-serialize-container.d.ts +1 -4
- package/dist/rules/no-serialize-container.js.map +1 -1
- package/dist/rules/prefer-do-notation.d.ts +1 -4
- package/dist/rules/prefer-do-notation.js +1 -1
- package/dist/rules/prefer-do-notation.js.map +1 -1
- package/dist/rules/prefer-either.d.ts +1 -4
- package/dist/rules/prefer-either.js.map +1 -1
- package/dist/rules/prefer-flatmap.d.ts +1 -4
- package/dist/rules/prefer-flatmap.js +1 -1
- package/dist/rules/prefer-flatmap.js.map +1 -1
- package/dist/rules/prefer-fold.d.ts +1 -4
- package/dist/rules/prefer-fold.js +1 -1
- package/dist/rules/prefer-fold.js.map +1 -1
- package/dist/rules/prefer-functype-map.d.ts +1 -4
- package/dist/rules/prefer-functype-map.js.map +1 -1
- package/dist/rules/prefer-functype-set.d.ts +1 -4
- package/dist/rules/prefer-functype-set.js.map +1 -1
- package/dist/rules/prefer-list.d.ts +1 -4
- package/dist/rules/prefer-list.js +2 -2
- package/dist/rules/prefer-list.js.map +1 -1
- package/dist/rules/prefer-map.d.ts +1 -4
- package/dist/rules/prefer-map.js.map +1 -1
- package/dist/rules/prefer-option.d.ts +1 -4
- package/dist/rules/prefer-option.js.map +1 -1
- package/dist/rules/prefer-try.d.ts +1 -4
- package/dist/rules/prefer-try.js +1 -1
- package/dist/rules/prefer-try.js.map +1 -1
- package/dist/types/ast.d.ts +1 -4
- package/dist/utils/array-mutation.d.ts +1 -4
- package/dist/utils/array-mutation.js.map +1 -1
- package/dist/utils/ast-walk.d.ts +1 -4
- package/dist/utils/ast-walk.js.map +1 -1
- package/dist/utils/async-detection.d.ts +1 -4
- package/dist/utils/async-detection.js.map +1 -1
- package/dist/utils/boundary-tags.d.ts +1 -4
- package/dist/utils/boundary-tags.js.map +1 -1
- package/dist/utils/collection-binding.d.ts +1 -4
- package/dist/utils/collection-binding.js.map +1 -1
- package/dist/utils/dependency-validator.d.ts +1 -3
- package/dist/utils/dependency-validator.js.map +1 -1
- package/dist/utils/functype-detection.d.ts +1 -4
- package/dist/utils/functype-detection.js +1 -1
- package/dist/utils/functype-detection.js.map +1 -1
- package/dist/utils/functype-predicates.d.ts +1 -4
- package/dist/utils/functype-predicates.js.map +1 -1
- package/dist/utils/host-throws.d.ts +1 -4
- package/dist/utils/host-throws.js.map +1 -1
- package/dist/utils/import-fixer.d.ts +1 -4
- package/dist/utils/import-fixer.js.map +1 -1
- package/dist/utils/mutable-collection.d.ts +1 -4
- package/dist/utils/mutable-collection.js.map +1 -1
- package/dist/utils/react-render.d.ts +1 -4
- package/dist/utils/react-render.js.map +1 -1
- package/dist/utils/readonly-contract.d.ts +1 -4
- package/dist/utils/readonly-contract.js.map +1 -1
- package/dist/utils/type-aware.d.ts +2 -5
- package/dist/utils/type-aware.js +1 -1
- package/dist/utils/type-aware.js.map +1 -1
- package/dist/utils/wire-types.d.ts +1 -4
- package/dist/utils/wire-types.js.map +1 -1
- package/package.json +5 -5
- package/dist/configs/agent.d.ts +0 -45
- package/dist/configs/agent.js +0 -2
- package/dist/configs/agent.js.map +0 -1
- package/dist/configs/strict.d.ts +0 -26
- package/dist/configs/strict.js +0 -2
- package/dist/configs/strict.js.map +0 -1
package/dist/utils/type-aware.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=/* @__PURE__ */ new Set([`Iterable`,`AsyncIterable`,`IterableIterator`,`ArrayLike`]),t=e=>{let t=e.sourceCode.parserServices;return t?.program&&t.esTreeNodeToTSNodeMap?t:void 0},n=(e,n)=>{let r=t(n);if(!r)return;let i=r.esTreeNodeToTSNodeMap.get(e);if(!i)return;let a=r.program.getTypeChecker(),o=a.getNonNullableType(a.getTypeAtLocation(i));return a.getPropertyOfType(o,`orThrow`)!==void 0&&a.getPropertyOfType(o,`fold`)!==void 0},r=(e,n)=>{let r=t(n);if(!r)return;let i=r.esTreeNodeToTSNodeMap.get(e);if(!i)return;let a=r.program.getTypeChecker(),o=a.getNonNullableType(a.getTypeAtLocation(i));return a.getPropertyOfType(o,`runExit`)!==void 0&&a.getPropertyOfType(o,`provideLayer`)!==void 0},i=(e,n)=>{let r=t(n);if(!r)return;let i=r.esTreeNodeToTSNodeMap.get(e);if(!i)return;let a=r.program.getTypeChecker(),o=a.getNonNullableType(a.getTypeAtLocation(i)),s=(e,t)=>a.getPropertyOfType(e,t)!==void 0;return(o.types??[o]).some(e=>s(e,`fold`)&&(s(e,`isLeft`)||s(e,`isFailure`))&&!s(e,`runExit`))},a={LeftOf:`Either`,RightOf:`Either`},o=e=>{let t=(e.aliasSymbol?.name??e.getSymbol?.()?.name)?.replace(/\$\d+$/,``);return t===void 0||t.startsWith(`__`)?`functype container`:a[t]??t},s=e=>{let t=e.getSymbol?.();return t===void 0||t.name.startsWith(`__`)?!1:(t.getDeclarations?.()??[]).some(e=>e.getSourceFile().fileName.includes(`/node_modules/`))},c=(e,n)=>{let r=t(n);if(!r)return;let i=r.esTreeNodeToTSNodeMap.get(e);if(!i)return;let a=r.program.getTypeChecker(),c=/* @__PURE__ */ new Set,u=e=>a.getPropertyOfType(e,`_tag`)!==void 0&&a.getPropertyOfType(e,`fold`)!==void 0,d=(e,t)=>e===``?t:t.startsWith(`[`)?e+t:`${e}.${t}`,f=(e,t,n)=>{if(n>4||c.has(e)||l(e))return;c.add(e);let r=e;if(u(e))return{path:t,name:o(r)};if(r.isUnionOrIntersection?.()===!0)return(r.types??[]).map(e=>f(e,t,n)).find(e=>e!==void 0);if((r.getCallSignatures?.()??[]).length>0)return;if(a.isArrayLikeType(e)||a.isTupleType(e))return a.getTypeArguments(e).map(e=>f(e,t===``?`[]`:`${t}[]`,n+1)).find(e=>e!==void 0);let p=a.getIndexInfoOfType(e,0)?.type,m=p===void 0?void 0:f(p,d(t,`[key]`),n+1);if(m!==void 0)return m;if(!(r.getSymbol?.()===void 0||s(r)))return a.getPropertiesOfType(e).map(e=>f(a.getTypeOfSymbolAtLocation(e,i),d(t,e.name),n+1)).find(e=>e!==void 0)};return f(a.getTypeAtLocation(i),``,0)},l=e=>e.isTypeParameter?.()===!0,u=e=>{let t=e.parent;if(!t)return null;if((t.type===`CallExpression`||t.type===`NewExpression`)&&t.callee!==e){let n=t.arguments.indexOf(e);return n<0?null:{call:t,argument:e,index:n}}return t.type===`TSAsExpression`||t.type===`TSSatisfiesExpression`||t.type===`ConditionalExpression`&&t.test!==e||t.type===`LogicalExpression`||t.type===`Property`||t.type===`ObjectExpression`||t.type===`ArrayExpression`||t.type===`SpreadElement`?u(t):null},d=(e,t,n)=>{let r=u(n),i=r?t.esTreeNodeToTSNodeMap.get(r.call):void 0,a=i?e.getResolvedSignature(i)?.getDeclaration()?.parameters:void 0;if(!r||!a||a.length===0)return!1;let o=a[Math.min(r.index,a.length-1)];if(o?.type===void 0)return!1;let s=e.getTypeAtLocation(o.type);return(s.types??[s]).some(l)},f=(e,t,n)=>{let r=u(n),i=r?t.esTreeNodeToTSNodeMap.get(r.call):void 0,a=i?e.getResolvedSignature(i):void 0,o=r?t.esTreeNodeToTSNodeMap.get(r.argument):void 0;if(!a||!o)return!1;let s=e.getTypeAtLocation(o),c=t=>t===s||e.isTypeAssignableTo(s,t)&&e.isTypeAssignableTo(t,s),l=(t,n)=>{if(n>3)return!1;if(c(t))return!0;let{types:r,target:i}=t;if(r)return r.some(e=>l(e,n+1));if(i!==void 0&&(e.isTupleType(t)||e.isArrayLikeType(t)))return e.getTypeArguments(t).some(e=>l(e,n+1));let a=e.getAwaitedType(t);return a!==void 0&&a!==t&&l(a,n+1)};return l(e.getReturnTypeOfSignature(a),0)},p=(e,t,n)=>h(n.type)||l(n.type)&&!f(e,t,n.at),m=(t,n,r)=>{if(p(t,n,r))return!0;let{types:i,symbol:a}=r.type;return i?i.some(e=>m(t,n,{type:e,at:r.at})):a?.name!==void 0&&e.has(a.name)?!0:!l(r.type)&&t.isArrayLikeType(r.type)},h=e=>{let{flags:t}=e;return t!==void 0&&!!(t&3)},g=(e,t)=>{let{types:n,symbol:r}=t;return n?n.some(t=>g(e,t)):r?.name===`Array`&&e.isArrayLikeType(t)},_=e=>e.computed?null:e.key?.type===`Identifier`?e.key.name:e.key?.type===`Literal`&&typeof e.key.value==`string`?e.key.value:null,v=(e,t,n,r,i=0)=>{if(i>4)return;let a=t.esTreeNodeToTSNodeMap.get(n),o=a?e.getContextualType(a):void 0;if(o!==void 0)return{type:o,at:n};let s=n.parent;if(s?.type===`ArrowFunctionExpression`&&s.body===n){let n=s.parent;if(n?.type===`VariableDeclarator`&&n.init===s&&n.id?.type===`Identifier`)return(r.sourceCode.getDeclaredVariables(n)[0]?.references??[]).map(e=>e.identifier.parent).filter(e=>e?.type===`CallExpression`).map(n=>v(e,t,n,r,i+1)).find(e=>e!==void 0)}if((s?.type===`CallExpression`||s?.type===`NewExpression`)&&s.callee!==n){let r=s.arguments.indexOf(n),i=t.esTreeNodeToTSNodeMap.get(s),a=r>=0&&i?e.getResolvedSignature(i)?.parameters[r]:void 0;return a===void 0?void 0:{type:e.getTypeOfSymbolAtLocation(a,i),at:n}}let c=s?.type===`Property`&&s.value===n?s.parent:void 0;if(c?.type!==`ObjectExpression`)return;let l=v(e,t,c,r,i+1);if(l===void 0||p(e,t,l))return l;let u=l.type,d=_(s);if(d===null){let r=s.key,i=r?t.esTreeNodeToTSNodeMap.get(r):void 0,o=i?e.getTypeAtLocation(i):void 0,c=o?.value??o?.types?.[0]?.value,l=typeof c==`string`?e.getPropertyOfType(u,c):void 0,d=l===void 0?e.getIndexInfoOfType(u,0)?.type:e.getTypeOfSymbolAtLocation(l,a);return d===void 0?void 0:{type:d,at:n}}let f=e.getPropertyOfType(u,d);return f===void 0?void 0:{type:e.getTypeOfSymbolAtLocation(f,a),at:n}},y=(e,n)=>{let r=t(n);if(!r)return;let i=r.program.getTypeChecker(),a=v(i,r,e,n);if(a!==void 0)return d(i,r,a.at)?!f(i,r,a.at):m(i,r,a)},b=(e,n)=>{let r=t(n);if(!r)return;let i=r.program.getTypeChecker(),a=v(i,r,e,n);return a===void 0||d(i,r,a.at)?!1:g(i,a.type)},x=(e,n)=>{let r=t(n);if(!r)return;let i=r.esTreeNodeToTSNodeMap.get(e);if(!i)return;let a=r.program.getTypeChecker(),o=a.getTypeAtLocation(i);if(h(o))return!0;if(!a.isArrayLikeType(o))return!1;let s=a.getTypeArguments(o)[0];return s!==void 0&&h(s)},S=e=>t(e)!==void 0;export{i as canCarryFailureByType,c as containerInsideByType,y as flowsIntoArraySlot,b as flowsIntoMutableArraySlot,S as hasTypeInformation,n as isExtractableByType,r as isIOByType,x as isUntypedExpression};
|
|
1
|
+
const e=/* @__PURE__ */ new Set([`Iterable`,`AsyncIterable`,`IterableIterator`,`ArrayLike`]),t=e=>{let t=e.sourceCode.parserServices;return t?.program&&t.esTreeNodeToTSNodeMap?t:void 0},n=(e,n)=>{let r=t(n);if(!r)return;let i=r.esTreeNodeToTSNodeMap.get(e);if(!i)return;let a=r.program.getTypeChecker(),o=a.getNonNullableType(a.getTypeAtLocation(i));return a.getPropertyOfType(o,`orThrow`)!==void 0&&a.getPropertyOfType(o,`fold`)!==void 0},r=(e,n)=>{let r=t(n);if(!r)return;let i=r.esTreeNodeToTSNodeMap.get(e);if(!i)return;let a=r.program.getTypeChecker(),o=a.getNonNullableType(a.getTypeAtLocation(i));return a.getPropertyOfType(o,`runExit`)!==void 0&&a.getPropertyOfType(o,`provideLayer`)!==void 0},i=(e,n)=>{let r=t(n);if(!r)return;let i=r.esTreeNodeToTSNodeMap.get(e);if(!i)return;let a=r.program.getTypeChecker(),o=a.getNonNullableType(a.getTypeAtLocation(i)),s=(e,t)=>a.getPropertyOfType(e,t)!==void 0;return(o.types??[o]).some(e=>s(e,`fold`)&&(s(e,`isLeft`)||s(e,`isFailure`))&&!s(e,`runExit`))},a={LeftOf:`Either`,RightOf:`Either`,SomeOf:`Option`,NoneOf:`Option`,SuccessOf:`Try`,FailureOf:`Try`,SuccessExitOf:`Exit`,FailureExitOf:`Exit`,DieExitOf:`Exit`,InterruptedExitOf:`Exit`},o=e=>{let t=(e.aliasSymbol?.name??e.getSymbol?.()?.name)?.replace(/\$\d+$/,``);return t===void 0||t.startsWith(`__`)?`functype container`:a[t]??t},s=e=>{let t=e.getSymbol?.();return t===void 0||t.name.startsWith(`__`)?!1:(t.getDeclarations?.()??[]).some(e=>e.getSourceFile().fileName.includes(`/node_modules/`))},c=(e,n)=>{let r=t(n);if(!r)return;let i=r.esTreeNodeToTSNodeMap.get(e);if(!i)return;let a=r.program.getTypeChecker(),c=/* @__PURE__ */ new Set,u=e=>a.getPropertyOfType(e,`_tag`)!==void 0&&a.getPropertyOfType(e,`fold`)!==void 0,d=(e,t)=>e===``?t:t.startsWith(`[`)?e+t:`${e}.${t}`,f=(e,t,n)=>{if(n>4||c.has(e)||l(e))return;c.add(e);let r=e;if(u(e))return{path:t,name:o(r)};if(r.isUnionOrIntersection?.()===!0)return(r.types??[]).map(e=>f(e,t,n)).find(e=>e!==void 0);if((r.getCallSignatures?.()??[]).length>0)return;if(a.isArrayLikeType(e)||a.isTupleType(e))return a.getTypeArguments(e).map(e=>f(e,t===``?`[]`:`${t}[]`,n+1)).find(e=>e!==void 0);let p=a.getIndexInfoOfType(e,0)?.type,m=p===void 0?void 0:f(p,d(t,`[key]`),n+1);if(m!==void 0)return m;if(!(r.getSymbol?.()===void 0||s(r)))return a.getPropertiesOfType(e).map(e=>f(a.getTypeOfSymbolAtLocation(e,i),d(t,e.name),n+1)).find(e=>e!==void 0)};return f(a.getTypeAtLocation(i),``,0)},l=e=>e.isTypeParameter?.()===!0,u=e=>{let t=e.parent;if(!t)return null;if((t.type===`CallExpression`||t.type===`NewExpression`)&&t.callee!==e){let n=t.arguments.indexOf(e);return n<0?null:{call:t,argument:e,index:n}}return t.type===`TSAsExpression`||t.type===`TSSatisfiesExpression`||t.type===`ConditionalExpression`&&t.test!==e||t.type===`LogicalExpression`||t.type===`Property`||t.type===`ObjectExpression`||t.type===`ArrayExpression`||t.type===`SpreadElement`?u(t):null},d=(e,t,n)=>{let r=u(n),i=r?t.esTreeNodeToTSNodeMap.get(r.call):void 0,a=i?e.getResolvedSignature(i)?.getDeclaration()?.parameters:void 0;if(!r||!a||a.length===0)return!1;let o=a[Math.min(r.index,a.length-1)];if(o?.type===void 0)return!1;let s=e.getTypeAtLocation(o.type);return(s.types??[s]).some(l)},f=(e,t,n)=>{let r=u(n),i=r?t.esTreeNodeToTSNodeMap.get(r.call):void 0,a=i?e.getResolvedSignature(i):void 0,o=r?t.esTreeNodeToTSNodeMap.get(r.argument):void 0;if(!a||!o)return!1;let s=e.getTypeAtLocation(o),c=t=>t===s||e.isTypeAssignableTo(s,t)&&e.isTypeAssignableTo(t,s),l=(t,n)=>{if(n>3)return!1;if(c(t))return!0;let{types:r,target:i}=t;if(r)return r.some(e=>l(e,n+1));if(i!==void 0&&(e.isTupleType(t)||e.isArrayLikeType(t)))return e.getTypeArguments(t).some(e=>l(e,n+1));let a=e.getAwaitedType(t);return a!==void 0&&a!==t&&l(a,n+1)};return l(e.getReturnTypeOfSignature(a),0)},p=(e,t,n)=>h(n.type)||l(n.type)&&!f(e,t,n.at),m=(t,n,r)=>{if(p(t,n,r))return!0;let{types:i,symbol:a}=r.type;return i?i.some(e=>m(t,n,{type:e,at:r.at})):a?.name!==void 0&&e.has(a.name)?!0:!l(r.type)&&t.isArrayLikeType(r.type)},h=e=>{let{flags:t}=e;return t!==void 0&&!!(t&3)},g=(e,t)=>{let{types:n,symbol:r}=t;return n?n.some(t=>g(e,t)):r?.name===`Array`&&e.isArrayLikeType(t)},_=e=>e.computed?null:e.key?.type===`Identifier`?e.key.name:e.key?.type===`Literal`&&typeof e.key.value==`string`?e.key.value:null,v=(e,t,n,r,i=0)=>{if(i>4)return;let a=t.esTreeNodeToTSNodeMap.get(n),o=a?e.getContextualType(a):void 0;if(o!==void 0)return{type:o,at:n};let s=n.parent;if(s?.type===`ArrowFunctionExpression`&&s.body===n){let n=s.parent;if(n?.type===`VariableDeclarator`&&n.init===s&&n.id?.type===`Identifier`)return(r.sourceCode.getDeclaredVariables(n)[0]?.references??[]).map(e=>e.identifier.parent).filter(e=>e?.type===`CallExpression`).map(n=>v(e,t,n,r,i+1)).find(e=>e!==void 0)}if((s?.type===`CallExpression`||s?.type===`NewExpression`)&&s.callee!==n){let r=s.arguments.indexOf(n),i=t.esTreeNodeToTSNodeMap.get(s),a=r>=0&&i?e.getResolvedSignature(i)?.parameters[r]:void 0;return a===void 0?void 0:{type:e.getTypeOfSymbolAtLocation(a,i),at:n}}let c=s?.type===`Property`&&s.value===n?s.parent:void 0;if(c?.type!==`ObjectExpression`)return;let l=v(e,t,c,r,i+1);if(l===void 0||p(e,t,l))return l;let u=l.type,d=_(s);if(d===null){let r=s.key,i=r?t.esTreeNodeToTSNodeMap.get(r):void 0,o=i?e.getTypeAtLocation(i):void 0,c=o?.value??o?.types?.[0]?.value,l=typeof c==`string`?e.getPropertyOfType(u,c):void 0,d=l===void 0?e.getIndexInfoOfType(u,0)?.type:e.getTypeOfSymbolAtLocation(l,a);return d===void 0?void 0:{type:d,at:n}}let f=e.getPropertyOfType(u,d);return f===void 0?void 0:{type:e.getTypeOfSymbolAtLocation(f,a),at:n}},y=(e,n)=>{let r=t(n);if(!r)return;let i=r.program.getTypeChecker(),a=v(i,r,e,n);if(a!==void 0)return d(i,r,a.at)?!f(i,r,a.at):m(i,r,a)},b=(e,n)=>{let r=t(n);if(!r)return;let i=r.program.getTypeChecker(),a=v(i,r,e,n);return a===void 0||d(i,r,a.at)?!1:g(i,a.type)},x=(e,n)=>{let r=t(n);if(!r)return;let i=r.esTreeNodeToTSNodeMap.get(e);if(!i)return;let a=r.program.getTypeChecker(),o=a.getTypeAtLocation(i);if(h(o))return!0;if(!a.isArrayLikeType(o))return!1;let s=a.getTypeArguments(o)[0];return s!==void 0&&h(s)},S=e=>t(e)!==void 0;export{i as canCarryFailureByType,c as containerInsideByType,y as flowsIntoArraySlot,b as flowsIntoMutableArraySlot,S as hasTypeInformation,n as isExtractableByType,r as isIOByType,x as isUntypedExpression};
|
|
2
2
|
//# sourceMappingURL=type-aware.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-aware.js","names":["CONSUMED_COLLECTION_TYPES","typedServices","services","context","isExtractableByType","tsNode","node","checker","type","isIOByType","canCarryFailureByType","has","member","name","MEMBER_TO_CONTAINER","containerName","raw","isFromDependency","symbol","declaration","containerInsideByType","seen","isContainer","at","path","step","find","depth","isTypeParameter","shape","h","element","indexed","byIndex","property","enclosingCall","parent","index","isGenericParameterArgument","found","callTs","parameters","declared","annotated","handsArgumentBack","signature","argTs","argType","sameAsArgument","candidate","search","types","target","awaited","isOpaqueSink","isUntyped","slot","isArrayLikeOrUntyped","flags","isMutableArrayType","propertyKey","expectedSlot","own","declarator","ref","call","parameter","objectLiteral","outerSlot","outer","key","keyNode","keyTs","keyType","literal","named","flowsIntoArraySlot","flowsIntoMutableArraySlot","isUntypedExpression","hasTypeInformation"],"sources":["../../src/utils/type-aware.ts"],"sourcesContent":["import type { Rule } from \"eslint\"\n\nimport type { ASTNode } from \"../types/ast\"\n\n/**\n * Type-aware helpers that work only when the consumer turns on type-aware linting\n * (`parserOptions.projectService` or `project`). Without it they report \"unknown\", and a rule\n * falls back to its syntactic heuristic.\n *\n * The checker is reached through `parserServices` and typed structurally here, so the plugin\n * takes no runtime dependency on `typescript`.\n */\n\ntype TypeLike = object\n\ntype CheckerLike = {\n getTypeAtLocation(node: unknown): TypeLike\n getNonNullableType(type: TypeLike): TypeLike\n getPropertyOfType(type: TypeLike, name: string): unknown\n getContextualType(node: unknown): TypeLike | undefined\n isArrayLikeType(type: TypeLike): boolean\n getTypeOfSymbolAtLocation(symbol: unknown, node: unknown): TypeLike\n getTypeArguments(type: TypeLike): ReadonlyArray<TypeLike>\n getResolvedSignature(node: unknown): SignatureLike | undefined\n getIndexInfoOfType(type: TypeLike, kind: number): { readonly type: TypeLike } | undefined\n getReturnTypeOfSignature(signature: unknown): TypeLike\n getAwaitedType(type: TypeLike): TypeLike | undefined\n isTupleType(type: TypeLike): boolean\n isTypeAssignableTo(source: TypeLike, target: TypeLike): boolean\n getPropertiesOfType(type: TypeLike): ReadonlyArray<{ readonly name: string }>\n}\n\ntype SignatureLike = {\n readonly parameters: ReadonlyArray<unknown>\n getDeclaration(): { readonly parameters?: ReadonlyArray<unknown> } | undefined\n}\n\n/** `ts.TypeFlags.Any` / `Unknown`, inlined so the plugin needs no runtime `typescript` import. */\nconst ANY_OR_UNKNOWN_FLAGS = 1 | 2\n\n/** Interfaces a consumer reads through rather than keeps: `importKey(…, usages: Iterable<KeyUsage>)`, `new Set(values)`. */\nconst CONSUMED_COLLECTION_TYPES: ReadonlySet<string> = new Set([\n \"Iterable\",\n \"AsyncIterable\",\n \"IterableIterator\",\n \"ArrayLike\",\n])\n\ntype TypedServices = {\n readonly program: { getTypeChecker(): CheckerLike }\n readonly esTreeNodeToTSNodeMap: { get(node: unknown): unknown }\n}\n\nconst typedServices = (context: Rule.RuleContext): TypedServices | undefined => {\n const services = context.sourceCode.parserServices as Partial<TypedServices> | undefined\n return services?.program && services.esTreeNodeToTSNodeMap ? (services as TypedServices) : undefined\n}\n\n/**\n * Is `node`'s type a functype extractable container (Option, Either, Try, Lazy, …)? Structural:\n * the type, after stripping `null` / `undefined`, has both `orThrow` and `fold` — true of every\n * functype container, including union types like `Either` (each member has both). Native\n * collections (`Map#get`) and arbitrary objects don't.\n *\n * `undefined` when type information isn't available, so the caller can fall back.\n */\nexport const isExtractableByType = (node: ASTNode, context: Rule.RuleContext): boolean | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(node)\n if (!tsNode) return undefined\n const checker = services.program.getTypeChecker()\n const type = checker.getNonNullableType(checker.getTypeAtLocation(tsNode))\n return (\n checker.getPropertyOfType(type, \"orThrow\") !== undefined && checker.getPropertyOfType(type, \"fold\") !== undefined\n )\n}\n\n/**\n * Is `node`'s type a functype `IO`? Structural: the type has both `runExit` and `provideLayer`, which\n * only `IO` carries — `Task`, `Lazy` and the other containers have neither — and has carried since\n * well before 1.9, so older functype versions are recognized too. A union of IOs counts.\n * `any` and `unknown` have no properties, so they don't.\n *\n * `undefined` when type information isn't available.\n */\nexport const isIOByType = (node: ASTNode, context: Rule.RuleContext): boolean | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(node)\n if (!tsNode) return undefined\n const checker = services.program.getTypeChecker()\n const type = checker.getNonNullableType(checker.getTypeAtLocation(tsNode))\n return (\n checker.getPropertyOfType(type, \"runExit\") !== undefined &&\n checker.getPropertyOfType(type, \"provideLayer\") !== undefined\n )\n}\n\n/**\n * Can `node`'s value carry a failure that dropping it would lose? Structural: the type, or a member of\n * its union, has `fold` and `isLeft` or `isFailure`. That covers Either, Try, Exit, Validation and\n * Either-shaped wrappers such as a `ServiceResult`, and leaves out Option and List, whose `None` or\n * empty value is no error. An `IO` is left to no-floating-io: it hasn't run, so it holds no failure yet.\n *\n * `undefined` when type information isn't available.\n */\nexport const canCarryFailureByType = (node: ASTNode, context: Rule.RuleContext): boolean | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(node)\n if (!tsNode) return undefined\n const checker = services.program.getTypeChecker()\n const type = checker.getNonNullableType(checker.getTypeAtLocation(tsNode))\n const has = (member: TypeLike, name: string): boolean => checker.getPropertyOfType(member, name) !== undefined\n const carries = (member: TypeLike): boolean =>\n has(member, \"fold\") && (has(member, \"isLeft\") || has(member, \"isFailure\")) && !has(member, \"runExit\")\n const members = (type as { readonly types?: ReadonlyArray<TypeLike> }).types ?? [type]\n return members.some(carries)\n}\n\n/** Where a functype container sits inside a value, and what it is called. */\nexport type ContainerAt = { readonly path: string; readonly name: string }\n\ntype TypeShape = {\n readonly types?: ReadonlyArray<TypeLike>\n readonly aliasSymbol?: SymbolShape\n isUnionOrIntersection?: () => boolean\n getSymbol?: () => SymbolShape | undefined\n getCallSignatures?: () => ReadonlyArray<unknown>\n}\ntype SymbolShape = {\n readonly name: string\n getDeclarations?: () => ReadonlyArray<{ getSourceFile(): { readonly fileName: string } }> | undefined\n}\n\nconst SERIALIZE_DEPTH = 4\n\n/** A name to show for a container type: `Either`, `Option`, `List`, or the generic fallback. */\n/** Member names TypeScript shows once a union loses its alias (`Either<E, A> | null`), mapped back. */\nconst MEMBER_TO_CONTAINER: Readonly<Record<string, string>> = { LeftOf: \"Either\", RightOf: \"Either\" }\n\nconst containerName = (type: TypeShape): string => {\n // A bundled .d.ts renames a clashing declaration `Map$1`.\n const raw = (type.aliasSymbol?.name ?? type.getSymbol?.()?.name)?.replace(/\\$\\d+$/, \"\")\n if (raw === undefined || raw.startsWith(\"__\")) return \"functype container\"\n return MEMBER_TO_CONTAINER[raw] ?? raw\n}\n\n/** Declared in a dependency or the TypeScript lib: Stripe objects, Date, Request. Never descended into. */\nconst isFromDependency = (type: TypeShape): boolean => {\n // The type's own symbol, not its alias: `Partial<User>` and `Omit<Row, \"x\">` are anonymous mapped\n // types whose alias is declared in TypeScript's lib, and their properties are the caller's.\n const symbol = type.getSymbol?.()\n if (symbol === undefined || symbol.name.startsWith(\"__\")) return false\n return (symbol.getDeclarations?.() ?? []).some((declaration) =>\n declaration.getSourceFile().fileName.includes(\"/node_modules/\"),\n )\n}\n\n/**\n * The first functype container inside the value `node` evaluates to, and the path to it: `subscription`,\n * `items[]`, or empty for the whole value. A container is a type with `_tag` and `fold`, which every\n * functype container has and its `toJSON()` envelope doesn't. Walks unions, intersections, array and\n * tuple elements, object properties and string index signatures, up to 4 levels deep, and checks for a\n * container before skipping types declared in node_modules, where functype itself lives (#364).\n *\n * `undefined` when there is none, or when type information isn't available.\n */\nexport const containerInsideByType = (node: ASTNode, context: Rule.RuleContext): ContainerAt | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(node)\n if (!tsNode) return undefined\n const checker = services.program.getTypeChecker()\n const seen = new Set<TypeLike>()\n const isContainer = (type: TypeLike): boolean =>\n checker.getPropertyOfType(type, \"_tag\") !== undefined && checker.getPropertyOfType(type, \"fold\") !== undefined\n const at = (path: string, step: string): string =>\n path === \"\" ? step : step.startsWith(\"[\") ? path + step : `${path}.${step}`\n\n const find = (type: TypeLike, path: string, depth: number): ContainerAt | undefined => {\n if (depth > SERIALIZE_DEPTH || seen.has(type) || isTypeParameter(type)) return undefined\n seen.add(type)\n const shape = type as TypeShape\n // Before splitting: an Either union has `_tag` and `fold` on every member, and `Stack` is an\n // intersection whose `_tag` and `fold` come from different members.\n if (isContainer(type)) return { path, name: containerName(shape) }\n if (shape.isUnionOrIntersection?.() === true) {\n return (shape.types ?? []).map((member) => find(member, path, depth)).find((h) => h !== undefined)\n }\n if ((shape.getCallSignatures?.() ?? []).length > 0) return undefined\n if (checker.isArrayLikeType(type) || checker.isTupleType(type)) {\n return checker\n .getTypeArguments(type)\n .map((element) => find(element, path === \"\" ? \"[]\" : `${path}[]`, depth + 1))\n .find((h) => h !== undefined)\n }\n // Before the dependency skip: `Record<string, Option<T>>` is declared in TypeScript's lib.\n const indexed = checker.getIndexInfoOfType(type, 0)?.type\n const byIndex = indexed === undefined ? undefined : find(indexed, at(path, \"[key]\"), depth + 1)\n if (byIndex !== undefined) return byIndex\n if (shape.getSymbol?.() === undefined || isFromDependency(shape)) return undefined\n return checker\n .getPropertiesOfType(type)\n .map((property) => find(checker.getTypeOfSymbolAtLocation(property, tsNode), at(path, property.name), depth + 1))\n .find((h) => h !== undefined)\n }\n\n return find(checker.getTypeAtLocation(tsNode), \"\", 0)\n}\n\n/** A slot's expected type and the expression TypeScript computed it for. */\ntype Slot = { readonly type: TypeLike; readonly at: ASTNode }\n\n/**\n * Uses the `Type` object's own predicate rather than a `TypeFlags` bit: TypeScript renumbers its flags\n * between majors (TypeParameter is `1 << 19` in TS 6, `1 << 18` before), and the plugin has no runtime\n * `typescript` import to read them from.\n */\nconst isTypeParameter = (type: TypeLike): boolean =>\n (type as { isTypeParameter?: () => boolean }).isTypeParameter?.() === true\n\n/**\n * `f(…, arg, …)` where `at` is `arg` or sits inside it (an object property, an array element, a spread,\n * a conditional branch, an `as`): the call, the whole argument, and its index.\n */\nconst enclosingCall = (\n at: ASTNode,\n): { readonly call: ASTNode; readonly argument: ASTNode; readonly index: number } | null => {\n const parent = at.parent as ASTNode | undefined\n if (!parent) return null\n if ((parent.type === \"CallExpression\" || parent.type === \"NewExpression\") && parent.callee !== at) {\n const index = (parent.arguments as ReadonlyArray<ASTNode>).indexOf(at)\n return index < 0 ? null : { call: parent, argument: at, index }\n }\n const passesThrough =\n parent.type === \"TSAsExpression\" ||\n parent.type === \"TSSatisfiesExpression\" ||\n (parent.type === \"ConditionalExpression\" && parent.test !== at) ||\n parent.type === \"LogicalExpression\" ||\n parent.type === \"Property\" ||\n parent.type === \"ObjectExpression\" ||\n parent.type === \"ArrayExpression\" ||\n parent.type === \"SpreadElement\"\n return passesThrough ? enclosingCall(parent) : null\n}\n\n/**\n * Is the parameter that `at` is passed to (directly or nested) declared as a type parameter, or a union\n * containing one — `json<T>(data: T)`, `useState<S>(init: S | (() => S))`? Then TypeScript's expected type for `at` is only an echo of what it inferred from\n * `at` itself (`[1, 2]` → `number[]`), not a shape the library demands.\n */\nconst isGenericParameterArgument = (checker: CheckerLike, services: TypedServices, at: ASTNode): boolean => {\n const found = enclosingCall(at)\n const callTs = found ? services.esTreeNodeToTSNodeMap.get(found.call) : undefined\n const parameters = callTs ? checker.getResolvedSignature(callTs)?.getDeclaration()?.parameters : undefined\n if (!found || !parameters || parameters.length === 0) return false\n const declared = parameters[Math.min(found.index, parameters.length - 1)] as { readonly type?: unknown } | undefined\n // The parameter's type annotation node (`T` in `value: T`); asking for the declaration node's type gives `any`.\n if (declared?.type === undefined) return false\n const annotated = checker.getTypeAtLocation(declared.type)\n // React's `useState<S>(init: S | (() => S))`: a union that contains the type parameter is generic too.\n const members = (annotated as { types?: ReadonlyArray<TypeLike> }).types ?? [annotated]\n return members.some(isTypeParameter)\n}\n\n/**\n * Does the generic call around `at` hand the argument straight back to the caller — `useState(init)`\n * returning `[init, set]`, `identity(x)`, a `Promise` of it? Then the shape stays the caller's, and a\n * type parameter isn't a sink. Looks only at the return type itself, union / intersection members,\n * tuple and array elements, and an awaited Promise, not object properties: Hono's `c.json<T>` returns a\n * `Response` that carries a *parsed* copy of `T` for its RPC client, which the caller doesn't get back.\n */\nconst handsArgumentBack = (checker: CheckerLike, services: TypedServices, at: ASTNode): boolean => {\n const found = enclosingCall(at)\n const callTs = found ? services.esTreeNodeToTSNodeMap.get(found.call) : undefined\n const signature = callTs ? checker.getResolvedSignature(callTs) : undefined\n const argTs = found ? services.esTreeNodeToTSNodeMap.get(found.argument) : undefined\n if (!signature || !argTs) return false\n const argType = checker.getTypeAtLocation(argTs)\n const sameAsArgument = (candidate: TypeLike): boolean =>\n candidate === argType ||\n (checker.isTypeAssignableTo(argType, candidate) && checker.isTypeAssignableTo(candidate, argType))\n const search = (type: TypeLike, depth: number): boolean => {\n if (depth > 3) return false\n if (sameAsArgument(type)) return true\n const { types, target } = type as { types?: ReadonlyArray<TypeLike>; target?: unknown }\n if (types) return types.some((member) => search(member, depth + 1))\n if (target !== undefined && (checker.isTupleType(type) || checker.isArrayLikeType(type))) {\n return checker.getTypeArguments(type).some((element) => search(element, depth + 1))\n }\n const awaited = checker.getAwaitedType(type)\n return awaited !== undefined && awaited !== type && search(awaited, depth + 1)\n }\n return search(checker.getReturnTypeOfSignature(signature), 0)\n}\n\n/**\n * Untyped, or a type parameter of a call that doesn't hand the argument back: an object handed to\n * `c.json<T>(data: T)` or `JSON.stringify` goes to a sink. `useState<T>(init: T)` is not one.\n */\nconst isOpaqueSink = (checker: CheckerLike, services: TypedServices, slot: Slot): boolean =>\n isUntyped(slot.type) || (isTypeParameter(slot.type) && !handsArgumentBack(checker, services, slot.at))\n\nconst isArrayLikeOrUntyped = (checker: CheckerLike, services: TypedServices, slot: Slot): boolean => {\n if (isOpaqueSink(checker, services, slot)) return true\n const { types, symbol } = slot.type as { types?: ReadonlyArray<TypeLike>; symbol?: { name?: string } }\n if (types) return types.some((member) => isArrayLikeOrUntyped(checker, services, { type: member, at: slot.at }))\n if (symbol?.name !== undefined && CONSUMED_COLLECTION_TYPES.has(symbol.name)) return true\n return !isTypeParameter(slot.type) && checker.isArrayLikeType(slot.type)\n}\n\nconst isUntyped = (type: TypeLike): boolean => {\n const { flags } = type as { flags?: number }\n return flags !== undefined && (flags & ANY_OR_UNKNOWN_FLAGS) !== 0\n}\n\n/** The mutable `Array` type, as opposed to `ReadonlyArray`: the one a `ReadonlyArray` can't be passed to. */\nconst isMutableArrayType = (checker: CheckerLike, type: TypeLike): boolean => {\n const { types, symbol } = type as { types?: ReadonlyArray<TypeLike>; symbol?: { name?: string } }\n if (types) return types.some((member) => isMutableArrayType(checker, member))\n return symbol?.name === \"Array\" && checker.isArrayLikeType(type)\n}\n\n/** The name a property is written under: `params` in `{ params }`, `parts` in `{ parts: … }` or `{ \"parts\": … }`. */\nconst propertyKey = (property: ASTNode): string | null => {\n if (property.computed) return null\n if (property.key?.type === \"Identifier\") return property.key.name\n return property.key?.type === \"Literal\" && typeof property.key.value === \"string\" ? property.key.value : null\n}\n\n/**\n * The expected type of `node`, looking through object literals when TypeScript gives the value none of\n * its own. Two cases: a shorthand `{ params }` passed to a function, where the expected type is that\n * property's type on the parameter; and `[…]` in `JSON.stringify({ parts: [...] })`, where the object is\n * passed to an `any` parameter, so the whole object is going to an untyped host.\n */\nconst expectedSlot = (\n checker: CheckerLike,\n services: TypedServices,\n node: ASTNode,\n context: Rule.RuleContext,\n depth = 0,\n): Slot | undefined => {\n if (depth > 4) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(node)\n const own = tsNode ? checker.getContextualType(tsNode) : undefined\n if (own !== undefined) return { type: own, at: node }\n const parent = node.parent as ASTNode | undefined\n // `const metadata = (url) => ({ … })` with no declared return type: the object goes wherever the\n // calls' results go (`c.json(metadata(url))`), so take the expected type at the first call site.\n if (parent?.type === \"ArrowFunctionExpression\" && parent.body === node) {\n const declarator = parent.parent as ASTNode | undefined\n if (\n declarator?.type === \"VariableDeclarator\" &&\n declarator.init === parent &&\n declarator.id?.type === \"Identifier\"\n ) {\n const variable = context.sourceCode.getDeclaredVariables(declarator)[0]\n const calls = (variable?.references ?? [])\n .map((ref) => (ref.identifier as unknown as ASTNode).parent as ASTNode | undefined)\n .filter((call): call is ASTNode => call?.type === \"CallExpression\")\n return calls\n .map((call) => expectedSlot(checker, services, call, context, depth + 1))\n .find((slot) => slot !== undefined)\n }\n }\n // An argument to an overloaded function (`crypto.subtle.importKey(…, [\"decrypt\"])`) gets no contextual\n // type; the parameter of the overload TypeScript picked is the expected type.\n if ((parent?.type === \"CallExpression\" || parent?.type === \"NewExpression\") && parent.callee !== node) {\n const index = (parent.arguments as ReadonlyArray<ASTNode>).indexOf(node)\n const call = services.esTreeNodeToTSNodeMap.get(parent)\n const parameter = index >= 0 && call ? checker.getResolvedSignature(call)?.parameters[index] : undefined\n return parameter === undefined ? undefined : { type: checker.getTypeOfSymbolAtLocation(parameter, call), at: node }\n }\n const objectLiteral = parent?.type === \"Property\" && parent.value === node ? (parent.parent as ASTNode) : undefined\n if (objectLiteral?.type !== \"ObjectExpression\") return undefined\n const outerSlot = expectedSlot(checker, services, objectLiteral, context, depth + 1)\n if (outerSlot === undefined || isOpaqueSink(checker, services, outerSlot)) return outerSlot\n const outer = outerSlot.type\n const key = propertyKey(parent as ASTNode)\n // `{ [k]: [...] }` (a reduce accumulator keyed by category): the property named by the key's literal\n // type, else the string index signature's type.\n if (key === null) {\n const keyNode = (parent as ASTNode).key\n const keyTs = keyNode ? services.esTreeNodeToTSNodeMap.get(keyNode) : undefined\n const keyType = keyTs\n ? (checker.getTypeAtLocation(keyTs) as { value?: unknown; types?: ReadonlyArray<{ value?: unknown }> })\n : undefined\n const literal = keyType?.value ?? keyType?.types?.[0]?.value\n const named = typeof literal === \"string\" ? checker.getPropertyOfType(outer, literal) : undefined\n const type =\n named !== undefined\n ? checker.getTypeOfSymbolAtLocation(named, tsNode)\n : checker.getIndexInfoOfType(outer, 0)?.type\n return type === undefined ? undefined : { type, at: node }\n }\n const member = checker.getPropertyOfType(outer, key)\n return member === undefined ? undefined : { type: checker.getTypeOfSymbolAtLocation(member, tsNode), at: node }\n}\n\n/**\n * Does `node` (an expression) flow into a slot that is typed as an array, a tuple or `any`/`unknown`?\n * That's the expected type TypeScript checks it against: the parameter it is passed to, the property\n * it initialises, the declared return type. A literal in such a slot is handed to code that requires an\n * array, such as drizzle's `.values([...])` or an index definition, so `List` can't go there. A literal\n * inside an object passed to an `any` parameter (a `JSON.stringify` request body) counts too.\n *\n * `undefined` when type information isn't available, or when there is no expected type (a free-standing\n * literal), so the caller can fall back.\n */\nexport const flowsIntoArraySlot = (node: ASTNode, context: Rule.RuleContext): boolean | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const checker = services.program.getTypeChecker()\n const slot = expectedSlot(checker, services, node, context)\n if (slot === undefined) return undefined\n // A bare `T` parameter: a sink unless the call hands the argument straight back (`useState`, `identity`).\n if (isGenericParameterArgument(checker, services, slot.at)) return !handsArgumentBack(checker, services, slot.at)\n return isArrayLikeOrUntyped(checker, services, slot)\n}\n\n/**\n * Does `node` flow into a slot that requires a *mutable* array — a parameter typed `T[]`, such as pg's\n * `query(text, values: unknown[])`, drizzle's `inArray(col, values)` or ReactFlow's `nodes`? There a\n * `ReadonlyArray` won't type-check, so a mutable annotation is what the library demands.\n *\n * `undefined` when type information isn't available.\n */\nexport const flowsIntoMutableArraySlot = (node: ASTNode, context: Rule.RuleContext): boolean | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const checker = services.program.getTypeChecker()\n const slot = expectedSlot(checker, services, node, context)\n if (slot === undefined || isGenericParameterArgument(checker, services, slot.at)) return false\n return isMutableArrayType(checker, slot.type)\n}\n\n/**\n * Is `node`'s own type `any` / `unknown`, or an array of them — `JSON.parse(raw)`, `await res.json()`,\n * `raw` after `Array.isArray(raw)` (narrowed to `any[]`)? `undefined` when type information isn't available.\n */\nexport const isUntypedExpression = (node: ASTNode, context: Rule.RuleContext): boolean | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(node)\n if (!tsNode) return undefined\n const checker = services.program.getTypeChecker()\n const type = checker.getTypeAtLocation(tsNode)\n if (isUntyped(type)) return true\n if (!checker.isArrayLikeType(type)) return false\n const element = checker.getTypeArguments(type)[0]\n return element !== undefined && isUntyped(element)\n}\n\n/** Is type-aware linting on for this file (`parserOptions.projectService` or `project`)? */\nexport const hasTypeInformation = (context: Rule.RuleContext): boolean => typedServices(context) !== undefined\n"],"mappings":"AAsCA,MAGMA,kBAAiD,IAAI,IAAI,CAC7D,WACA,gBACA,mBACA,WACF,CAAC,EAOKC,EAAiB,GAAyD,CAC9E,IAAMC,EAAWC,EAAQ,WAAW,eACpC,OAAOD,GAAU,SAAWA,EAAS,sBAAyBA,EAA6B,IAAA,EAC7F,EAUaE,GAAuB,EAAe,IAAmD,CACpG,IAAMF,EAAWD,EAAcE,CAAO,EACtC,GAAI,CAACD,EAAU,OACf,IAAMG,EAASH,EAAS,sBAAsB,IAAII,CAAI,EACtD,GAAI,CAACD,EAAQ,OACb,IAAME,EAAUL,EAAS,QAAQ,eAAe,EAC1CM,EAAOD,EAAQ,mBAAmBA,EAAQ,kBAAkBF,CAAM,CAAC,EACzE,OACEE,EAAQ,kBAAkBC,EAAM,SAAS,IAAM,IAAA,IAAaD,EAAQ,kBAAkBC,EAAM,MAAM,IAAM,IAAA,EAE5G,EAUaC,GAAc,EAAe,IAAmD,CAC3F,IAAMP,EAAWD,EAAcE,CAAO,EACtC,GAAI,CAACD,EAAU,OACf,IAAMG,EAASH,EAAS,sBAAsB,IAAII,CAAI,EACtD,GAAI,CAACD,EAAQ,OACb,IAAME,EAAUL,EAAS,QAAQ,eAAe,EAC1CM,EAAOD,EAAQ,mBAAmBA,EAAQ,kBAAkBF,CAAM,CAAC,EACzE,OACEE,EAAQ,kBAAkBC,EAAM,SAAS,IAAM,IAAA,IAC/CD,EAAQ,kBAAkBC,EAAM,cAAc,IAAM,IAAA,EAExD,EAUaE,GAAyB,EAAe,IAAmD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,GAAI,CAACD,EAAU,OACf,IAAMG,EAASH,EAAS,sBAAsB,IAAII,CAAI,EACtD,GAAI,CAACD,EAAQ,OACb,IAAME,EAAUL,EAAS,QAAQ,eAAe,EAC1CM,EAAOD,EAAQ,kBAAkBF,CAAM,EAC7C,GAAIkD,EAAU/C,CAAI,EAAG,MAAO,GAC5B,GAAI,CAACD,EAAQ,gBAAgBC,CAAI,EAAG,MAAO,GAC3C,IAAMuB,EAAUxB,EAAQ,iBAAiBC,CAAI,CAAC,CAAC,GAC/C,OAAOuB,IAAY,IAAA,IAAawB,EAAUxB,CAAO,CACnD,EAGagD,EAAsB,GAAuC9E,EAAcE,CAAO,IAAM,IAAA"}
|
|
1
|
+
{"version":3,"file":"type-aware.js","names":["CONSUMED_COLLECTION_TYPES","typedServices","services","context","isExtractableByType","tsNode","node","checker","type","isIOByType","canCarryFailureByType","has","member","name","MEMBER_TO_CONTAINER","containerName","raw","isFromDependency","symbol","declaration","containerInsideByType","seen","isContainer","at","path","step","find","depth","isTypeParameter","shape","h","element","indexed","byIndex","property","enclosingCall","parent","index","isGenericParameterArgument","found","callTs","parameters","declared","annotated","handsArgumentBack","signature","argTs","argType","sameAsArgument","candidate","search","types","target","awaited","isOpaqueSink","isUntyped","slot","isArrayLikeOrUntyped","flags","isMutableArrayType","propertyKey","expectedSlot","own","declarator","ref","call","parameter","objectLiteral","outerSlot","outer","key","keyNode","keyTs","keyType","literal","named","flowsIntoArraySlot","flowsIntoMutableArraySlot","isUntypedExpression","hasTypeInformation"],"sources":["../../src/utils/type-aware.ts"],"sourcesContent":["import type { Rule } from \"eslint\"\n\nimport type { ASTNode } from \"../types/ast\"\n\n/**\n * Type-aware helpers that work only when the consumer turns on type-aware linting\n * (`parserOptions.projectService` or `project`). Without it they report \"unknown\", and a rule\n * falls back to its syntactic heuristic.\n *\n * The checker is reached through `parserServices` and typed structurally here, so the plugin\n * takes no runtime dependency on `typescript`.\n */\n\ntype TypeLike = object\n\ntype CheckerLike = {\n getTypeAtLocation(node: unknown): TypeLike\n getNonNullableType(type: TypeLike): TypeLike\n getPropertyOfType(type: TypeLike, name: string): unknown\n getContextualType(node: unknown): TypeLike | undefined\n isArrayLikeType(type: TypeLike): boolean\n getTypeOfSymbolAtLocation(symbol: unknown, node: unknown): TypeLike\n getTypeArguments(type: TypeLike): ReadonlyArray<TypeLike>\n getResolvedSignature(node: unknown): SignatureLike | undefined\n getIndexInfoOfType(type: TypeLike, kind: number): { readonly type: TypeLike } | undefined\n getReturnTypeOfSignature(signature: unknown): TypeLike\n getAwaitedType(type: TypeLike): TypeLike | undefined\n isTupleType(type: TypeLike): boolean\n isTypeAssignableTo(source: TypeLike, target: TypeLike): boolean\n getPropertiesOfType(type: TypeLike): ReadonlyArray<{ readonly name: string }>\n}\n\ntype SignatureLike = {\n readonly parameters: ReadonlyArray<unknown>\n getDeclaration(): { readonly parameters?: ReadonlyArray<unknown> } | undefined\n}\n\n/** `ts.TypeFlags.Any` / `Unknown`, inlined so the plugin needs no runtime `typescript` import. */\nconst ANY_OR_UNKNOWN_FLAGS = 1 | 2\n\n/** Interfaces a consumer reads through rather than keeps: `importKey(…, usages: Iterable<KeyUsage>)`, `new Set(values)`. */\nconst CONSUMED_COLLECTION_TYPES: ReadonlySet<string> = new Set([\n \"Iterable\",\n \"AsyncIterable\",\n \"IterableIterator\",\n \"ArrayLike\",\n])\n\ntype TypedServices = {\n readonly program: { getTypeChecker(): CheckerLike }\n readonly esTreeNodeToTSNodeMap: { get(node: unknown): unknown }\n}\n\nconst typedServices = (context: Rule.RuleContext): TypedServices | undefined => {\n const services = context.sourceCode.parserServices as Partial<TypedServices> | undefined\n return services?.program && services.esTreeNodeToTSNodeMap ? (services as TypedServices) : undefined\n}\n\n/**\n * Is `node`'s type a functype extractable container (Option, Either, Try, Lazy, …)? Structural:\n * the type, after stripping `null` / `undefined`, has both `orThrow` and `fold` — true of every\n * functype container, including union types like `Either` (each member has both). Native\n * collections (`Map#get`) and arbitrary objects don't.\n *\n * `undefined` when type information isn't available, so the caller can fall back.\n */\nexport const isExtractableByType = (node: ASTNode, context: Rule.RuleContext): boolean | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(node)\n if (!tsNode) return undefined\n const checker = services.program.getTypeChecker()\n const type = checker.getNonNullableType(checker.getTypeAtLocation(tsNode))\n return (\n checker.getPropertyOfType(type, \"orThrow\") !== undefined && checker.getPropertyOfType(type, \"fold\") !== undefined\n )\n}\n\n/**\n * Is `node`'s type a functype `IO`? Structural: the type has both `runExit` and `provideLayer`, which\n * only `IO` carries — `Lazy` and the other containers have neither — and has carried since\n * well before 1.9, so older functype versions are recognized too. A union of IOs counts.\n * `any` and `unknown` have no properties, so they don't.\n *\n * `undefined` when type information isn't available.\n */\nexport const isIOByType = (node: ASTNode, context: Rule.RuleContext): boolean | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(node)\n if (!tsNode) return undefined\n const checker = services.program.getTypeChecker()\n const type = checker.getNonNullableType(checker.getTypeAtLocation(tsNode))\n return (\n checker.getPropertyOfType(type, \"runExit\") !== undefined &&\n checker.getPropertyOfType(type, \"provideLayer\") !== undefined\n )\n}\n\n/**\n * Can `node`'s value carry a failure that dropping it would lose? Structural: the type, or a member of\n * its union, has `fold` and `isLeft` or `isFailure`. That covers Either, Try, Exit, Validation and\n * Either-shaped wrappers such as a `ServiceResult`, and leaves out Option and List, whose `None` or\n * empty value is no error. An `IO` is left to no-floating-io: it hasn't run, so it holds no failure yet.\n *\n * `undefined` when type information isn't available.\n */\nexport const canCarryFailureByType = (node: ASTNode, context: Rule.RuleContext): boolean | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(node)\n if (!tsNode) return undefined\n const checker = services.program.getTypeChecker()\n const type = checker.getNonNullableType(checker.getTypeAtLocation(tsNode))\n const has = (member: TypeLike, name: string): boolean => checker.getPropertyOfType(member, name) !== undefined\n const carries = (member: TypeLike): boolean =>\n has(member, \"fold\") && (has(member, \"isLeft\") || has(member, \"isFailure\")) && !has(member, \"runExit\")\n const members = (type as { readonly types?: ReadonlyArray<TypeLike> }).types ?? [type]\n return members.some(carries)\n}\n\n/** Where a functype container sits inside a value, and what it is called. */\nexport type ContainerAt = { readonly path: string; readonly name: string }\n\ntype TypeShape = {\n readonly types?: ReadonlyArray<TypeLike>\n readonly aliasSymbol?: SymbolShape\n isUnionOrIntersection?: () => boolean\n getSymbol?: () => SymbolShape | undefined\n getCallSignatures?: () => ReadonlyArray<unknown>\n}\ntype SymbolShape = {\n readonly name: string\n getDeclarations?: () => ReadonlyArray<{ getSourceFile(): { readonly fileName: string } }> | undefined\n}\n\nconst SERIALIZE_DEPTH = 4\n\n/** A name to show for a container type: `Either`, `Option`, `List`, or the generic fallback. */\n/** Member names TypeScript shows once a union loses its alias (`Either<E, A> | null`), mapped back. */\nconst MEMBER_TO_CONTAINER: Readonly<Record<string, string>> = {\n LeftOf: \"Either\",\n RightOf: \"Either\",\n SomeOf: \"Option\",\n NoneOf: \"Option\",\n SuccessOf: \"Try\",\n FailureOf: \"Try\",\n SuccessExitOf: \"Exit\",\n FailureExitOf: \"Exit\",\n DieExitOf: \"Exit\",\n InterruptedExitOf: \"Exit\",\n}\n\nconst containerName = (type: TypeShape): string => {\n // A bundled .d.ts renames a clashing declaration `Map$1`.\n const raw = (type.aliasSymbol?.name ?? type.getSymbol?.()?.name)?.replace(/\\$\\d+$/, \"\")\n if (raw === undefined || raw.startsWith(\"__\")) return \"functype container\"\n return MEMBER_TO_CONTAINER[raw] ?? raw\n}\n\n/** Declared in a dependency or the TypeScript lib: Stripe objects, Date, Request. Never descended into. */\nconst isFromDependency = (type: TypeShape): boolean => {\n // The type's own symbol, not its alias: `Partial<User>` and `Omit<Row, \"x\">` are anonymous mapped\n // types whose alias is declared in TypeScript's lib, and their properties are the caller's.\n const symbol = type.getSymbol?.()\n if (symbol === undefined || symbol.name.startsWith(\"__\")) return false\n return (symbol.getDeclarations?.() ?? []).some((declaration) =>\n declaration.getSourceFile().fileName.includes(\"/node_modules/\"),\n )\n}\n\n/**\n * The first functype container inside the value `node` evaluates to, and the path to it: `subscription`,\n * `items[]`, or empty for the whole value. A container is a type with `_tag` and `fold`, which every\n * functype container has and its `toJSON()` envelope doesn't. Walks unions, intersections, array and\n * tuple elements, object properties and string index signatures, up to 4 levels deep, and checks for a\n * container before skipping types declared in node_modules, where functype itself lives (#364).\n *\n * `undefined` when there is none, or when type information isn't available.\n */\nexport const containerInsideByType = (node: ASTNode, context: Rule.RuleContext): ContainerAt | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(node)\n if (!tsNode) return undefined\n const checker = services.program.getTypeChecker()\n const seen = new Set<TypeLike>()\n const isContainer = (type: TypeLike): boolean =>\n checker.getPropertyOfType(type, \"_tag\") !== undefined && checker.getPropertyOfType(type, \"fold\") !== undefined\n const at = (path: string, step: string): string =>\n path === \"\" ? step : step.startsWith(\"[\") ? path + step : `${path}.${step}`\n\n const find = (type: TypeLike, path: string, depth: number): ContainerAt | undefined => {\n if (depth > SERIALIZE_DEPTH || seen.has(type) || isTypeParameter(type)) return undefined\n seen.add(type)\n const shape = type as TypeShape\n // Before splitting: an Either union has `_tag` and `fold` on every member, and `Stack` is an\n // intersection whose `_tag` and `fold` come from different members.\n if (isContainer(type)) return { path, name: containerName(shape) }\n if (shape.isUnionOrIntersection?.() === true) {\n return (shape.types ?? []).map((member) => find(member, path, depth)).find((h) => h !== undefined)\n }\n if ((shape.getCallSignatures?.() ?? []).length > 0) return undefined\n if (checker.isArrayLikeType(type) || checker.isTupleType(type)) {\n return checker\n .getTypeArguments(type)\n .map((element) => find(element, path === \"\" ? \"[]\" : `${path}[]`, depth + 1))\n .find((h) => h !== undefined)\n }\n // Before the dependency skip: `Record<string, Option<T>>` is declared in TypeScript's lib.\n const indexed = checker.getIndexInfoOfType(type, 0)?.type\n const byIndex = indexed === undefined ? undefined : find(indexed, at(path, \"[key]\"), depth + 1)\n if (byIndex !== undefined) return byIndex\n if (shape.getSymbol?.() === undefined || isFromDependency(shape)) return undefined\n return checker\n .getPropertiesOfType(type)\n .map((property) => find(checker.getTypeOfSymbolAtLocation(property, tsNode), at(path, property.name), depth + 1))\n .find((h) => h !== undefined)\n }\n\n return find(checker.getTypeAtLocation(tsNode), \"\", 0)\n}\n\n/** A slot's expected type and the expression TypeScript computed it for. */\ntype Slot = { readonly type: TypeLike; readonly at: ASTNode }\n\n/**\n * Uses the `Type` object's own predicate rather than a `TypeFlags` bit: TypeScript renumbers its flags\n * between majors (TypeParameter is `1 << 19` in TS 6, `1 << 18` before), and the plugin has no runtime\n * `typescript` import to read them from.\n */\nconst isTypeParameter = (type: TypeLike): boolean =>\n (type as { isTypeParameter?: () => boolean }).isTypeParameter?.() === true\n\n/**\n * `f(…, arg, …)` where `at` is `arg` or sits inside it (an object property, an array element, a spread,\n * a conditional branch, an `as`): the call, the whole argument, and its index.\n */\nconst enclosingCall = (\n at: ASTNode,\n): { readonly call: ASTNode; readonly argument: ASTNode; readonly index: number } | null => {\n const parent = at.parent as ASTNode | undefined\n if (!parent) return null\n if ((parent.type === \"CallExpression\" || parent.type === \"NewExpression\") && parent.callee !== at) {\n const index = (parent.arguments as ReadonlyArray<ASTNode>).indexOf(at)\n return index < 0 ? null : { call: parent, argument: at, index }\n }\n const passesThrough =\n parent.type === \"TSAsExpression\" ||\n parent.type === \"TSSatisfiesExpression\" ||\n (parent.type === \"ConditionalExpression\" && parent.test !== at) ||\n parent.type === \"LogicalExpression\" ||\n parent.type === \"Property\" ||\n parent.type === \"ObjectExpression\" ||\n parent.type === \"ArrayExpression\" ||\n parent.type === \"SpreadElement\"\n return passesThrough ? enclosingCall(parent) : null\n}\n\n/**\n * Is the parameter that `at` is passed to (directly or nested) declared as a type parameter, or a union\n * containing one — `json<T>(data: T)`, `useState<S>(init: S | (() => S))`? Then TypeScript's expected type for `at` is only an echo of what it inferred from\n * `at` itself (`[1, 2]` → `number[]`), not a shape the library demands.\n */\nconst isGenericParameterArgument = (checker: CheckerLike, services: TypedServices, at: ASTNode): boolean => {\n const found = enclosingCall(at)\n const callTs = found ? services.esTreeNodeToTSNodeMap.get(found.call) : undefined\n const parameters = callTs ? checker.getResolvedSignature(callTs)?.getDeclaration()?.parameters : undefined\n if (!found || !parameters || parameters.length === 0) return false\n const declared = parameters[Math.min(found.index, parameters.length - 1)] as { readonly type?: unknown } | undefined\n // The parameter's type annotation node (`T` in `value: T`); asking for the declaration node's type gives `any`.\n if (declared?.type === undefined) return false\n const annotated = checker.getTypeAtLocation(declared.type)\n // React's `useState<S>(init: S | (() => S))`: a union that contains the type parameter is generic too.\n const members = (annotated as { types?: ReadonlyArray<TypeLike> }).types ?? [annotated]\n return members.some(isTypeParameter)\n}\n\n/**\n * Does the generic call around `at` hand the argument straight back to the caller — `useState(init)`\n * returning `[init, set]`, `identity(x)`, a `Promise` of it? Then the shape stays the caller's, and a\n * type parameter isn't a sink. Looks only at the return type itself, union / intersection members,\n * tuple and array elements, and an awaited Promise, not object properties: Hono's `c.json<T>` returns a\n * `Response` that carries a *parsed* copy of `T` for its RPC client, which the caller doesn't get back.\n */\nconst handsArgumentBack = (checker: CheckerLike, services: TypedServices, at: ASTNode): boolean => {\n const found = enclosingCall(at)\n const callTs = found ? services.esTreeNodeToTSNodeMap.get(found.call) : undefined\n const signature = callTs ? checker.getResolvedSignature(callTs) : undefined\n const argTs = found ? services.esTreeNodeToTSNodeMap.get(found.argument) : undefined\n if (!signature || !argTs) return false\n const argType = checker.getTypeAtLocation(argTs)\n const sameAsArgument = (candidate: TypeLike): boolean =>\n candidate === argType ||\n (checker.isTypeAssignableTo(argType, candidate) && checker.isTypeAssignableTo(candidate, argType))\n const search = (type: TypeLike, depth: number): boolean => {\n if (depth > 3) return false\n if (sameAsArgument(type)) return true\n const { types, target } = type as { types?: ReadonlyArray<TypeLike>; target?: unknown }\n if (types) return types.some((member) => search(member, depth + 1))\n if (target !== undefined && (checker.isTupleType(type) || checker.isArrayLikeType(type))) {\n return checker.getTypeArguments(type).some((element) => search(element, depth + 1))\n }\n const awaited = checker.getAwaitedType(type)\n return awaited !== undefined && awaited !== type && search(awaited, depth + 1)\n }\n return search(checker.getReturnTypeOfSignature(signature), 0)\n}\n\n/**\n * Untyped, or a type parameter of a call that doesn't hand the argument back: an object handed to\n * `c.json<T>(data: T)` or `JSON.stringify` goes to a sink. `useState<T>(init: T)` is not one.\n */\nconst isOpaqueSink = (checker: CheckerLike, services: TypedServices, slot: Slot): boolean =>\n isUntyped(slot.type) || (isTypeParameter(slot.type) && !handsArgumentBack(checker, services, slot.at))\n\nconst isArrayLikeOrUntyped = (checker: CheckerLike, services: TypedServices, slot: Slot): boolean => {\n if (isOpaqueSink(checker, services, slot)) return true\n const { types, symbol } = slot.type as { types?: ReadonlyArray<TypeLike>; symbol?: { name?: string } }\n if (types) return types.some((member) => isArrayLikeOrUntyped(checker, services, { type: member, at: slot.at }))\n if (symbol?.name !== undefined && CONSUMED_COLLECTION_TYPES.has(symbol.name)) return true\n return !isTypeParameter(slot.type) && checker.isArrayLikeType(slot.type)\n}\n\nconst isUntyped = (type: TypeLike): boolean => {\n const { flags } = type as { flags?: number }\n return flags !== undefined && (flags & ANY_OR_UNKNOWN_FLAGS) !== 0\n}\n\n/** The mutable `Array` type, as opposed to `ReadonlyArray`: the one a `ReadonlyArray` can't be passed to. */\nconst isMutableArrayType = (checker: CheckerLike, type: TypeLike): boolean => {\n const { types, symbol } = type as { types?: ReadonlyArray<TypeLike>; symbol?: { name?: string } }\n if (types) return types.some((member) => isMutableArrayType(checker, member))\n return symbol?.name === \"Array\" && checker.isArrayLikeType(type)\n}\n\n/** The name a property is written under: `params` in `{ params }`, `parts` in `{ parts: … }` or `{ \"parts\": … }`. */\nconst propertyKey = (property: ASTNode): string | null => {\n if (property.computed) return null\n if (property.key?.type === \"Identifier\") return property.key.name\n return property.key?.type === \"Literal\" && typeof property.key.value === \"string\" ? property.key.value : null\n}\n\n/**\n * The expected type of `node`, looking through object literals when TypeScript gives the value none of\n * its own. Two cases: a shorthand `{ params }` passed to a function, where the expected type is that\n * property's type on the parameter; and `[…]` in `JSON.stringify({ parts: [...] })`, where the object is\n * passed to an `any` parameter, so the whole object is going to an untyped host.\n */\nconst expectedSlot = (\n checker: CheckerLike,\n services: TypedServices,\n node: ASTNode,\n context: Rule.RuleContext,\n depth = 0,\n): Slot | undefined => {\n if (depth > 4) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(node)\n const own = tsNode ? checker.getContextualType(tsNode) : undefined\n if (own !== undefined) return { type: own, at: node }\n const parent = node.parent as ASTNode | undefined\n // `const metadata = (url) => ({ … })` with no declared return type: the object goes wherever the\n // calls' results go (`c.json(metadata(url))`), so take the expected type at the first call site.\n if (parent?.type === \"ArrowFunctionExpression\" && parent.body === node) {\n const declarator = parent.parent as ASTNode | undefined\n if (\n declarator?.type === \"VariableDeclarator\" &&\n declarator.init === parent &&\n declarator.id?.type === \"Identifier\"\n ) {\n const variable = context.sourceCode.getDeclaredVariables(declarator)[0]\n const calls = (variable?.references ?? [])\n .map((ref) => (ref.identifier as unknown as ASTNode).parent as ASTNode | undefined)\n .filter((call): call is ASTNode => call?.type === \"CallExpression\")\n return calls\n .map((call) => expectedSlot(checker, services, call, context, depth + 1))\n .find((slot) => slot !== undefined)\n }\n }\n // An argument to an overloaded function (`crypto.subtle.importKey(…, [\"decrypt\"])`) gets no contextual\n // type; the parameter of the overload TypeScript picked is the expected type.\n if ((parent?.type === \"CallExpression\" || parent?.type === \"NewExpression\") && parent.callee !== node) {\n const index = (parent.arguments as ReadonlyArray<ASTNode>).indexOf(node)\n const call = services.esTreeNodeToTSNodeMap.get(parent)\n const parameter = index >= 0 && call ? checker.getResolvedSignature(call)?.parameters[index] : undefined\n return parameter === undefined ? undefined : { type: checker.getTypeOfSymbolAtLocation(parameter, call), at: node }\n }\n const objectLiteral = parent?.type === \"Property\" && parent.value === node ? (parent.parent as ASTNode) : undefined\n if (objectLiteral?.type !== \"ObjectExpression\") return undefined\n const outerSlot = expectedSlot(checker, services, objectLiteral, context, depth + 1)\n if (outerSlot === undefined || isOpaqueSink(checker, services, outerSlot)) return outerSlot\n const outer = outerSlot.type\n const key = propertyKey(parent as ASTNode)\n // `{ [k]: [...] }` (a reduce accumulator keyed by category): the property named by the key's literal\n // type, else the string index signature's type.\n if (key === null) {\n const keyNode = (parent as ASTNode).key\n const keyTs = keyNode ? services.esTreeNodeToTSNodeMap.get(keyNode) : undefined\n const keyType = keyTs\n ? (checker.getTypeAtLocation(keyTs) as { value?: unknown; types?: ReadonlyArray<{ value?: unknown }> })\n : undefined\n const literal = keyType?.value ?? keyType?.types?.[0]?.value\n const named = typeof literal === \"string\" ? checker.getPropertyOfType(outer, literal) : undefined\n const type =\n named !== undefined\n ? checker.getTypeOfSymbolAtLocation(named, tsNode)\n : checker.getIndexInfoOfType(outer, 0)?.type\n return type === undefined ? undefined : { type, at: node }\n }\n const member = checker.getPropertyOfType(outer, key)\n return member === undefined ? undefined : { type: checker.getTypeOfSymbolAtLocation(member, tsNode), at: node }\n}\n\n/**\n * Does `node` (an expression) flow into a slot that is typed as an array, a tuple or `any`/`unknown`?\n * That's the expected type TypeScript checks it against: the parameter it is passed to, the property\n * it initialises, the declared return type. A literal in such a slot is handed to code that requires an\n * array, such as drizzle's `.values([...])` or an index definition, so `List` can't go there. A literal\n * inside an object passed to an `any` parameter (a `JSON.stringify` request body) counts too.\n *\n * `undefined` when type information isn't available, or when there is no expected type (a free-standing\n * literal), so the caller can fall back.\n */\nexport const flowsIntoArraySlot = (node: ASTNode, context: Rule.RuleContext): boolean | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const checker = services.program.getTypeChecker()\n const slot = expectedSlot(checker, services, node, context)\n if (slot === undefined) return undefined\n // A bare `T` parameter: a sink unless the call hands the argument straight back (`useState`, `identity`).\n if (isGenericParameterArgument(checker, services, slot.at)) return !handsArgumentBack(checker, services, slot.at)\n return isArrayLikeOrUntyped(checker, services, slot)\n}\n\n/**\n * Does `node` flow into a slot that requires a *mutable* array — a parameter typed `T[]`, such as pg's\n * `query(text, values: unknown[])`, drizzle's `inArray(col, values)` or ReactFlow's `nodes`? There a\n * `ReadonlyArray` won't type-check, so a mutable annotation is what the library demands.\n *\n * `undefined` when type information isn't available.\n */\nexport const flowsIntoMutableArraySlot = (node: ASTNode, context: Rule.RuleContext): boolean | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const checker = services.program.getTypeChecker()\n const slot = expectedSlot(checker, services, node, context)\n if (slot === undefined || isGenericParameterArgument(checker, services, slot.at)) return false\n return isMutableArrayType(checker, slot.type)\n}\n\n/**\n * Is `node`'s own type `any` / `unknown`, or an array of them — `JSON.parse(raw)`, `await res.json()`,\n * `raw` after `Array.isArray(raw)` (narrowed to `any[]`)? `undefined` when type information isn't available.\n */\nexport const isUntypedExpression = (node: ASTNode, context: Rule.RuleContext): boolean | undefined => {\n const services = typedServices(context)\n if (!services) return undefined\n const tsNode = services.esTreeNodeToTSNodeMap.get(node)\n if (!tsNode) return undefined\n const checker = services.program.getTypeChecker()\n const type = checker.getTypeAtLocation(tsNode)\n if (isUntyped(type)) return true\n if (!checker.isArrayLikeType(type)) return false\n const element = checker.getTypeArguments(type)[0]\n return element !== undefined && isUntyped(element)\n}\n\n/** Is type-aware linting on for this file (`parserOptions.projectService` or `project`)? */\nexport const hasTypeInformation = (context: Rule.RuleContext): boolean => typedServices(context) !== undefined\n"],"mappings":"AAsCA,MAGMA,kBAAiD,IAAI,IAAI,CAC7D,WACA,gBACA,mBACA,WACF,CAAC,EAOKC,EAAiB,GAAyD,CAC9E,IAAMC,EAAWC,EAAQ,WAAW,eACpC,OAAOD,GAAU,SAAWA,EAAS,sBAAyBA,EAA6B,IAAA,EAC7F,EAUaE,GAAuB,EAAe,IAAmD,CACpG,IAAMF,EAAWD,EAAcE,CAAO,EACtC,GAAI,CAACD,E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ASTNode } from "../types/ast.js";
|
|
2
|
-
//#region src/utils/wire-types.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* `Wire<T>` declares a value in its serialization-safe shape — a DB row, an HTTP body,
|
|
5
4
|
* a JSONB payload (#325 B). Everything inside its type argument is the wire shape by declaration: a
|
|
@@ -16,6 +15,4 @@ export declare const WIRE_TYPES_SCHEMA: {
|
|
|
16
15
|
readonly default: readonly string[];
|
|
17
16
|
};
|
|
18
17
|
/** Is `node` inside the type argument of a `Wire<…>` (or other configured wire type) reference? */
|
|
19
|
-
export declare const isInsideWireType: (node: ASTNode, wireTypes: ReadonlyArray<string>) => boolean;
|
|
20
|
-
//#endregion
|
|
21
|
-
//# sourceMappingURL=wire-types.d.ts.map
|
|
18
|
+
export declare const isInsideWireType: (node: ASTNode, wireTypes: ReadonlyArray<string>) => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire-types.js","names":["DEFAULT_WIRE_TYPES","WIRE_TYPES_SCHEMA","entityName","name","referenceName","typeRef","isInsideWireType","wireTypes","walk","parent","current","node"],"sources":["../../src/utils/wire-types.ts"],"sourcesContent":["import type { ASTNode } from \"../types/ast\"\n\n/**\n * `Wire<T>` declares a value in its serialization-safe shape — a DB row, an HTTP body,\n * a JSONB payload (#325 B). Everything inside its type argument is the wire shape by declaration: a\n * `ReadonlyArray` there is not a missed `List`, and a `T | null` there is not a missed `Option`. Rules\n * that prefer the functype shape skip it, so the boundary is stated once instead of suppressed at every\n * field. Names are configurable (`wireTypes`) for consumers with their own boundary alias.\n */\n\nexport const DEFAULT_WIRE_TYPES: ReadonlyArray<string> = [\"Wire\"]\n\nexport const WIRE_TYPES_SCHEMA = {\n type: \"array\",\n items: { type: \"string\" },\n default: [...DEFAULT_WIRE_TYPES],\n} as const\n\n/** The last segment of an entity name: `Wire` from `Wire` or `functype.Wire`. */\nconst entityName = (name: ASTNode): string | null => {\n if (name?.type === \"Identifier\") return name.name\n if (name?.type === \"TSQualifiedName\" && name.right?.type === \"Identifier\") return name.right.name\n return null\n}\n\n/** `Wire` from `Wire<…>`, `functype.Wire<…>` or `import(\"functype\").Wire<…>`; null otherwise. */\nconst referenceName = (typeRef: ASTNode): string | null => {\n if (typeRef.type === \"TSTypeReference\") return entityName(typeRef.typeName)\n if (typeRef.type === \"TSImportType\") return entityName(typeRef.qualifier)\n return null\n}\n\n/** Is `node` inside the type argument of a `Wire<…>` (or other configured wire type) reference? */\nexport const isInsideWireType = (node: ASTNode, wireTypes: ReadonlyArray<string>): boolean => {\n if (wireTypes.length === 0) return false\n const walk = (current: ASTNode | null | undefined): boolean => {\n const parent = current?.parent\n if (!parent) return false\n if (parent.type === \"TSTypeParameterInstantiation\" && parent.parent) {\n const name = referenceName(parent.parent)\n if (name !== null && wireTypes.includes(name)) return true\n }\n return walk(parent)\n }\n return walk(node)\n}\n"],"mappings":"AAUA,MAAaA,EAA4C,CAAC,MAAM,EAEnDC,EAAoB,CAC/B,KAAM,QACN,MAAO,CAAE,KAAM,QAAS,EACxB,QAAS,CAAC,GAAGD,CAAkB,CACjC,EAGME,EAAc,GACdC,GAAM,OAAS,aAAqBA,EAAK,KACzCA,GAAM,OAAS,mBAAqBA,EAAK,OAAO,OAAS,aAAqBA,EAAK,MAAM,KACtF,KAIHC,EAAiB,GACjBC,EAAQ,OAAS,kBAA0BH,EAAWG,EAAQ,QAAQ,EACtEA,EAAQ,OAAS,eAAuBH,EAAWG,EAAQ,SAAS,EACjE,KAIIC,GAAoB,EAAe,IAA8C,CAC5F,GAAIC,EAAU,SAAW,EAAG,MAAO,GACnC,IAAMC,EAAQ,GAAiD,CAC7D,IAAMC,EAASC,GAAS,OACxB,GAAI,CAACD,EAAQ,MAAO,GACpB,GAAIA,EAAO,OAAS,gCAAkCA,EAAO,OAAQ,CACnE,IAAMN,EAAOC,EAAcK,EAAO,MAAM,EACxC,GAAIN,IAAS,MAAQI,EAAU,SAASJ,CAAI,EAAG,MAAO,EACxD,CACA,OAAOK,EAAKC,CAAM,CACpB,EACA,OAAOD,EAAKG,CAAI,CAClB"}
|
|
1
|
+
{"version":3,"file":"wire-types.js","names":["DEFAULT_WIRE_TYPES","WIRE_TYPES_SCHEMA","entityName","name","referenceName","typeRef","isInsideWireType","wireTypes","walk","parent","current","node"],"sources":["../../src/utils/wire-types.ts"],"sourcesContent":["import type { ASTNode } from \"../types/ast\"\n\n/**\n * `Wire<T>` declares a value in its serialization-safe shape — a DB row, an HTTP body,\n * a JSONB payload (#325 B). Everything inside its type argument is the wire shape by declaration: a\n * `ReadonlyArray` there is not a missed `List`, and a `T | null` there is not a missed `Option`. Rules\n * that prefer the functype shape skip it, so the boundary is stated once instead of suppressed at every\n * field. Names are configurable (`wireTypes`) for consumers with their own boundary alias.\n */\n\nexport const DEFAULT_WIRE_TYPES: ReadonlyArray<string> = [\"Wire\"]\n\nexport const WIRE_TYPES_SCHEMA = {\n type: \"array\",\n items: { type: \"string\" },\n default: [...DEFAULT_WIRE_TYPES],\n} as const\n\n/** The last segment of an entity name: `Wire` from `Wire` or `functype.Wire`. */\nconst entityName = (name: ASTNode): string | null => {\n if (name?.type === \"Identifier\") return name.name\n if (name?.type === \"TSQualifiedName\" && name.right?.type === \"Identifier\") return name.right.name\n return null\n}\n\n/** `Wire` from `Wire<…>`, `functype.Wire<…>` or `import(\"functype\").Wire<…>`; null otherwise. */\nconst referenceName = (typeRef: ASTNode): string | null => {\n if (typeRef.type === \"TSTypeReference\") return entityName(typeRef.typeName)\n if (typeRef.type === \"TSImportType\") return entityName(typeRef.qualifier)\n return null\n}\n\n/** Is `node` inside the type argument of a `Wire<…>` (or other configured wire type) reference? */\nexport const isInsideWireType = (node: ASTNode, wireTypes: ReadonlyArray<string>): boolean => {\n if (wireTypes.length === 0) return false\n const walk = (current: ASTNode | null | undefined): boolean => {\n const parent = current?.parent\n if (!parent) return false\n if (parent.type === \"TSTypeParameterInstantiation\" && parent.parent) {\n const name = referenceName(parent.parent)\n if (name !== null && wireTypes.includes(name)) return true\n }\n return walk(parent)\n }\n return walk(node)\n}\n"],"mappings":"AAUA,MAAaA,EAA4C,CAAC,MAAM,EAEnDC,EAAoB,CAC/B,KAAM,QACN,MAAO,CAAE,KAAM,QAAS,EACxB,QAAS,CAAC,GAAGD,CAAkB,CACjC,EAGME,EAAc,GACdC,GAAM,OAAS,aAAqBA,EAAK,KACzCA,GAAM,OAAS,mBAAqBA,EAAK,OAAO,OAAS,aAAqBA,EAAK,MAAM,KACtF,KAIHC,EAAiB,GACjBC,EAAQ,OAAS,kBAA0BH,EAAWG,EAAQ,QAAQ,EACtEA,EAAQ,OAAS,eAAuBH,EAAWG,EAAQ,SAAS,EACjE,KAIIC,GAAoB,EAAe,IAA8C,CAC5F,GAAIC,EAAU,SAAW,EAAG,MAAO,GACnC,IAAMC,EAAQ,GAAiD,CAC7D,IAAMC,EAASC,GAAS,OACxB,GAAI,CAACD,EAAQ,MAAO,GACpB,GAAIA,EAAO,OAAS,gCAAkCA,EAAO,OAAQ,CACnE,IAAMN,EAAOC,EAAcK,EAAO,MAAM,EACxC,GAAIN,IAAS,MAAQI,EAAU,SAASJ,CAAI,EAAG,MAAO,EACxD,CACA,OAAOK,EAAKC,CAAM,CACpB,EACA,OAAOD,EAAKG,CAAI,CAClB,E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-functype",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.200.0",
|
|
4
4
|
"description": "Custom ESLint rules for functional TypeScript programming with functype library patterns including Do notation (ESLint 10+)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"eslint": "^10.2.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@types/node": "^24.19.
|
|
43
|
-
"@typescript-eslint/rule-tester": "^8.
|
|
42
|
+
"@types/node": "^24.19.2",
|
|
43
|
+
"@typescript-eslint/rule-tester": "^8.72.2",
|
|
44
44
|
"eslint-config-prettier": "^10.1.8",
|
|
45
|
-
"functype": "^
|
|
45
|
+
"functype": "^2.0.0",
|
|
46
46
|
"ts-builds": "^4.5.0",
|
|
47
|
-
"tsdown": "^0.23.
|
|
47
|
+
"tsdown": "^0.23.7"
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public",
|
package/dist/configs/agent.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
//#region src/configs/agent.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* The preset for code a coding agent writes. An agent acts on what fails its build and passes over a
|
|
4
|
-
* warning, so this preset has none: every rule is `error` or `off`.
|
|
5
|
-
*
|
|
6
|
-
* `error`: everything `strict` errors on, plus three rules `strict` still warns on while they are
|
|
7
|
-
* measured. no-floating-io has had 0 false positives across ~1,340 IO-typed calls, and the two React
|
|
8
|
-
* rules none across 1,403 files. A forgotten `.run()` or a throw in render is the kind of mistake an
|
|
9
|
-
* agent makes and a human reviewer misses. prefer-option, prefer-either and prefer-try are `error` here
|
|
10
|
-
* as in `strict`: at a real boundary an agent marks it (`@interop <reason>` or `invariant()` for a
|
|
11
|
-
* throw, `Wire<T>` for a data shape) instead of leaving the reader to guess.
|
|
12
|
-
*
|
|
13
|
-
* `off`: prefer-flatmap and prefer-do-notation, whose precision is unmeasured. At `error` they would
|
|
14
|
-
* teach an agent to write `eslint-disable`; each moves to `error` here once it is measured. Also
|
|
15
|
-
* prefer-list: with type-aware linting, its in-place-change case is no-array-mutation's, which is `error`
|
|
16
|
-
* here, and the rest asks for `ReadonlyArray<T>` types, a typing choice `strict` keeps at `warn`.
|
|
17
|
-
*
|
|
18
|
-
* no-array-mutation, no-floating-io, no-floating-result and no-serialize-container are type-aware:
|
|
19
|
-
* without `parserOptions.projectService` they report nothing.
|
|
20
|
-
*/
|
|
21
|
-
declare const agentRules: {
|
|
22
|
-
"functype/no-floating-io": string;
|
|
23
|
-
"functype/no-getOrThrow-in-render": string;
|
|
24
|
-
"functype/must-fold-on-component-return": string;
|
|
25
|
-
"functype/no-serialize-container": string;
|
|
26
|
-
"functype/prefer-flatmap": string;
|
|
27
|
-
"functype/prefer-do-notation": string;
|
|
28
|
-
"functype/prefer-list": string;
|
|
29
|
-
"functype/prefer-option": string;
|
|
30
|
-
"functype/prefer-either": string;
|
|
31
|
-
"functype/prefer-try": string;
|
|
32
|
-
"functype/no-get-unsafe": string;
|
|
33
|
-
"functype/no-array-mutation": string;
|
|
34
|
-
"functype/no-floating-result": string;
|
|
35
|
-
"functype/prefer-functype-map": string;
|
|
36
|
-
"functype/prefer-functype-set": string;
|
|
37
|
-
"functype/no-imperative-loops": string;
|
|
38
|
-
"functype/no-let": string;
|
|
39
|
-
"functype/prefer-map": string;
|
|
40
|
-
"functype/prefer-fold": string;
|
|
41
|
-
"functype/collection-naming": string;
|
|
42
|
-
};
|
|
43
|
-
//#endregion
|
|
44
|
-
export { agentRules as default };
|
|
45
|
-
//# sourceMappingURL=agent.d.ts.map
|
package/dist/configs/agent.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import e from"./strict.js";const t={...e,"functype/no-floating-io":`error`,"functype/no-getOrThrow-in-render":`error`,"functype/must-fold-on-component-return":`error`,"functype/no-serialize-container":`error`,"functype/prefer-flatmap":`off`,"functype/prefer-do-notation":`off`,"functype/prefer-list":`off`};export{t as default};
|
|
2
|
-
//# sourceMappingURL=agent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","names":["strictRules","agentRules"],"sources":["../../src/configs/agent.ts"],"sourcesContent":["import strictRules from \"./strict\"\n\n/**\n * The preset for code a coding agent writes. An agent acts on what fails its build and passes over a\n * warning, so this preset has none: every rule is `error` or `off`.\n *\n * `error`: everything `strict` errors on, plus three rules `strict` still warns on while they are\n * measured. no-floating-io has had 0 false positives across ~1,340 IO-typed calls, and the two React\n * rules none across 1,403 files. A forgotten `.run()` or a throw in render is the kind of mistake an\n * agent makes and a human reviewer misses. prefer-option, prefer-either and prefer-try are `error` here\n * as in `strict`: at a real boundary an agent marks it (`@interop <reason>` or `invariant()` for a\n * throw, `Wire<T>` for a data shape) instead of leaving the reader to guess.\n *\n * `off`: prefer-flatmap and prefer-do-notation, whose precision is unmeasured. At `error` they would\n * teach an agent to write `eslint-disable`; each moves to `error` here once it is measured. Also\n * prefer-list: with type-aware linting, its in-place-change case is no-array-mutation's, which is `error`\n * here, and the rest asks for `ReadonlyArray<T>` types, a typing choice `strict` keeps at `warn`.\n *\n * no-array-mutation, no-floating-io, no-floating-result and no-serialize-container are type-aware:\n * without `parserOptions.projectService` they report nothing.\n */\nconst agentRules = {\n ...strictRules,\n \"functype/no-floating-io\": \"error\",\n \"functype/no-getOrThrow-in-render\": \"error\",\n \"functype/must-fold-on-component-return\": \"error\",\n \"functype/no-serialize-container\": \"error\",\n \"functype/prefer-flatmap\": \"off\",\n \"functype/prefer-do-notation\": \"off\",\n \"functype/prefer-list\": \"off\",\n}\n\nexport default agentRules\n"],"mappings":"2BAqBA,MAAMC,EAAa,CACjB,GAAGD,EACH,0BAA2B,QAC3B,mCAAoC,QACpC,yCAA0C,QAC1C,kCAAmC,QACnC,0BAA2B,MAC3B,8BAA+B,MAC/B,uBAAwB,KAC1B"}
|
package/dist/configs/strict.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
//#region src/configs/strict.d.ts
|
|
2
|
-
declare const strictRules: {
|
|
3
|
-
"functype/prefer-option": string;
|
|
4
|
-
"functype/prefer-either": string;
|
|
5
|
-
"functype/prefer-try": string;
|
|
6
|
-
"functype/no-get-unsafe": string;
|
|
7
|
-
"functype/prefer-list": string;
|
|
8
|
-
"functype/no-array-mutation": string;
|
|
9
|
-
"functype/no-floating-io": string;
|
|
10
|
-
"functype/no-floating-result": string;
|
|
11
|
-
"functype/no-serialize-container": string;
|
|
12
|
-
"functype/no-getOrThrow-in-render": string;
|
|
13
|
-
"functype/must-fold-on-component-return": string;
|
|
14
|
-
"functype/prefer-functype-map": string;
|
|
15
|
-
"functype/prefer-functype-set": string;
|
|
16
|
-
"functype/no-imperative-loops": string;
|
|
17
|
-
"functype/no-let": string;
|
|
18
|
-
"functype/prefer-map": string;
|
|
19
|
-
"functype/prefer-fold": string;
|
|
20
|
-
"functype/collection-naming": string;
|
|
21
|
-
"functype/prefer-flatmap": string;
|
|
22
|
-
"functype/prefer-do-notation": string;
|
|
23
|
-
};
|
|
24
|
-
//#endregion
|
|
25
|
-
export { strictRules as default };
|
|
26
|
-
//# sourceMappingURL=strict.d.ts.map
|
package/dist/configs/strict.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import e from"./recommended.js";const t={...e,"functype/prefer-option":`error`,"functype/prefer-either":`error`,"functype/prefer-try":`error`,"functype/no-get-unsafe":`error`,"functype/prefer-list":`warn`,"functype/no-array-mutation":`error`,"functype/no-floating-io":`warn`,"functype/no-floating-result":`error`,"functype/no-serialize-container":`error`,"functype/no-getOrThrow-in-render":`warn`,"functype/must-fold-on-component-return":`warn`,"functype/prefer-functype-map":`error`,"functype/prefer-functype-set":`error`,"functype/no-imperative-loops":`error`};export{t as default};
|
|
2
|
-
//# sourceMappingURL=strict.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"strict.js","names":["recommendedRules","strictRules"],"sources":["../../src/configs/strict.ts"],"sourcesContent":["import recommendedRules from \"./recommended\"\n\nconst strictRules = {\n ...recommendedRules,\n \"functype/prefer-option\": \"error\",\n \"functype/prefer-either\": \"error\",\n \"functype/prefer-try\": \"error\",\n \"functype/no-get-unsafe\": \"error\",\n \"functype/prefer-list\": \"warn\",\n \"functype/no-array-mutation\": \"error\",\n \"functype/no-floating-io\": \"warn\",\n \"functype/no-floating-result\": \"error\",\n \"functype/no-serialize-container\": \"error\",\n \"functype/no-getOrThrow-in-render\": \"warn\",\n \"functype/must-fold-on-component-return\": \"warn\",\n \"functype/prefer-functype-map\": \"error\",\n \"functype/prefer-functype-set\": \"error\",\n \"functype/no-imperative-loops\": \"error\",\n}\n\nexport default strictRules\n"],"mappings":"gCAEA,MAAMC,EAAc,CAClB,GAAGD,EACH,yBAA0B,QAC1B,yBAA0B,QAC1B,sBAAuB,QACvB,yBAA0B,QAC1B,uBAAwB,OACxB,6BAA8B,QAC9B,0BAA2B,OAC3B,8BAA+B,QAC/B,kCAAmC,QACnC,mCAAoC,OACpC,yCAA0C,OAC1C,+BAAgC,QAChC,+BAAgC,QAChC,+BAAgC,OAClC"}
|