MCPcopy Index your code
hub / github.com/reactjs/react-codemod / checkDeprecatedAPICalls

Function checkDeprecatedAPICalls

transforms/class.js:177–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175 // ---------------------------------------------------------------------------
176 // Checks if the module uses mixins or accesses deprecated APIs.
177 const checkDeprecatedAPICalls = classPath =>
178 DEPRECATED_APIS.reduce(
179 (acc, name) =>
180 acc + j(classPath)
181 .find(j.Identifier, {name})
182 .filter(path => {
183 // Do not consider history.replaceState() deprecated
184 let correctContext = true;
185
186 if (
187 name === 'replaceState' &&
188 path.parentPath &&
189 path.parentPath.value &&
190 path.parentPath.value.object &&
191 path.parentPath.value.object.name &&
192 path.parentPath.value.object.name === 'history'
193 ) {
194 correctContext = false;
195 }
196
197 return correctContext;
198 })
199 .size(),
200 0
201 ) > 0;
202
203 const hasNoCallsToDeprecatedAPIs = classPath => {
204 if (checkDeprecatedAPICalls(classPath)) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…