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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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-before';
  11. const messages = ruleMessages(ruleName, {
  12. expectedBefore: () => 'Expected single space before "!"',
  13. rejectedBefore: () => 'Unexpected whitespace before "!"',
  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.before,
  29. checkedRuleName: ruleName,
  30. fix: context.fix
  31. ? (decl, index) => {
  32. let bangIndex = index - declarationValueIndex(decl);
  33. const value = getDeclarationValue(decl);
  34. let target;
  35. let setFixed;
  36. if (bangIndex < value.length) {
  37. target = value;
  38. setFixed = (val) => {
  39. setDeclarationValue(decl, val);
  40. };
  41. } else if (decl.important) {
  42. target = decl.raws.important || ' !important';
  43. bangIndex -= value.length;
  44. setFixed = (val) => {
  45. decl.raws.important = val;
  46. };
  47. } else {
  48. return false; // not standard
  49. }
  50. const targetBefore = target.slice(0, bangIndex);
  51. const targetAfter = target.slice(bangIndex);
  52. if (expectation === 'always') {
  53. // eslint-disable-next-line prefer-template
  54. setFixed(targetBefore.replace(/\s*$/, '') + ' ' + targetAfter);
  55. return true;
  56. }
  57. if (expectation === 'never') {
  58. setFixed(targetBefore.replace(/\s*$/, '') + targetAfter);
  59. return true;
  60. }
  61. }
  62. : null,
  63. });
  64. };
  65. }
  66. rule.ruleName = ruleName;
  67. rule.messages = messages;
  68. module.exports = rule;