MCPcopy Index your code
hub / github.com/react/react / ExpressionStatement

Function ExpressionStatement

scripts/babel/transform-react-version-pragma.js:55–108  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

53 name: 'transform-react-version-pragma',
54 visitor: {
55 ExpressionStatement(path) {
56 const statement = path.node;
57 const expression = statement.expression;
58 if (expression.type === 'CallExpression') {
59 const callee = expression.callee;
60 switch (callee.type) {
61 case 'Identifier': {
62 if (
63 callee.name === 'test' ||
64 callee.name === 'it' ||
65 callee.name === 'fit'
66 ) {
67 const comments = getComments(path);
68 const condition = buildGateVersionCondition(comments);
69 if (condition !== null) {
70 callee.name =
71 callee.name === 'fit'
72 ? '_test_react_version_focus'
73 : '_test_react_version';
74 expression.arguments = [condition, ...expression.arguments];
75 } else if (REACT_VERSION_ENV) {
76 callee.name = '_test_ignore_for_react_version';
77 }
78 }
79 break;
80 }
81 case 'MemberExpression': {
82 if (
83 callee.object.type === 'Identifier' &&
84 (callee.object.name === 'test' ||
85 callee.object.name === 'it') &&
86 callee.property.type === 'Identifier' &&
87 callee.property.name === 'only'
88 ) {
89 const comments = getComments(path);
90 const condition = buildGateVersionCondition(comments);
91 if (condition !== null) {
92 statement.expression = t.callExpression(
93 t.identifier('_test_react_version_focus'),
94 [condition, ...expression.arguments]
95 );
96 } else if (REACT_VERSION_ENV) {
97 statement.expression = t.callExpression(
98 t.identifier('_test_ignore_for_react_version'),
99 expression.arguments
100 );
101 }
102 }
103 break;
104 }
105 }
106 }
107 return;
108 },
109 },
110 };
111}

Callers

nothing calls this directly

Calls 2

getCommentsFunction · 0.85

Tested by

no test coverage detected