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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // @ts-nocheck
  2. 'use strict';
  3. const declarationBangSpaceChecker = require('../declarationBangSpaceChecker');
  4. const declarationValueIndex = require('../../utils/declarationValueIndex');
  5. const getDeclarationValue = require('../../utils/getDeclarationValue');
  6. const ruleMessages = require('../../utils/ruleMessages');
  7. const setDeclarationValue = require('../../utils/setDeclarationValue');
  8. const validateOptions = require('../../utils/validateOptions');
  9. const whitespaceChecker = require('../../utils/whitespaceChecker');
  10. const ruleName = 'declaration-bang-space-after';
  11. const messages = ruleMessages(ruleName, {
  12. expectedAfter: () => 'Expected single space after "!"',
  13. rejectedAfter: () => 'Unexpected whitespace after "!"',
  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'],
  21. });
  22. if (!validOptions) {
  23. return;
  24. }
  25. declarationBangSpaceChecker({
  26. root,
  27. result,
  28. locationChecker: checker.after,
  29. checkedRuleName: ruleName,
  30. fix: context.fix
  31. ? (decl, index) => {
  32. let bangIndex = index - declarationValueIndex(decl);
  33. const declValue = getDeclarationValue(decl);
  34. let target;
  35. let setFixed;
  36. if (bangIndex < declValue.length) {
  37. target = declValue;
  38. setFixed = (value) => {
  39. setDeclarationValue(decl, value);
  40. };
  41. } else if (decl.important) {
  42. target = decl.raws.important || ' !important';
  43. bangIndex -= declValue.length;
  44. setFixed = (value) => {
  45. decl.raws.important = value;
  46. };
  47. } else {
  48. return false; // not standard
  49. }
  50. const targetBefore = target.slice(0, bangIndex + 1);
  51. const targetAfter = target.slice(bangIndex + 1);
  52. if (expectation === 'always') {
  53. setFixed(targetBefore + targetAfter.replace(/^\s*/, ' '));
  54. return true;
  55. }
  56. if (expectation === 'never') {
  57. setFixed(targetBefore + targetAfter.replace(/^\s*/, ''));
  58. return true;
  59. }
  60. }
  61. : null,
  62. });
  63. };
  64. }
  65. rule.ruleName = ruleName;
  66. rule.messages = messages;
  67. module.exports = rule;