.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / stylelint / lib / utils / isSharedLineComment.js
diff --git a/.config/coc/extensions/node_modules/coc-prettier/node_modules/stylelint/lib/utils/isSharedLineComment.js b/.config/coc/extensions/node_modules/coc-prettier/node_modules/stylelint/lib/utils/isSharedLineComment.js
new file mode 100644 (file)
index 0000000..ae9e230
--- /dev/null
@@ -0,0 +1,41 @@
+/* @flow */
+"use strict";
+
+const _ = require("lodash");
+const getNextNonSharedLineCommentNode = require("./getNextNonSharedLineCommentNode");
+const getPreviousNonSharedLineCommentNode = require("./getPreviousNonSharedLineCommentNode");
+
+function nodesShareLines(a, b) {
+  return _.get(a, "source.end.line") === _.get(b, "source.start.line");
+}
+
+module.exports = function isSharedLineComment(
+  node /*: postcss$node*/
+) /*: boolean*/ {
+  if (node.type !== "comment") {
+    return false;
+  }
+
+  const previousNonSharedLineCommentNode = getPreviousNonSharedLineCommentNode(
+    node
+  );
+  if (nodesShareLines(previousNonSharedLineCommentNode, node)) {
+    return true;
+  }
+
+  const nextNonSharedLineCommentNode = getNextNonSharedLineCommentNode(node);
+  if (nodesShareLines(node, nextNonSharedLineCommentNode)) {
+    return true;
+  }
+
+  const parentNode = node.parent;
+  if (
+    parentNode !== undefined &&
+    parentNode.type !== "root" &&
+    parentNode.source.start.line === node.source.start.line
+  ) {
+    return true;
+  }
+
+  return false;
+};