@yahoo/uds 0.4.5 → 0.4.6
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/cli/codemods/remapProps.ts +65 -0
- package/cli/commands/codemod/spacingProps.ts +52 -0
- package/dist/experimental/index.cjs +1 -1
- package/dist/experimental/index.js +1 -1
- package/dist/experimental/index.native.cjs +1 -1
- package/dist/experimental/index.native.js +1 -1
- package/dist/index.native.cjs +1 -1
- package/dist/index.native.js +1 -1
- package/dist/tailwind/purger.cjs +1 -1
- package/dist/tailwind/purger.js +1 -1
- package/dist/tailwind/tsMorph.cjs +1 -1
- package/dist/tailwind/tsMorph.d.cts +7 -1
- package/dist/tailwind/tsMorph.d.ts +7 -1
- package/dist/tailwind/tsMorph.js +1 -1
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
"use strict";var
|
1
|
+
"use strict";var f=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var J=(t,e)=>{for(var i in e)f(t,i,{get:e[i],enumerable:!0})},C=(t,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of D(e))!F.call(t,r)&&r!==i&&f(t,r,{get:()=>e[r],enumerable:!(s=E(e,r))||s.enumerable});return t};var A=t=>C(f({},"__esModule",{value:!0}),t);var h={};J(h,{findReferencesAsJsxElements:()=>S,getJsxElement:()=>O,getJsxElements:()=>d,getParentSpreadOrParamIdentifier:()=>m,getReactFunctionDeclaration:()=>p,getUsedPropsInReference:()=>b,isForwardRefExpression:()=>u,isJsxComponent:()=>x});module.exports=A(h);var n=require("ts-morph");function u(t){if(n.Node.isCallExpression(t)){let e=t.getExpression();if(n.Node.isIdentifier(e)&&e.getText()==="forwardRef"||n.Node.isPropertyAccessExpression(e)&&e.getText()==="React.forwardRef")return!0}return!1}function x(t){let e;return n.Node.isVariableDeclaration(t)||n.Node.isFunctionDeclaration(t)||n.Node.isClassDeclaration(t)?e=t.getName():(n.Node.isFunctionExpression(t)||n.Node.isArrowFunction(t))&&(e=t.getFirstAncestorByKind(n.SyntaxKind.VariableDeclaration)?.getName()),e?/[A-Z]/.test(e.charAt(0)):!1}function p(t){if(x(t)){if(n.Node.isFunctionDeclaration(t))return t;if(n.Node.isVariableDeclaration(t)){let e=t.getInitializer();if(e){if(u(e)){let[i]=e.getArguments();if(n.Node.isFunctionDeclaration(i)||n.Node.isFunctionExpression(i)||n.Node.isArrowFunction(i))return i}else if(n.Node.isFunctionDeclaration(e)||n.Node.isFunctionExpression(e)||n.Node.isArrowFunction(e))return e}}}return null}function O(t,e){return d(t).find(i=>i.getFirstDescendantByKindOrThrow(n.SyntaxKind.Identifier).getText()===e)}function d(t){return t.getDescendants().filter(e=>n.Node.isJsxElement(e)||n.Node.isJsxSelfClosingElement(e))}function S(t){let e=[];for(let i of t.findReferencesAsNodes()){let s=i.getFirstAncestor(r=>n.Node.isJsxOpeningElement(r)||n.Node.isJsxSelfClosingElement(r));s&&e.push(s)}return e}var m=t=>{let i=t.getParentWhile(r=>!p(r)).getParent();if(!i)return;let s=p(i);if(s){let r=s.getParameters();for(let o=0;o<r.length;o++){let a=r[o],c=a.getChildrenOfKind(n.SyntaxKind.ObjectBindingPattern)[0],l=a.getChildrenOfKind(n.SyntaxKind.Identifier)[0];if(c){let g=c.getFirstDescendantByKind(n.SyntaxKind.DotDotDotToken);if(g!==void 0)return g?.getParent()?.getFirstChildByKindOrThrow(n.SyntaxKind.Identifier).getText()}else if(l)return l.getText()}}},b=t=>t.getAttributes().map(s=>{if(n.Node.isJsxAttribute(s))return[s.getNameNode().getText()];if(n.Node.isJsxSpreadAttribute(s)){let r=m(t),o=s.getExpression().getChildren(),a=o.length===0?s.getExpression():o.pop();return!a||a?.getText()===r?[]:a.getType().getProperties().map(l=>l.getName()).flat()}return[]}).flat();0&&(module.exports={findReferencesAsJsxElements,getJsxElement,getJsxElements,getParentSpreadOrParamIdentifier,getReactFunctionDeclaration,getUsedPropsInReference,isForwardRefExpression,isJsxComponent});
|
@@ -17,9 +17,15 @@ declare function getJsxElements(node: Node): (JsxElement | JsxSelfClosingElement
|
|
17
17
|
* Note, this currently does not account for cases where the component is used as a prop or is renamed.
|
18
18
|
*/
|
19
19
|
declare function findReferencesAsJsxElements(identifer: Identifier): (JsxOpeningElement | JsxSelfClosingElement)[];
|
20
|
+
/**
|
21
|
+
* Given a Jsx Reference, this function finds the parent of that reference,
|
22
|
+
* looks at the props, and returns the name used either for spread operator rest or
|
23
|
+
* the prop name if there's no spread operator
|
24
|
+
*/
|
25
|
+
declare const getParentSpreadOrParamIdentifier: (reference: JsxOpeningElement | JsxSelfClosingElement) => string | undefined;
|
20
26
|
/**
|
21
27
|
* Get used props on a reference.
|
22
28
|
*/
|
23
29
|
declare const getUsedPropsInReference: (reference: JsxOpeningElement | JsxSelfClosingElement) => string[];
|
24
30
|
|
25
|
-
export { findReferencesAsJsxElements, getJsxElement, getJsxElements, getReactFunctionDeclaration, getUsedPropsInReference, isForwardRefExpression, isJsxComponent };
|
31
|
+
export { findReferencesAsJsxElements, getJsxElement, getJsxElements, getParentSpreadOrParamIdentifier, getReactFunctionDeclaration, getUsedPropsInReference, isForwardRefExpression, isJsxComponent };
|
@@ -17,9 +17,15 @@ declare function getJsxElements(node: Node): (JsxElement | JsxSelfClosingElement
|
|
17
17
|
* Note, this currently does not account for cases where the component is used as a prop or is renamed.
|
18
18
|
*/
|
19
19
|
declare function findReferencesAsJsxElements(identifer: Identifier): (JsxOpeningElement | JsxSelfClosingElement)[];
|
20
|
+
/**
|
21
|
+
* Given a Jsx Reference, this function finds the parent of that reference,
|
22
|
+
* looks at the props, and returns the name used either for spread operator rest or
|
23
|
+
* the prop name if there's no spread operator
|
24
|
+
*/
|
25
|
+
declare const getParentSpreadOrParamIdentifier: (reference: JsxOpeningElement | JsxSelfClosingElement) => string | undefined;
|
20
26
|
/**
|
21
27
|
* Get used props on a reference.
|
22
28
|
*/
|
23
29
|
declare const getUsedPropsInReference: (reference: JsxOpeningElement | JsxSelfClosingElement) => string[];
|
24
30
|
|
25
|
-
export { findReferencesAsJsxElements, getJsxElement, getJsxElements, getReactFunctionDeclaration, getUsedPropsInReference, isForwardRefExpression, isJsxComponent };
|
31
|
+
export { findReferencesAsJsxElements, getJsxElement, getJsxElements, getParentSpreadOrParamIdentifier, getReactFunctionDeclaration, getUsedPropsInReference, isForwardRefExpression, isJsxComponent };
|
package/dist/tailwind/tsMorph.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import{Node as
|
1
|
+
import{Node as n,SyntaxKind as l}from"ts-morph";function u(e){if(n.isCallExpression(e)){let t=e.getExpression();if(n.isIdentifier(t)&&t.getText()==="forwardRef"||n.isPropertyAccessExpression(t)&&t.getText()==="React.forwardRef")return!0}return!1}function x(e){let t;return n.isVariableDeclaration(e)||n.isFunctionDeclaration(e)||n.isClassDeclaration(e)?t=e.getName():(n.isFunctionExpression(e)||n.isArrowFunction(e))&&(t=e.getFirstAncestorByKind(l.VariableDeclaration)?.getName()),t?/[A-Z]/.test(t.charAt(0)):!1}function g(e){if(x(e)){if(n.isFunctionDeclaration(e))return e;if(n.isVariableDeclaration(e)){let t=e.getInitializer();if(t){if(u(t)){let[i]=t.getArguments();if(n.isFunctionDeclaration(i)||n.isFunctionExpression(i)||n.isArrowFunction(i))return i}else if(n.isFunctionDeclaration(t)||n.isFunctionExpression(t)||n.isArrowFunction(t))return t}}}return null}function J(e,t){return d(e).find(i=>i.getFirstDescendantByKindOrThrow(l.Identifier).getText()===t)}function d(e){return e.getDescendants().filter(t=>n.isJsxElement(t)||n.isJsxSelfClosingElement(t))}function C(e){let t=[];for(let i of e.findReferencesAsNodes()){let r=i.getFirstAncestor(s=>n.isJsxOpeningElement(s)||n.isJsxSelfClosingElement(s));r&&t.push(r)}return t}var m=e=>{let i=e.getParentWhile(s=>!g(s)).getParent();if(!i)return;let r=g(i);if(r){let s=r.getParameters();for(let o=0;o<s.length;o++){let a=s[o],f=a.getChildrenOfKind(l.ObjectBindingPattern)[0],c=a.getChildrenOfKind(l.Identifier)[0];if(f){let p=f.getFirstDescendantByKind(l.DotDotDotToken);if(p!==void 0)return p?.getParent()?.getFirstChildByKindOrThrow(l.Identifier).getText()}else if(c)return c.getText()}}},A=e=>e.getAttributes().map(r=>{if(n.isJsxAttribute(r))return[r.getNameNode().getText()];if(n.isJsxSpreadAttribute(r)){let s=m(e),o=r.getExpression().getChildren(),a=o.length===0?r.getExpression():o.pop();return!a||a?.getText()===s?[]:a.getType().getProperties().map(c=>c.getName()).flat()}return[]}).flat();export{C as findReferencesAsJsxElements,J as getJsxElement,d as getJsxElements,m as getParentSpreadOrParamIdentifier,g as getReactFunctionDeclaration,A as getUsedPropsInReference,u as isForwardRefExpression,x as isJsxComponent};
|