.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / stylelint / lib / utils / getNextNonSharedLineCommentNode.js
1 /* @flow */
2 "use strict";
3
4 const _ = require("lodash");
5
6 function getNodeLine(node /*:: ?: postcss$node*/) /*: number | void*/ {
7   return _.get(node, "source.start.line");
8 }
9
10 module.exports = function getNextNonSharedLineCommentNode(
11   node /*:: ?: postcss$node*/
12 ) /*: postcss$node | void*/ {
13   if (node === undefined) {
14     return undefined;
15   }
16
17   const nextNode = node.next();
18
19   if (_.get(nextNode, "type") !== "comment") {
20     return nextNode;
21   }
22
23   if (
24     getNodeLine(node) === getNodeLine(nextNode) ||
25     (nextNode !== undefined &&
26       getNodeLine(nextNode) === getNodeLine(nextNode.next()))
27   ) {
28     return getNextNonSharedLineCommentNode(nextNode);
29   }
30
31   return nextNode;
32 };