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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // @ts-nocheck
  2. 'use strict';
  3. const _ = require('lodash');
  4. const declarationValueIndex = require('../../utils/declarationValueIndex');
  5. const findNotContiguousOrRectangular = require('./utils/findNotContiguousOrRectangular');
  6. const isRectangular = require('./utils/isRectangular');
  7. const report = require('../../utils/report');
  8. const ruleMessages = require('../../utils/ruleMessages');
  9. const validateOptions = require('../../utils/validateOptions');
  10. const valueParser = require('postcss-value-parser');
  11. const ruleName = 'named-grid-areas-no-invalid';
  12. const messages = ruleMessages(ruleName, {
  13. expectedToken: () => 'Expected cell token within string',
  14. expectedSameNumber: () => 'Expected same number of cell tokens in each string',
  15. expectedRectangle: (name) => `Expected single filled-in rectangle for "${name}"`,
  16. });
  17. function rule(actual) {
  18. return (root, result) => {
  19. const validOptions = validateOptions(result, ruleName, { actual });
  20. if (!validOptions) {
  21. return;
  22. }
  23. root.walkDecls(/^grid-template-areas$/i, (decl) => {
  24. const { value } = decl;
  25. if (value.toLowerCase().trim() === 'none') return;
  26. const areas = [];
  27. let reportSent = false;
  28. valueParser(value).walk(({ sourceIndex, type, value: tokenValue }) => {
  29. if (type !== 'string') return;
  30. if (tokenValue === '') {
  31. complain(messages.expectedToken(), sourceIndex);
  32. reportSent = true;
  33. return;
  34. }
  35. areas.push(_.compact(tokenValue.trim().split(' ')));
  36. });
  37. if (reportSent) return;
  38. if (!isRectangular(areas)) {
  39. complain(messages.expectedSameNumber());
  40. return;
  41. }
  42. const notContiguousOrRectangular = findNotContiguousOrRectangular(areas);
  43. notContiguousOrRectangular.sort().forEach((name) => {
  44. complain(messages.expectedRectangle(name));
  45. });
  46. function complain(message, sourceIndex = 0) {
  47. report({
  48. message,
  49. node: decl,
  50. index: declarationValueIndex(decl) + sourceIndex,
  51. result,
  52. ruleName,
  53. });
  54. }
  55. });
  56. };
  57. }
  58. rule.ruleName = ruleName;
  59. rule.messages = messages;
  60. module.exports = rule;