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.

invalidScopeDisables.js 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. 'use strict';
  2. const optionsMatches = require('./utils/optionsMatches');
  3. const validateDisableSettings = require('./validateDisableSettings');
  4. /** @typedef {import('stylelint').RangeType} RangeType */
  5. /**
  6. * @param {import('stylelint').StylelintResult[]} results
  7. */
  8. module.exports = function (results) {
  9. results.forEach((result) => {
  10. const settings = validateDisableSettings(result._postcssResult, 'reportInvalidScopeDisables');
  11. if (!settings) return;
  12. const [enabled, options, stylelintResult] = settings;
  13. const configRules = (stylelintResult.config || {}).rules || {};
  14. const usedRules = new Set(Object.keys(configRules));
  15. usedRules.add('all');
  16. const rangeData = stylelintResult.disabledRanges;
  17. const disabledRules = Object.keys(rangeData);
  18. disabledRules.forEach((rule) => {
  19. if (usedRules.has(rule)) return;
  20. if (enabled === optionsMatches(options, 'except', rule)) return;
  21. rangeData[rule].forEach((range) => {
  22. if (!range.strictStart && !range.strictEnd) return;
  23. // If the comment doesn't have a location, we can't report a useful error.
  24. // In practice we expect all comments to have locations, though.
  25. if (!range.comment.source || !range.comment.source.start) return;
  26. result.warnings.push({
  27. text: `Rule "${rule}" isn't enabled`,
  28. rule: '--report-invalid-scope-disables',
  29. line: range.comment.source.start.line,
  30. column: range.comment.source.start.column,
  31. severity: options.severity,
  32. });
  33. });
  34. });
  35. });
  36. };