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.

isStandardSyntaxRule.js 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. 'use strict';
  2. const _ = require('lodash');
  3. const isCustomPropertySet = require('../utils/isCustomPropertySet');
  4. const isStandardSyntaxSelector = require('../utils/isStandardSyntaxSelector');
  5. /**
  6. * Check whether a Node is a standard rule
  7. *
  8. * @param {import('postcss').Rule | import('postcss-less').Rule} rule
  9. * @returns {boolean}
  10. */
  11. module.exports = function (rule) {
  12. if (rule.type !== 'rule') {
  13. return false;
  14. }
  15. // Get full selector
  16. const selector = _.get(rule, 'raws.selector.raw', rule.selector);
  17. if (!isStandardSyntaxSelector(rule.selector)) {
  18. return false;
  19. }
  20. // Custom property set (e.g. --custom-property-set: {})
  21. if (isCustomPropertySet(rule)) {
  22. return false;
  23. }
  24. // Called Less mixin (e.g. a { .mixin() })
  25. // @ts-ignore TODO TYPES support LESS and SASS types somehow
  26. if (rule.mixin) {
  27. return false;
  28. }
  29. // Less detached rulesets
  30. if (selector.startsWith('@') && selector.endsWith(':')) {
  31. return false;
  32. }
  33. // Ignore Less &:extend rule
  34. if ('extend' in rule && rule.extend) {
  35. return false;
  36. }
  37. // Ignore mixin or &:extend rule
  38. // https://github.com/shellscape/postcss-less/blob/master/lib/less-parser.js#L52
  39. // @ts-ignore TODO TYPES support LESS and SASS types somehow
  40. if (rule.params && rule.params[0]) {
  41. return false;
  42. }
  43. // Non-outputting Less mixin definition (e.g. .mixin() {})
  44. if (selector.endsWith(')') && !selector.includes(':')) {
  45. return false;
  46. }
  47. // Less guards
  48. if (/when\s+(not\s+)*\(/.test(selector)) {
  49. return false;
  50. }
  51. // Ignore Scss nested properties
  52. if (selector.endsWith(':')) {
  53. return false;
  54. }
  55. return true;
  56. };