DefaultFormatter.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. "use strict";
  2. var __importStar = (this && this.__importStar) || function (mod) {
  3. if (mod && mod.__esModule) return mod;
  4. var result = {};
  5. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  6. result["default"] = mod;
  7. return result;
  8. };
  9. var __importDefault = (this && this.__importDefault) || function (mod) {
  10. return (mod && mod.__esModule) ? mod : { "default": mod };
  11. };
  12. Object.defineProperty(exports, "__esModule", { value: true });
  13. var os = __importStar(require("os"));
  14. var chalk_1 = __importDefault(require("chalk"));
  15. var issue_1 = require("../issue");
  16. var InternalFormatter_1 = require("./InternalFormatter");
  17. function createDefaultFormatter() {
  18. return function defaultFormatter(issue) {
  19. var color = {
  20. message: issue.severity === issue_1.IssueSeverity.WARNING
  21. ? chalk_1.default.bold.yellow
  22. : chalk_1.default.bold.red,
  23. position: chalk_1.default.bold.cyan,
  24. code: chalk_1.default.grey
  25. };
  26. if (issue.origin === issue_1.IssueOrigin.INTERNAL) {
  27. return InternalFormatter_1.createInternalFormatter()(issue);
  28. }
  29. var code = issue.origin === issue_1.IssueOrigin.TYPESCRIPT ? "TS" + issue.code : issue.code;
  30. return [
  31. color.message(issue.severity.toUpperCase() + " in ") +
  32. color.position(issue.file + "(" + issue.line + "," + issue.character + ")") +
  33. color.message(':'),
  34. color.code(code + ': ') + issue.message
  35. ].join(os.EOL);
  36. };
  37. }
  38. exports.createDefaultFormatter = createDefaultFormatter;
  39. //# sourceMappingURL=DefaultFormatter.js.map