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.

index.js 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // @ts-nocheck
  2. 'use strict';
  3. const _ = require('lodash');
  4. const atRuleParamIndex = require('../../utils/atRuleParamIndex');
  5. const isCustomMediaQuery = require('../../utils/isCustomMediaQuery');
  6. const isRangeContextMediaFeature = require('../../utils/isRangeContextMediaFeature');
  7. const isStandardSyntaxMediaFeatureName = require('../../utils/isStandardSyntaxMediaFeatureName');
  8. const keywordSets = require('../../reference/keywordSets');
  9. const mediaParser = require('postcss-media-query-parser').default;
  10. const optionsMatches = require('../../utils/optionsMatches');
  11. const rangeContextNodeParser = require('../rangeContextNodeParser');
  12. const report = require('../../utils/report');
  13. const ruleMessages = require('../../utils/ruleMessages');
  14. const validateOptions = require('../../utils/validateOptions');
  15. const vendor = require('../../utils/vendor');
  16. const ruleName = 'media-feature-name-no-unknown';
  17. const messages = ruleMessages(ruleName, {
  18. rejected: (mediaFeatureName) => `Unexpected unknown media feature name "${mediaFeatureName}"`,
  19. });
  20. function rule(actual, options) {
  21. return (root, result) => {
  22. const validOptions = validateOptions(
  23. result,
  24. ruleName,
  25. { actual },
  26. {
  27. actual: options,
  28. possible: {
  29. ignoreMediaFeatureNames: [_.isString, _.isRegExp],
  30. },
  31. optional: true,
  32. },
  33. );
  34. if (!validOptions) {
  35. return;
  36. }
  37. root.walkAtRules(/^media$/i, (atRule) => {
  38. mediaParser(atRule.params).walk(/^media-feature$/i, (mediaFeatureNode) => {
  39. const parent = mediaFeatureNode.parent;
  40. const mediaFeatureRangeContext = isRangeContextMediaFeature(parent.value);
  41. let value;
  42. let sourceIndex;
  43. if (mediaFeatureRangeContext) {
  44. const parsedRangeContext = rangeContextNodeParser(mediaFeatureNode);
  45. value = parsedRangeContext.name.value;
  46. sourceIndex = parsedRangeContext.name.sourceIndex;
  47. } else {
  48. value = mediaFeatureNode.value;
  49. sourceIndex = mediaFeatureNode.sourceIndex;
  50. }
  51. if (!isStandardSyntaxMediaFeatureName(value) || isCustomMediaQuery(value)) {
  52. return;
  53. }
  54. if (optionsMatches(options, 'ignoreMediaFeatureNames', value)) {
  55. return;
  56. }
  57. if (vendor.prefix(value) || keywordSets.mediaFeatureNames.has(value.toLowerCase())) {
  58. return;
  59. }
  60. report({
  61. index: atRuleParamIndex(atRule) + sourceIndex,
  62. message: messages.rejected(value),
  63. node: atRule,
  64. ruleName,
  65. result,
  66. });
  67. });
  68. });
  69. };
  70. }
  71. rule.ruleName = ruleName;
  72. rule.messages = messages;
  73. module.exports = rule;