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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // @ts-nocheck
  2. 'use strict';
  3. const blockString = require('../../utils/blockString');
  4. const rawNodeString = require('../../utils/rawNodeString');
  5. const report = require('../../utils/report');
  6. const ruleMessages = require('../../utils/ruleMessages');
  7. const validateOptions = require('../../utils/validateOptions');
  8. const whitespaceChecker = require('../../utils/whitespaceChecker');
  9. const ruleName = 'declaration-block-semicolon-space-after';
  10. const messages = ruleMessages(ruleName, {
  11. expectedAfter: () => 'Expected single space after ";"',
  12. rejectedAfter: () => 'Unexpected whitespace after ";"',
  13. expectedAfterSingleLine: () =>
  14. 'Expected single space after ";" in a single-line declaration block',
  15. rejectedAfterSingleLine: () =>
  16. 'Unexpected whitespace after ";" in a single-line declaration block',
  17. });
  18. function rule(expectation, options, context) {
  19. const checker = whitespaceChecker('space', expectation, messages);
  20. return function (root, result) {
  21. const validOptions = validateOptions(result, ruleName, {
  22. actual: expectation,
  23. possible: ['always', 'never', 'always-single-line', 'never-single-line'],
  24. });
  25. if (!validOptions) {
  26. return;
  27. }
  28. root.walkDecls((decl) => {
  29. // Ignore last declaration if there's no trailing semicolon
  30. const parentRule = decl.parent;
  31. if (!parentRule.raws.semicolon && parentRule.last === decl) {
  32. return;
  33. }
  34. const nextDecl = decl.next();
  35. if (!nextDecl) {
  36. return;
  37. }
  38. checker.after({
  39. source: rawNodeString(nextDecl),
  40. index: -1,
  41. lineCheckStr: blockString(parentRule),
  42. err: (m) => {
  43. if (context.fix) {
  44. if (expectation.startsWith('always')) {
  45. nextDecl.raws.before = ' ';
  46. return;
  47. }
  48. if (expectation.startsWith('never')) {
  49. nextDecl.raws.before = '';
  50. return;
  51. }
  52. }
  53. report({
  54. message: m,
  55. node: decl,
  56. index: decl.toString().length + 1,
  57. result,
  58. ruleName,
  59. });
  60. },
  61. });
  62. });
  63. };
  64. }
  65. rule.ruleName = ruleName;
  66. rule.messages = messages;
  67. module.exports = rule;