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.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // @ts-nocheck
  2. 'use strict';
  3. const atRuleParamIndex = require('../../utils/atRuleParamIndex');
  4. const mediaQueryListCommaWhitespaceChecker = require('../mediaQueryListCommaWhitespaceChecker');
  5. const ruleMessages = require('../../utils/ruleMessages');
  6. const validateOptions = require('../../utils/validateOptions');
  7. const whitespaceChecker = require('../../utils/whitespaceChecker');
  8. const ruleName = 'media-query-list-comma-space-before';
  9. const messages = ruleMessages(ruleName, {
  10. expectedBefore: () => 'Expected single space before ","',
  11. rejectedBefore: () => 'Unexpected whitespace before ","',
  12. expectedBeforeSingleLine: () => 'Expected single space before "," in a single-line list',
  13. rejectedBeforeSingleLine: () => 'Unexpected whitespace before "," in a single-line list',
  14. });
  15. function rule(expectation, options, context) {
  16. const checker = whitespaceChecker('space', expectation, messages);
  17. return (root, result) => {
  18. const validOptions = validateOptions(result, ruleName, {
  19. actual: expectation,
  20. possible: ['always', 'never', 'always-single-line', 'never-single-line'],
  21. });
  22. if (!validOptions) {
  23. return;
  24. }
  25. let fixData;
  26. mediaQueryListCommaWhitespaceChecker({
  27. root,
  28. result,
  29. locationChecker: checker.before,
  30. checkedRuleName: ruleName,
  31. fix: context.fix
  32. ? (atRule, index) => {
  33. const paramCommaIndex = index - atRuleParamIndex(atRule);
  34. fixData = fixData || new Map();
  35. const commaIndices = fixData.get(atRule) || [];
  36. commaIndices.push(paramCommaIndex);
  37. fixData.set(atRule, commaIndices);
  38. return true;
  39. }
  40. : null,
  41. });
  42. if (fixData) {
  43. fixData.forEach((commaIndices, atRule) => {
  44. let params = atRule.raws.params ? atRule.raws.params.raw : atRule.params;
  45. commaIndices
  46. .sort((a, b) => b - a)
  47. .forEach((index) => {
  48. const beforeComma = params.slice(0, index);
  49. const afterComma = params.slice(index);
  50. if (expectation.startsWith('always')) {
  51. params = beforeComma.replace(/\s*$/, ' ') + afterComma;
  52. } else if (expectation.startsWith('never')) {
  53. params = beforeComma.replace(/\s*$/, '') + afterComma;
  54. }
  55. });
  56. if (atRule.raws.params) {
  57. atRule.raws.params.raw = params;
  58. } else {
  59. atRule.params = params;
  60. }
  61. });
  62. }
  63. };
  64. }
  65. rule.ruleName = ruleName;
  66. rule.messages = messages;
  67. module.exports = rule;