• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

reactjs / react-docgen / 15503494088

07 Jun 2025 02:52AM CUT coverage: 95.479% (-0.01%) from 95.49%
15503494088

Pull #999

github

web-flow
Merge c42d1b242 into ec11d1f1e
Pull Request #999: Packages ready to publish

1393 of 1494 branches covered (93.24%)

Branch coverage included in aggregate %.

4605 of 4788 relevant lines covered (96.18%)

522.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.1
/packages/react-docgen/src/utils/resolveFunctionDefinitionToReturnValue.ts
1
import type { NodePath } from '@babel/traverse';
2
import { visitors } from '@babel/traverse';
3✔
3
import type { Expression, Function as BabelFunction } from '@babel/types';
4
import resolveToValue from './resolveToValue.js';
3✔
5
import { ignore, shallowIgnoreVisitors } from './traverse.js';
3✔
6

7
interface TraverseState {
8
  returnPath?: NodePath<Expression>;
9
}
10

11
const explodedVisitors = visitors.explode<TraverseState>({
3✔
12
  ...shallowIgnoreVisitors,
3✔
13

14
  Function: { enter: ignore },
3✔
15
  ReturnStatement: {
3✔
16
    enter: function (nodePath, state) {
3✔
17
      const argument = nodePath.get('argument');
141✔
18

19
      if (argument.hasNode()) {
141✔
20
        state.returnPath = resolveToValue(argument) as NodePath<Expression>;
141✔
21

22
        return nodePath.stop();
141✔
23
      }
141!
24

25
      nodePath.skip();
×
26
    },
141✔
27
  },
3✔
28
});
3✔
29

30
export default function resolveFunctionDefinitionToReturnValue(
144✔
31
  path: NodePath<BabelFunction>,
144✔
32
): NodePath<Expression> | null {
144✔
33
  const body = path.get('body');
144✔
34
  const state: TraverseState = {};
144✔
35

36
  body.traverse(explodedVisitors, state);
144✔
37

38
  return state.returnPath || null;
144✔
39
}
144✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc