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.

prepareReturnValue.js 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. 'use strict';
  2. const descriptionlessDisables = require('./descriptionlessDisables');
  3. const invalidScopeDisables = require('./invalidScopeDisables');
  4. const needlessDisables = require('./needlessDisables');
  5. const reportDisables = require('./reportDisables');
  6. /** @typedef {import('stylelint').Formatter} Formatter */
  7. /** @typedef {import('stylelint').StylelintResult} StylelintResult */
  8. /** @typedef {import('stylelint').StylelintStandaloneOptions} StylelintStandaloneOptions */
  9. /** @typedef {import('stylelint').StylelintStandaloneReturnValue} StylelintStandaloneReturnValue */
  10. /**
  11. * @param {StylelintResult[]} stylelintResults
  12. * @param {StylelintStandaloneOptions} options
  13. * @param {Formatter} formatter
  14. *
  15. * @returns {StylelintStandaloneReturnValue}
  16. */
  17. function prepareReturnValue(stylelintResults, options, formatter) {
  18. const { maxWarnings } = options;
  19. reportDisables(stylelintResults);
  20. needlessDisables(stylelintResults);
  21. invalidScopeDisables(stylelintResults);
  22. descriptionlessDisables(stylelintResults);
  23. const errored = stylelintResults.some(
  24. (result) =>
  25. result.errored ||
  26. result.parseErrors.length > 0 ||
  27. result.warnings.some((warning) => warning.severity === 'error'),
  28. );
  29. /** @type {StylelintStandaloneReturnValue} */
  30. const returnValue = {
  31. errored,
  32. results: [],
  33. output: '',
  34. reportedDisables: [],
  35. };
  36. if (maxWarnings !== undefined) {
  37. const foundWarnings = stylelintResults.reduce((count, file) => {
  38. return count + file.warnings.length;
  39. }, 0);
  40. if (foundWarnings > maxWarnings) {
  41. returnValue.maxWarningsExceeded = { maxWarnings, foundWarnings };
  42. }
  43. }
  44. returnValue.output = formatter(stylelintResults, returnValue);
  45. returnValue.results = stylelintResults;
  46. return returnValue;
  47. }
  48. module.exports = prepareReturnValue;