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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // @ts-nocheck
  2. 'use strict';
  3. const _ = require('lodash');
  4. const beforeBlockString = require('../../utils/beforeBlockString');
  5. const blockString = require('../../utils/blockString');
  6. const isSingleLineString = require('../../utils/isSingleLineString');
  7. const report = require('../../utils/report');
  8. const ruleMessages = require('../../utils/ruleMessages');
  9. const validateOptions = require('../../utils/validateOptions');
  10. const ruleName = 'declaration-block-single-line-max-declarations';
  11. const messages = ruleMessages(ruleName, {
  12. expected: (max) => `Expected no more than ${max} ${max === 1 ? 'declaration' : 'declarations'}`,
  13. });
  14. function rule(quantity) {
  15. return (root, result) => {
  16. const validOptions = validateOptions(result, ruleName, {
  17. actual: quantity,
  18. possible: [_.isNumber],
  19. });
  20. if (!validOptions) {
  21. return;
  22. }
  23. root.walkRules((ruleNode) => {
  24. if (!isSingleLineString(blockString(ruleNode))) {
  25. return;
  26. }
  27. if (!ruleNode.nodes) {
  28. return;
  29. }
  30. const decls = ruleNode.nodes.filter((node) => node.type === 'decl');
  31. if (decls.length <= quantity) {
  32. return;
  33. }
  34. report({
  35. message: messages.expected(quantity),
  36. node: ruleNode,
  37. index: beforeBlockString(ruleNode, { noRawBefore: true }).length,
  38. result,
  39. ruleName,
  40. });
  41. });
  42. };
  43. }
  44. rule.ruleName = ruleName;
  45. rule.messages = messages;
  46. module.exports = rule;