Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/fourtyone11/origin-hugo-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'assets/node_modules/stylelint/lib/utils/isSharedLineComment.js')
-rw-r--r--assets/node_modules/stylelint/lib/utils/isSharedLineComment.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/assets/node_modules/stylelint/lib/utils/isSharedLineComment.js b/assets/node_modules/stylelint/lib/utils/isSharedLineComment.js
new file mode 100644
index 0000000..1cfda15
--- /dev/null
+++ b/assets/node_modules/stylelint/lib/utils/isSharedLineComment.js
@@ -0,0 +1,53 @@
+'use strict';
+
+const _ = require('lodash');
+const getNextNonSharedLineCommentNode = require('./getNextNonSharedLineCommentNode');
+const getPreviousNonSharedLineCommentNode = require('./getPreviousNonSharedLineCommentNode');
+
+/** @typedef {import('postcss').Node} PostcssNode */
+
+/**
+ *
+ * @param {PostcssNode | void} a
+ * @param {PostcssNode | void} b
+ */
+function nodesShareLines(a, b) {
+ return _.get(a, 'source.end.line') === _.get(b, 'source.start.line');
+}
+
+/**
+ * @param {PostcssNode} node
+ * @returns {boolean}
+ */
+module.exports = function isSharedLineComment(node) {
+ if (node.type !== 'comment') {
+ return false;
+ }
+
+ const previousNonSharedLineCommentNode = getPreviousNonSharedLineCommentNode(node);
+
+ if (nodesShareLines(previousNonSharedLineCommentNode, node)) {
+ return true;
+ }
+
+ const nextNonSharedLineCommentNode = getNextNonSharedLineCommentNode(node);
+
+ if (nextNonSharedLineCommentNode && nodesShareLines(node, nextNonSharedLineCommentNode)) {
+ return true;
+ }
+
+ const parentNode = node.parent;
+
+ // It's a first child and located on the same line as block start
+ if (
+ parentNode !== undefined &&
+ parentNode.type !== 'root' &&
+ parentNode.index(node) === 0 &&
+ node.raws.before !== undefined &&
+ !node.raws.before.includes('\n')
+ ) {
+ return true;
+ }
+
+ return false;
+};