Repository: prettier/prettier
File: src/language-markdown/printer-markdown.js (JavaScript)

Code before:
  return !isInlineNode && !isInlineHTML;
}

function isLooseListItem(node, options) {
  return (
    node.type === "listItem" &&
    (node.spread ||
      // Check if `listItem` ends with `\n`
      // since it can't be empty, so we only need check the last character
      options.originalText.charAt(node.position.end.offset - 1) === "\n")
  );
}

function shouldPrePrintDoubleHardline({ node, previous, parent }, options) {
  const isPrevNodeLooseListItem = isLooseListItem(previous, options);

  if (isPrevNodeLooseListItem) {
    return true;
  }

  const isSequence = previous.type === node.type;
  const isSiblingNode = isSequence && SIBLING_NODE_TYPES.has(node.type);
  const isInTightListItem =
    parent.type === "listItem" &&
    (node.type === "list" ||
      (node.type !== "list" && !isLooseListItem(parent, options)));
  const isPrevNodePrettierIgnore = isPrettierIgnore(previous) === "next";
  const isBlockHtmlWithoutBlankLineBetweenPrevHtml =
    node.type === "html" &&
    previous.type === "html" &&
    previous.position.end.line + 1 === node.position.start.line;
  const isHtmlDirectAfterListItem =
    node.type === "html" &&
    parent.type === "listItem" &&
    previous.type === "paragraph" &&
    previous.position.end.line + 1 === node.position.start.line;

  return !(
    isSiblingNode ||
    isInTightListItem ||
    isPrevNodePrettierIgnore ||
    isBlockHtmlWithoutBlankLineBetweenPrevHtml ||
    isHtmlDirectAfterListItem
  );
}

function shouldPrePrintTripleHardline({ node, previous }) {
  const isPrevNodeList = previous.type === "list";
  const isIndentedCode = node.type === "code" && node.isIndented;

  return isPrevNodeList && isIndentedCode;

Review comment (refactor):
```typescript
    parent.type === "listItem" &&
      (node.type === "list" ||
        (node.type !== "list" && // is always true
           !isLooseListItem(parent, options)));
```

The condition can be simplified since the `node.type !== "list"` check is redundant - if the first part of the OR (`node.type === "list"`) is false, then `node.type !== "list"` will always be true. Due to short-circuit evaluation, we can remove this redundant check while maintaining the same logic.

```suggestion
    parent.type === "listItem" &&
      (node.type === "list" || !isLooseListItem(parent, options));
```

I hope this PR can be reviewed and merged soon! 🤞 

Code after:
}

function shouldPrePrintHardline({ node, parent }) {
  const isInlineNode = INLINE_NODE_TYPES.has(node.type);

  const isInlineHTML =
    node.type === "html" && INLINE_NODE_WRAPPER_TYPES.has(parent.type);

  return !isInlineNode && !isInlineHTML;
}

function isLooseListItem(node, options) {
  return (
    node.type === "listItem" &&
    (node.spread ||
      // Check if `listItem` ends with `\n`
      // since it can't be empty, so we only need check the last character
      options.originalText.charAt(node.position.end.offset - 1) === "\n")
  );
}

function shouldPrePrintDoubleHardline({ node, previous, parent }, options) {
  const isPrevNodeLooseListItem = isLooseListItem(previous, options);

  if (isPrevNodeLooseListItem) {
    return true;
  }

  const isSequence = previous.type === node.type;
  const isSiblingNode = isSequence && SIBLING_NODE_TYPES.has(node.type);
  const isInTightListItem =
    parent.type === "listItem" &&
    (node.type === "list" || !isLooseListItem(parent, options));
  const isPrevNodePrettierIgnore = isPrettierIgnore(previous) === "next";
  const isBlockHtmlWithoutBlankLineBetweenPrevHtml =
    node.type === "html" &&
    previous.type === "html" &&
    previous.position.end.line + 1 === node.position.start.line;
  const isHtmlDirectAfterListItem =
    node.type === "html" &&
    parent.type === "listItem" &&
    previous.type === "paragraph" &&
    previous.position.end.line + 1 === node.position.start.line;

  return !(
    isSiblingNode ||
    isInTightListItem ||
    isPrevNodePrettierIgnore ||
    isBlockHtmlWithoutBlankLineBetweenPrevHtml ||
    isHtmlDirectAfterListItem
  );