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

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