Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

isSharedLineComment.js 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. 'use strict';
  2. const _ = require('lodash');
  3. const getNextNonSharedLineCommentNode = require('./getNextNonSharedLineCommentNode');
  4. const getPreviousNonSharedLineCommentNode = require('./getPreviousNonSharedLineCommentNode');
  5. /** @typedef {import('postcss').Node} PostcssNode */
  6. /**
  7. *
  8. * @param {PostcssNode | void} a
  9. * @param {PostcssNode | void} b
  10. */
  11. function nodesShareLines(a, b) {
  12. return _.get(a, 'source.end.line') === _.get(b, 'source.start.line');
  13. }
  14. /**
  15. * @param {PostcssNode} node
  16. * @returns {boolean}
  17. */
  18. module.exports = function isSharedLineComment(node) {
  19. if (node.type !== 'comment') {
  20. return false;
  21. }
  22. const previousNonSharedLineCommentNode = getPreviousNonSharedLineCommentNode(node);
  23. if (nodesShareLines(previousNonSharedLineCommentNode, node)) {
  24. return true;
  25. }
  26. const nextNonSharedLineCommentNode = getNextNonSharedLineCommentNode(node);
  27. if (nextNonSharedLineCommentNode && nodesShareLines(node, nextNonSharedLineCommentNode)) {
  28. return true;
  29. }
  30. const parentNode = node.parent;
  31. // It's a first child and located on the same line as block start
  32. if (
  33. parentNode !== undefined &&
  34. parentNode.type !== 'root' &&
  35. parentNode.index(node) === 0 &&
  36. node.raws.before !== undefined &&
  37. !node.raws.before.includes('\n')
  38. ) {
  39. return true;
  40. }
  41. return false;
  42. };