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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // @ts-nocheck
  2. 'use strict';
  3. const _ = require('lodash');
  4. const atRuleParamIndex = require('../../utils/atRuleParamIndex');
  5. const report = require('../../utils/report');
  6. const ruleMessages = require('../../utils/ruleMessages');
  7. const validateOptions = require('../../utils/validateOptions');
  8. const valueParser = require('postcss-value-parser');
  9. const ruleName = 'media-feature-parentheses-space-inside';
  10. const messages = ruleMessages(ruleName, {
  11. expectedOpening: 'Expected single space after "("',
  12. rejectedOpening: 'Unexpected whitespace after "("',
  13. expectedClosing: 'Expected single space before ")"',
  14. rejectedClosing: 'Unexpected whitespace before ")"',
  15. });
  16. function rule(expectation, options, context) {
  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. root.walkAtRules(/^media$/i, (atRule) => {
  26. // If there are comments in the params, the complete string
  27. // will be at atRule.raws.params.raw
  28. const params = _.get(atRule, 'raws.params.raw', atRule.params);
  29. const indexBoost = atRuleParamIndex(atRule);
  30. const violations = [];
  31. const parsedParams = valueParser(params).walk((node) => {
  32. if (node.type === 'function') {
  33. const len = valueParser.stringify(node).length;
  34. if (expectation === 'never') {
  35. if (/[ \t]/.test(node.before)) {
  36. if (context.fix) node.before = '';
  37. violations.push({
  38. message: messages.rejectedOpening,
  39. index: node.sourceIndex + 1 + indexBoost,
  40. });
  41. }
  42. if (/[ \t]/.test(node.after)) {
  43. if (context.fix) node.after = '';
  44. violations.push({
  45. message: messages.rejectedClosing,
  46. index: node.sourceIndex - 2 + len + indexBoost,
  47. });
  48. }
  49. } else if (expectation === 'always') {
  50. if (node.before === '') {
  51. if (context.fix) node.before = ' ';
  52. violations.push({
  53. message: messages.expectedOpening,
  54. index: node.sourceIndex + 1 + indexBoost,
  55. });
  56. }
  57. if (node.after === '') {
  58. if (context.fix) node.after = ' ';
  59. violations.push({
  60. message: messages.expectedClosing,
  61. index: node.sourceIndex - 2 + len + indexBoost,
  62. });
  63. }
  64. }
  65. }
  66. });
  67. if (violations.length) {
  68. if (context.fix) {
  69. atRule.params = parsedParams.toString();
  70. return;
  71. }
  72. violations.forEach((err) => {
  73. report({
  74. message: err.message,
  75. node: atRule,
  76. index: err.index,
  77. result,
  78. ruleName,
  79. });
  80. });
  81. }
  82. });
  83. };
  84. }
  85. rule.ruleName = ruleName;
  86. rule.messages = messages;
  87. module.exports = rule;