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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // @ts-nocheck
  2. 'use strict';
  3. const _ = require('lodash');
  4. const declarationValueIndex = require('../../utils/declarationValueIndex');
  5. const findFontFamily = require('../../utils/findFontFamily');
  6. const keywordSets = require('../../reference/keywordSets');
  7. const optionsMatches = require('../../utils/optionsMatches');
  8. const report = require('../../utils/report');
  9. const ruleMessages = require('../../utils/ruleMessages');
  10. const validateOptions = require('../../utils/validateOptions');
  11. const ruleName = 'font-family-no-duplicate-names';
  12. const messages = ruleMessages(ruleName, {
  13. rejected: (name) => `Unexpected duplicate name ${name}`,
  14. });
  15. const isFamilyNameKeyword = (node) =>
  16. !node.quote && keywordSets.fontFamilyKeywords.has(node.value.toLowerCase());
  17. function rule(actual, options) {
  18. return (root, result) => {
  19. const validOptions = validateOptions(
  20. result,
  21. ruleName,
  22. { actual },
  23. {
  24. actual: options,
  25. possible: {
  26. ignoreFontFamilyNames: [_.isString, _.isRegExp],
  27. },
  28. optional: true,
  29. },
  30. );
  31. if (!validOptions) {
  32. return;
  33. }
  34. root.walkDecls(/^font(-family)?$/i, (decl) => {
  35. const keywords = new Set();
  36. const familyNames = new Set();
  37. const fontFamilies = findFontFamily(decl.value);
  38. if (fontFamilies.length === 0) {
  39. return;
  40. }
  41. fontFamilies.forEach((fontFamilyNode) => {
  42. const family = fontFamilyNode.value.trim();
  43. if (optionsMatches(options, 'ignoreFontFamilyNames', fontFamilyNode.value.trim())) {
  44. return;
  45. }
  46. if (isFamilyNameKeyword(fontFamilyNode)) {
  47. if (keywords.has(family.toLowerCase())) {
  48. complain(
  49. messages.rejected(family),
  50. declarationValueIndex(decl) + fontFamilyNode.sourceIndex,
  51. decl,
  52. );
  53. return;
  54. }
  55. keywords.add(family);
  56. return;
  57. }
  58. if (familyNames.has(family)) {
  59. complain(
  60. messages.rejected(family),
  61. declarationValueIndex(decl) + fontFamilyNode.sourceIndex,
  62. decl,
  63. );
  64. return;
  65. }
  66. familyNames.add(family);
  67. });
  68. });
  69. function complain(message, index, decl) {
  70. report({
  71. result,
  72. ruleName,
  73. message,
  74. node: decl,
  75. index,
  76. });
  77. }
  78. };
  79. }
  80. rule.ruleName = ruleName;
  81. rule.messages = messages;
  82. module.exports = rule;