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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // @ts-nocheck
  2. 'use strict';
  3. const _ = require('lodash');
  4. const isAutoprefixable = require('../../utils/isAutoprefixable');
  5. const isStandardSyntaxDeclaration = require('../../utils/isStandardSyntaxDeclaration');
  6. const isStandardSyntaxProperty = require('../../utils/isStandardSyntaxProperty');
  7. const optionsMatches = require('../../utils/optionsMatches');
  8. const report = require('../../utils/report');
  9. const ruleMessages = require('../../utils/ruleMessages');
  10. const styleSearch = require('style-search');
  11. const validateOptions = require('../../utils/validateOptions');
  12. const vendor = require('../../utils/vendor');
  13. const ruleName = 'value-no-vendor-prefix';
  14. const messages = ruleMessages(ruleName, {
  15. rejected: (value) => `Unexpected vendor-prefix "${value}"`,
  16. });
  17. const valuePrefixes = ['-webkit-', '-moz-', '-ms-', '-o-'];
  18. function rule(actual, options, context) {
  19. return (root, result) => {
  20. const validOptions = validateOptions(
  21. result,
  22. ruleName,
  23. { actual },
  24. {
  25. optional: true,
  26. actual: options,
  27. possible: {
  28. ignoreValues: [_.isString],
  29. },
  30. },
  31. );
  32. if (!validOptions) {
  33. return;
  34. }
  35. root.walkDecls((decl) => {
  36. if (
  37. !isStandardSyntaxDeclaration(decl) ||
  38. !isStandardSyntaxProperty(decl.prop) ||
  39. !decl.value.startsWith('-')
  40. ) {
  41. return;
  42. }
  43. const prop = decl.prop;
  44. const value = decl.value;
  45. const unprefixedValue = vendor.unprefixed(value);
  46. //return early if value is to be ignored
  47. if (optionsMatches(options, 'ignoreValues', unprefixedValue)) {
  48. return;
  49. }
  50. // Search the full declaration in order to get an accurate index
  51. styleSearch({ source: value.toLowerCase(), target: valuePrefixes }, (match) => {
  52. const fullIdentifier = /^(-[a-z-]+)\b/i.exec(value.slice(match.startIndex))[1];
  53. if (!isAutoprefixable.propertyValue(prop, fullIdentifier)) {
  54. return;
  55. }
  56. if (context.fix) {
  57. decl.value = isAutoprefixable.unprefix(decl.value);
  58. return;
  59. }
  60. report({
  61. message: messages.rejected(fullIdentifier),
  62. node: decl,
  63. index: prop.length + (decl.raws.between || '').length + match.startIndex,
  64. result,
  65. ruleName,
  66. });
  67. });
  68. });
  69. };
  70. }
  71. rule.ruleName = ruleName;
  72. rule.messages = messages;
  73. module.exports = rule;