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.

descriptionlessDisables.js 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. 'use strict';
  2. const optionsMatches = require('./utils/optionsMatches');
  3. const validateDisableSettings = require('./validateDisableSettings');
  4. /** @typedef {import('postcss/lib/comment')} PostcssComment */
  5. /** @typedef {import('stylelint').RangeType} RangeType */
  6. /** @typedef {import('stylelint').DisableReportRange} DisableReportRange */
  7. /** @typedef {import('stylelint').StylelintDisableOptionsReport} StylelintDisableOptionsReport */
  8. /**
  9. * @param {import('stylelint').StylelintResult[]} results
  10. */
  11. module.exports = function (results) {
  12. results.forEach((result) => {
  13. const settings = validateDisableSettings(
  14. result._postcssResult,
  15. 'reportDescriptionlessDisables',
  16. );
  17. if (!settings) return;
  18. const [enabled, options, stylelintResult] = settings;
  19. const rangeData = stylelintResult.disabledRanges;
  20. /** @type {Set<PostcssComment>} */
  21. const alreadyReported = new Set();
  22. Object.keys(rangeData).forEach((rule) => {
  23. rangeData[rule].forEach((range) => {
  24. if (range.description) return;
  25. if (alreadyReported.has(range.comment)) return;
  26. if (enabled === optionsMatches(options, 'except', rule)) {
  27. // An 'all' rule will get copied for each individual rule. If the
  28. // configuration is `[false, {except: ['specific-rule']}]`, we
  29. // don't want to report the copies that match except, so we record
  30. // the comment as already reported.
  31. if (!enabled && rule === 'all') alreadyReported.add(range.comment);
  32. return;
  33. }
  34. alreadyReported.add(range.comment);
  35. // If the comment doesn't have a location, we can't report a useful error.
  36. // In practice we expect all comments to have locations, though.
  37. if (!range.comment.source || !range.comment.source.start) return;
  38. result.warnings.push({
  39. text: `Disable for "${rule}" is missing a description`,
  40. rule: '--report-descriptionless-disables',
  41. line: range.comment.source.start.line,
  42. column: range.comment.source.start.column,
  43. severity: options.severity,
  44. });
  45. });
  46. });
  47. });
  48. };