(path, options, print)
| 35 | } |
| 36 | |
| 37 | function printDecorators(path, options, print) { |
| 38 | const { node, parent } = path; |
| 39 | const { decorators } = node; |
| 40 | |
| 41 | if ( |
| 42 | !isNonEmptyArray(decorators) || |
| 43 | // If the parent node is an export declaration and the decorator |
| 44 | // was written before the export, the export will be responsible |
| 45 | // for printing the decorators. |
| 46 | hasDecoratorsBeforeExport(parent) || |
| 47 | // Decorators already printed in ignored node |
| 48 | isIgnored(path) |
| 49 | ) { |
| 50 | return ""; |
| 51 | } |
| 52 | |
| 53 | const shouldBreak = |
| 54 | node.type === "ClassExpression" || |
| 55 | node.type === "ClassDeclaration" || |
| 56 | hasNewlineBetweenOrAfterDecorators(node, options); |
| 57 | |
| 58 | return [ |
| 59 | path.key === "declaration" && isExportDeclaration(parent) |
| 60 | ? hardline |
| 61 | : shouldBreak |
| 62 | ? breakParent |
| 63 | : "", |
| 64 | join(line, path.map(print, "decorators")), |
| 65 | line, |
| 66 | ]; |
| 67 | } |
| 68 | |
| 69 | function hasNewlineBetweenOrAfterDecorators(node, options) { |
| 70 | return node.decorators.some((decorator) => |
no test coverage detected
searching dependent graphs…