issue-match.js 1.0 KB

1234567891011121314151617181920
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. exports.createIssuePredicateFromIssueMatch = void 0;
  7. const path_1 = __importDefault(require("path"));
  8. const minimatch_1 = __importDefault(require("minimatch"));
  9. const forward_slash_1 = require("../utils/path/forward-slash");
  10. function createIssuePredicateFromIssueMatch(context, match) {
  11. return (issue) => {
  12. const matchesSeverity = !match.severity || match.severity === issue.severity;
  13. const matchesCode = !match.code || match.code === issue.code;
  14. const matchesFile = !issue.file ||
  15. (!!issue.file &&
  16. (!match.file || (0, minimatch_1.default)((0, forward_slash_1.forwardSlash)(path_1.default.relative(context, issue.file)), match.file)));
  17. return matchesSeverity && matchesCode && matchesFile;
  18. };
  19. }
  20. exports.createIssuePredicateFromIssueMatch = createIssuePredicateFromIssueMatch;