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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // @ts-nocheck
  2. 'use strict';
  3. const _ = require('lodash');
  4. const isStandardSyntaxCombinator = require('../../utils/isStandardSyntaxCombinator');
  5. const isStandardSyntaxRule = require('../../utils/isStandardSyntaxRule');
  6. const parseSelector = require('../../utils/parseSelector');
  7. const report = require('../../utils/report');
  8. const ruleMessages = require('../../utils/ruleMessages');
  9. const validateOptions = require('../../utils/validateOptions');
  10. const ruleName = 'selector-combinator-disallowed-list';
  11. const messages = ruleMessages(ruleName, {
  12. rejected: (combinator) => `Unexpected combinator "${combinator}"`,
  13. });
  14. function rule(list) {
  15. return (root, result) => {
  16. const validOptions = validateOptions(result, ruleName, {
  17. actual: list,
  18. possible: [_.isString],
  19. });
  20. if (!validOptions) {
  21. return;
  22. }
  23. root.walkRules((ruleNode) => {
  24. if (!isStandardSyntaxRule(ruleNode)) {
  25. return;
  26. }
  27. const selector = ruleNode.selector;
  28. parseSelector(selector, result, ruleNode, (fullSelector) => {
  29. fullSelector.walkCombinators((combinatorNode) => {
  30. if (!isStandardSyntaxCombinator(combinatorNode)) {
  31. return;
  32. }
  33. const value = normalizeCombinator(combinatorNode.value);
  34. if (!list.includes(value)) {
  35. return;
  36. }
  37. report({
  38. result,
  39. ruleName,
  40. message: messages.rejected(value),
  41. node: ruleNode,
  42. index: combinatorNode.sourceIndex,
  43. });
  44. });
  45. });
  46. });
  47. };
  48. }
  49. function normalizeCombinator(value) {
  50. return value.replace(/\s+/g, ' ');
  51. }
  52. rule.primaryOptionArray = true;
  53. rule.ruleName = ruleName;
  54. rule.messages = messages;
  55. module.exports = rule;