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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // @ts-nocheck
  2. 'use strict';
  3. const _ = require('lodash');
  4. const isCustomProperty = require('../../utils/isCustomProperty');
  5. const report = require('../../utils/report');
  6. const ruleMessages = require('../../utils/ruleMessages');
  7. const validateOptions = require('../../utils/validateOptions');
  8. const ruleName = 'custom-property-pattern';
  9. const messages = ruleMessages(ruleName, {
  10. expected: (pattern) => `Expected custom property name to match pattern "${pattern}"`,
  11. });
  12. function rule(pattern) {
  13. return (root, result) => {
  14. const validOptions = validateOptions(result, ruleName, {
  15. actual: pattern,
  16. possible: [_.isRegExp, _.isString],
  17. });
  18. if (!validOptions) {
  19. return;
  20. }
  21. const regexpPattern = _.isString(pattern) ? new RegExp(pattern) : pattern;
  22. root.walkDecls((decl) => {
  23. const prop = decl.prop;
  24. if (!isCustomProperty(prop)) {
  25. return;
  26. }
  27. if (regexpPattern.test(prop.slice(2))) {
  28. return;
  29. }
  30. report({
  31. message: messages.expected(pattern),
  32. node: decl,
  33. result,
  34. ruleName,
  35. });
  36. });
  37. };
  38. }
  39. rule.ruleName = ruleName;
  40. rule.messages = messages;
  41. module.exports = rule;