All files / babel-plugin/default-props-macro index.js

84.61% Statements 11/13
50% Branches 2/4
100% Functions 1/1
84.61% Lines 11/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 241x 1x 1x   1x   1x 2x       2x   2x       2x   2x     1x  
const babel = require("@babel/core");
const { DEFAULT_PROPS_MACRO } = require("../constants");
const defineMacro = require("../define-macro");
 
const t = babel.types;
 
const defaultPropsMacro = defineMacro(DEFAULT_PROPS_MACRO, (path) => {
  Iif (!path.parentPath.isCallExpression()) {
    return false;
  }
 
  const arg = path.parentPath.node.arguments[0];
 
  Iif (!t.isNode(arg)) {
    return false;
  }
 
  path.parentPath.replaceWith(arg);
 
  return true;
});
 
module.exports = defaultPropsMacro;