isStandardSyntaxMediaFeature.js 533 B

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. const hasInterpolation = require('../utils/hasInterpolation');
  3. /**
  4. * Check whether a media feature is standard
  5. *
  6. * @param {string} mediaFeature
  7. * @returns {boolean}
  8. */
  9. module.exports = function (mediaFeature) {
  10. // Remove outside parens
  11. mediaFeature = mediaFeature.slice(1, -1);
  12. // Parentheticals used for non-standard operations e.g. ($var - 10)
  13. if (mediaFeature.includes('(')) {
  14. return false;
  15. }
  16. // SCSS or Less interpolation
  17. if (hasInterpolation(mediaFeature)) {
  18. return false;
  19. }
  20. return true;
  21. };