calcSeverityCounts.js 429 B

123456789101112131415161718192021
  1. 'use strict';
  2. /**
  3. * @typedef {import('stylelint').Severity} Severity
  4. *
  5. * @param {Severity} severity
  6. * @param {Record<Severity, number>} counts
  7. * @returns {void}
  8. */
  9. module.exports = function calcSeverityCounts(severity, counts) {
  10. switch (severity) {
  11. case 'error':
  12. counts.error += 1;
  13. break;
  14. case 'warning':
  15. counts.warning += 1;
  16. break;
  17. default:
  18. throw new Error(`Unknown severity: "${severity}"`);
  19. }
  20. };