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.

isStandardSyntaxDeclaration.js 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. 'use strict';
  2. const isScssVariable = require('./isScssVariable');
  3. const { isRoot } = require('./typeGuards');
  4. /**
  5. * @param {string} [lang]
  6. */
  7. function isStandardSyntaxLang(lang) {
  8. return lang && (lang === 'css' || lang === 'custom-template' || lang === 'template-literal');
  9. }
  10. /**
  11. * Check whether a declaration is standard
  12. *
  13. * @param {import('postcss').Declaration | import('postcss-less').Declaration} decl
  14. */
  15. module.exports = function (decl) {
  16. const prop = decl.prop;
  17. const parent = decl.parent;
  18. // Declarations belong in a declaration block or standard CSS source
  19. if (
  20. isRoot(parent) &&
  21. parent.source &&
  22. !isStandardSyntaxLang(
  23. /** @type {import('postcss').NodeSource & {lang?: string}} */ (parent.source).lang,
  24. )
  25. ) {
  26. return false;
  27. }
  28. // SCSS var
  29. if (isScssVariable(prop)) {
  30. return false;
  31. }
  32. // Less var (e.g. @var: x), but exclude variable interpolation (e.g. @{var})
  33. if (prop[0] === '@' && prop[1] !== '{') {
  34. return false;
  35. }
  36. // Sass nested properties (e.g. border: { style: solid; color: red; })
  37. if (
  38. // @ts-ignore TODO TYPES selector does not exists
  39. parent.selector &&
  40. // @ts-ignore
  41. parent.selector[parent.selector.length - 1] === ':' &&
  42. // @ts-ignore
  43. parent.selector.substring(0, 2) !== '--'
  44. ) {
  45. return false;
  46. }
  47. // Less &:extend
  48. if ('extend' in decl && decl.extend) {
  49. return false;
  50. }
  51. return true;
  52. };