All files / src/nodes ExpressionStatement.js

100% Statements 15/15
100% Branches 13/13
100% Functions 1/1
100% Lines 15/15

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 24 25 26 27 28 29 30 31 32 33        55x   55x   55x   2903x   2903x   2903x 50x 10x 10x 5x 5x         2903x 2903x   2903x       55x  
const {
  doc: {
    builders: { hardline }
  }
} = require('prettier');
 
const printComments = require('./print-comments');
 
const ExpressionStatement = {
  print: ({ node, options, path, print }) => {
    const parts = [];
 
    const parent = path.getParentNode();
 
    if (parent.type === 'IfStatement') {
      if (node.comments && node.comments.length) {
        const comments = printComments(node, path, options);
        if (comments && comments.parts && comments.parts.length) {
          parts.push(comments);
          parts.push(hardline);
        }
      }
    }
 
    parts.push(path.call(print, 'expression'));
    parts.push(node.omitSemicolon ? '' : ';');
 
    return parts;
  }
};
 
module.exports = ExpressionStatement;