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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // @ts-nocheck
  2. 'use strict';
  3. const declarationValueIndex = require('../../utils/declarationValueIndex');
  4. const findFontFamily = require('../../utils/findFontFamily');
  5. const isStandardSyntaxValue = require('../../utils/isStandardSyntaxValue');
  6. const isVariable = require('../../utils/isVariable');
  7. const keywordSets = require('../../reference/keywordSets');
  8. const optionsMatches = require('../../utils/optionsMatches');
  9. const postcss = require('postcss');
  10. const report = require('../../utils/report');
  11. const ruleMessages = require('../../utils/ruleMessages');
  12. const validateOptions = require('../../utils/validateOptions');
  13. const _ = require('lodash');
  14. const ruleName = 'font-family-no-missing-generic-family-keyword';
  15. const messages = ruleMessages(ruleName, {
  16. rejected: 'Unexpected missing generic font family',
  17. });
  18. const isFamilyNameKeyword = (node) =>
  19. !node.quote && keywordSets.fontFamilyKeywords.has(node.value.toLowerCase());
  20. const isLastFontFamilyVariable = (value) => {
  21. const lastValue = postcss.list.comma(value).pop();
  22. return isVariable(lastValue) || !isStandardSyntaxValue(lastValue);
  23. };
  24. function rule(actual, options) {
  25. return (root, result) => {
  26. const validOptions = validateOptions(
  27. result,
  28. ruleName,
  29. { actual },
  30. {
  31. actual: options,
  32. possible: {
  33. ignoreFontFamilies: [_.isString, _.isRegExp],
  34. },
  35. optional: true,
  36. },
  37. );
  38. if (!validOptions) {
  39. return;
  40. }
  41. root.walkDecls(/^font(-family)?$/i, (decl) => {
  42. // Ignore @font-face
  43. if (
  44. decl.parent &&
  45. decl.parent.type === 'atrule' &&
  46. decl.parent.name.toLowerCase() === 'font-face'
  47. ) {
  48. return;
  49. }
  50. if (decl.prop === 'font' && keywordSets.systemFontValues.has(decl.value.toLowerCase())) {
  51. return;
  52. }
  53. if (isLastFontFamilyVariable(decl.value)) {
  54. return;
  55. }
  56. const fontFamilies = findFontFamily(decl.value);
  57. if (fontFamilies.length === 0) {
  58. return;
  59. }
  60. if (fontFamilies.some(isFamilyNameKeyword)) {
  61. return;
  62. }
  63. if (fontFamilies.some((node) => optionsMatches(options, 'ignoreFontFamilies', node.value))) {
  64. return;
  65. }
  66. report({
  67. result,
  68. ruleName,
  69. message: messages.rejected,
  70. node: decl,
  71. index: declarationValueIndex(decl) + fontFamilies[fontFamilies.length - 1].sourceIndex,
  72. });
  73. });
  74. };
  75. }
  76. rule.ruleName = ruleName;
  77. rule.messages = messages;
  78. module.exports = rule;