MCPcopy Index your code
hub / github.com/TanStack/query / transformUsages

Function transformUsages

packages/query-codemods/src/v5/is-loading/is-loading.cjs:15–225  ·  view source on GitHub ↗
({ jscodeshift, utils, root, filePath, config })

Source from the content-addressed store, hash-verified

13 * @param {{keyName: "mutationKey"|"queryKey", queryClientMethods: ReadonlyArray<string>, hooks: ReadonlyArray<string>}} config
14 */
15const transformUsages = ({ jscodeshift, utils, root, filePath, config }) => {
16 /**
17 * @param {import('jscodeshift').CallExpression | import('jscodeshift').ExpressionStatement} node
18 * @returns {{start: number, end: number}}
19 */
20 const getNodeLocation = (node) => {
21 const location = utils.isCallExpression(node) ? node.callee.loc : node.loc
22 const start = location.start.line
23 const end = location.end.line
24
25 return { start, end }
26 }
27
28 /**
29 * @param {import('jscodeshift').ASTNode} node
30 * @returns {boolean}
31 */
32 const isObjectExpression = (node) => {
33 return jscodeshift.match(node, {
34 type: jscodeshift.ObjectExpression.name,
35 })
36 }
37
38 /**
39 * @param {import('jscodeshift').ASTNode} node
40 * @returns {boolean}
41 */
42 const isObjectPattern = (node) => {
43 return jscodeshift.match(node, {
44 type: jscodeshift.ObjectPattern.name,
45 })
46 }
47
48 /**
49 * @param {import('jscodeshift').ASTNode} node
50 * @returns {boolean}
51 */
52 const isVariableDeclarator = (node) => {
53 return jscodeshift.match(node, {
54 type: jscodeshift.VariableDeclarator.name,
55 })
56 }
57
58 /**
59 * @param {import('jscodeshift').Node} node
60 * @param {import('jscodeshift').Identifier} identifier
61 * @returns {Collection<import('jscodeshift').MemberExpression>}
62 */
63 const findIsLoadingPropertiesOfIdentifier = (node, identifier) => {
64 return jscodeshift(node).find(jscodeshift.MemberExpression, {
65 object: {
66 type: jscodeshift.Identifier.name,
67 name: identifier.name,
68 },
69 property: {
70 type: jscodeshift.Identifier.name,
71 name: originalName,
72 },

Callers 1

is-loading.cjsFile · 0.70

Calls 1

executeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…