calcSeverityCounts.cjs 661 B

123456789101112131415161718192021222324252627
  1. // NOTICE: This file is generated by Rollup. To modify it,
  2. // please instead edit the ESM counterpart and rebuild with Rollup (npm run build).
  3. 'use strict';
  4. const constants = require('../constants.cjs');
  5. /**
  6. * @import {Severity} from 'stylelint'
  7. *
  8. * @param {Severity} severity
  9. * @param {Record<Severity, number>} counts
  10. * @returns {void}
  11. */
  12. function calcSeverityCounts(severity, counts) {
  13. switch (severity) {
  14. case constants.SEVERITY_ERROR:
  15. counts.error += 1;
  16. break;
  17. case constants.SEVERITY_WARNING:
  18. counts.warning += 1;
  19. break;
  20. default:
  21. throw new Error(`Unknown severity: "${severity}"`);
  22. }
  23. }
  24. module.exports = calcSeverityCounts;