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 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // @ts-nocheck
  2. 'use strict';
  3. const _ = require('lodash');
  4. const beforeBlockString = require('../../utils/beforeBlockString');
  5. const hasBlock = require('../../utils/hasBlock');
  6. const hasEmptyBlock = require('../../utils/hasEmptyBlock');
  7. const optionsMatches = require('../../utils/optionsMatches');
  8. const report = require('../../utils/report');
  9. const ruleMessages = require('../../utils/ruleMessages');
  10. const validateOptions = require('../../utils/validateOptions');
  11. const ruleName = 'block-no-empty';
  12. const messages = ruleMessages(ruleName, {
  13. rejected: 'Unexpected empty block',
  14. });
  15. function rule(primary, options = {}) {
  16. return (root, result) => {
  17. const validOptions = validateOptions(
  18. result,
  19. ruleName,
  20. {
  21. actual: primary,
  22. possible: _.isBoolean,
  23. },
  24. {
  25. actual: options,
  26. possible: {
  27. ignore: ['comments'],
  28. },
  29. optional: true,
  30. },
  31. );
  32. if (!validOptions) {
  33. return;
  34. }
  35. const ignoreComments = optionsMatches(options, 'ignore', 'comments');
  36. // Check both kinds of statements: rules and at-rules
  37. root.walkRules(check);
  38. root.walkAtRules(check);
  39. function check(statement) {
  40. if (!hasEmptyBlock(statement) && !ignoreComments) {
  41. return;
  42. }
  43. if (!hasBlock(statement)) {
  44. return;
  45. }
  46. const hasCommentsOnly = statement.nodes.every((node) => node.type === 'comment');
  47. if (!hasCommentsOnly) {
  48. return;
  49. }
  50. let index = beforeBlockString(statement, { noRawBefore: true }).length;
  51. // For empty blocks when using SugarSS parser
  52. if (statement.raws.between === undefined) {
  53. index--;
  54. }
  55. report({
  56. message: messages.rejected,
  57. node: statement,
  58. index,
  59. result,
  60. ruleName,
  61. });
  62. }
  63. };
  64. }
  65. rule.ruleName = ruleName;
  66. rule.messages = messages;
  67. module.exports = rule;