Actualizacion maquina principal
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / stylelint / lib / utils / isFirstNested.js
1 /* @flow */
2 "use strict";
3
4 module.exports = function(statement /*: postcss$node*/) /*: boolean*/ {
5   const parentNode = statement.parent;
6
7   if (parentNode === undefined || parentNode.type === "root") {
8     return false;
9   }
10
11   if (statement === parentNode.first) {
12     return true;
13   }
14
15   /*
16    * Search for the statement in the parent's nodes, ignoring comment
17    * nodes on the same line as the parent's opening brace.
18    */
19
20   const parentNodes = parentNode.nodes;
21   const firstNode = parentNodes[0];
22
23   if (firstNode.type !== "comment" || firstNode.raws.before.includes("\n")) {
24     return false;
25   }
26
27   const openingBraceLine = firstNode.source.start.line;
28
29   if (openingBraceLine !== firstNode.source.end.line) {
30     return false;
31   }
32
33   for (let i = 1; i < parentNodes.length; i++) {
34     const node = parentNodes[i];
35
36     if (node === statement) {
37       return true;
38     }
39
40     if (node.type !== "comment" || node.source.end.line !== openingBraceLine) {
41       return false;
42     }
43   }
44
45   /* istanbul ignore next: Should always return in the loop */
46   return false;
47 };