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

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