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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // @ts-nocheck
  2. 'use strict';
  3. const _ = require('lodash');
  4. const eachDeclarationBlock = require('../../utils/eachDeclarationBlock');
  5. const optionsMatches = require('../../utils/optionsMatches');
  6. const report = require('../../utils/report');
  7. const ruleMessages = require('../../utils/ruleMessages');
  8. const shorthandData = require('../../reference/shorthandData');
  9. const validateOptions = require('../../utils/validateOptions');
  10. const vendor = require('../../utils/vendor');
  11. const ruleName = 'declaration-block-no-redundant-longhand-properties';
  12. const messages = ruleMessages(ruleName, {
  13. expected: (props) => `Expected shorthand property "${props}"`,
  14. });
  15. function rule(actual, options) {
  16. return (root, result) => {
  17. const validOptions = validateOptions(
  18. result,
  19. ruleName,
  20. { actual },
  21. {
  22. actual: options,
  23. possible: {
  24. ignoreShorthands: [_.isString, _.isRegExp],
  25. },
  26. optional: true,
  27. },
  28. );
  29. if (!validOptions) {
  30. return;
  31. }
  32. const longhandProperties = _.transform(shorthandData, (longhandProps, values, key) => {
  33. if (optionsMatches(options, 'ignoreShorthands', key)) {
  34. return;
  35. }
  36. values.forEach((value) => {
  37. (longhandProps[value] || (longhandProps[value] = [])).push(key);
  38. });
  39. });
  40. eachDeclarationBlock(root, (eachDecl) => {
  41. const longhandDeclarations = {};
  42. eachDecl((decl) => {
  43. const prop = decl.prop.toLowerCase();
  44. const unprefixedProp = vendor.unprefixed(prop);
  45. const prefix = vendor.prefix(prop);
  46. const shorthandProperties = longhandProperties[unprefixedProp];
  47. if (!shorthandProperties) {
  48. return;
  49. }
  50. shorthandProperties.forEach((shorthandProperty) => {
  51. const prefixedShorthandProperty = prefix + shorthandProperty;
  52. if (!longhandDeclarations[prefixedShorthandProperty]) {
  53. longhandDeclarations[prefixedShorthandProperty] = [];
  54. }
  55. longhandDeclarations[prefixedShorthandProperty].push(prop);
  56. const prefixedShorthandData = shorthandData[shorthandProperty].map((item) => {
  57. return prefix + item;
  58. });
  59. if (
  60. !_.isEqual(
  61. prefixedShorthandData.sort(),
  62. longhandDeclarations[prefixedShorthandProperty].sort(),
  63. )
  64. ) {
  65. return;
  66. }
  67. report({
  68. ruleName,
  69. result,
  70. node: decl,
  71. message: messages.expected(prefixedShorthandProperty),
  72. });
  73. });
  74. });
  75. });
  76. };
  77. }
  78. rule.ruleName = ruleName;
  79. rule.messages = messages;
  80. module.exports = rule;