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.

selectorAttributeOperatorSpaceChecker.js 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // @ts-nocheck
  2. 'use strict';
  3. const isStandardSyntaxRule = require('../utils/isStandardSyntaxRule');
  4. const parseSelector = require('../utils/parseSelector');
  5. const report = require('../utils/report');
  6. const styleSearch = require('style-search');
  7. module.exports = function (options) {
  8. options.root.walkRules((rule) => {
  9. if (!isStandardSyntaxRule(rule)) {
  10. return;
  11. }
  12. if (!rule.selector.includes('[') || !rule.selector.includes('=')) {
  13. return;
  14. }
  15. let hasFixed = false;
  16. const selector = rule.raws.selector ? rule.raws.selector.raw : rule.selector;
  17. const fixedSelector = parseSelector(selector, options.result, rule, (selectorTree) => {
  18. selectorTree.walkAttributes((attributeNode) => {
  19. const operator = attributeNode.operator;
  20. if (!operator) {
  21. return;
  22. }
  23. const attributeNodeString = attributeNode.toString();
  24. styleSearch({ source: attributeNodeString, target: operator }, (match) => {
  25. const index = options.checkBeforeOperator ? match.startIndex : match.endIndex - 1;
  26. checkOperator(attributeNodeString, index, rule, attributeNode, operator);
  27. });
  28. });
  29. });
  30. if (hasFixed) {
  31. if (!rule.raws.selector) {
  32. rule.selector = fixedSelector;
  33. } else {
  34. rule.raws.selector.raw = fixedSelector;
  35. }
  36. }
  37. function checkOperator(source, index, node, attributeNode, operator) {
  38. options.locationChecker({
  39. source,
  40. index,
  41. err: (m) => {
  42. if (options.fix && options.fix(attributeNode)) {
  43. hasFixed = true;
  44. return;
  45. }
  46. report({
  47. message: m.replace(
  48. options.checkBeforeOperator ? operator[0] : operator[operator.length - 1],
  49. operator,
  50. ),
  51. node,
  52. index: attributeNode.sourceIndex + index,
  53. result: options.result,
  54. ruleName: options.checkedRuleName,
  55. });
  56. },
  57. });
  58. }
  59. });
  60. };