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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // @ts-nocheck
  2. 'use strict';
  3. const blockString = require('../../utils/blockString');
  4. const hasBlock = require('../../utils/hasBlock');
  5. const rawNodeString = require('../../utils/rawNodeString');
  6. const report = require('../../utils/report');
  7. const ruleMessages = require('../../utils/ruleMessages');
  8. const validateOptions = require('../../utils/validateOptions');
  9. const whitespaceChecker = require('../../utils/whitespaceChecker');
  10. const ruleName = 'block-closing-brace-space-after';
  11. const messages = ruleMessages(ruleName, {
  12. expectedAfter: () => 'Expected single space after "}"',
  13. rejectedAfter: () => 'Unexpected whitespace after "}"',
  14. expectedAfterSingleLine: () => 'Expected single space after "}" of a single-line block',
  15. rejectedAfterSingleLine: () => 'Unexpected whitespace after "}" of a single-line block',
  16. expectedAfterMultiLine: () => 'Expected single space after "}" of a multi-line block',
  17. rejectedAfterMultiLine: () => 'Unexpected whitespace after "}" of a multi-line block',
  18. });
  19. function rule(expectation) {
  20. const checker = whitespaceChecker('space', expectation, messages);
  21. return function (root, result) {
  22. const validOptions = validateOptions(result, ruleName, {
  23. actual: expectation,
  24. possible: [
  25. 'always',
  26. 'never',
  27. 'always-single-line',
  28. 'never-single-line',
  29. 'always-multi-line',
  30. 'never-multi-line',
  31. ],
  32. });
  33. if (!validOptions) {
  34. return;
  35. }
  36. // Check both kinds of statements: rules and at-rules
  37. root.walkRules(check);
  38. root.walkAtRules(check);
  39. function check(statement) {
  40. const nextNode = statement.next();
  41. if (!nextNode) {
  42. return;
  43. }
  44. if (!hasBlock(statement)) {
  45. return;
  46. }
  47. let reportIndex = statement.toString().length;
  48. let source = rawNodeString(nextNode);
  49. // Skip a semicolon at the beginning, if any
  50. if (source && source.startsWith(';')) {
  51. source = source.slice(1);
  52. reportIndex++;
  53. }
  54. checker.after({
  55. source,
  56. index: -1,
  57. lineCheckStr: blockString(statement),
  58. err: (msg) => {
  59. report({
  60. message: msg,
  61. node: statement,
  62. index: reportIndex,
  63. result,
  64. ruleName,
  65. });
  66. },
  67. });
  68. }
  69. };
  70. }
  71. rule.ruleName = ruleName;
  72. rule.messages = messages;
  73. module.exports = rule;