.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / tslint / lib / formatters / tapFormatter.js
1 "use strict";
2 /**
3  * @license
4  * Copyright 2017 Palantir Technologies, Inc.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 Object.defineProperty(exports, "__esModule", { value: true });
19 var tslib_1 = require("tslib");
20 var abstractFormatter_1 = require("../language/formatter/abstractFormatter");
21 var Utils = require("../utils");
22 var Formatter = /** @class */ (function (_super) {
23     tslib_1.__extends(Formatter, _super);
24     function Formatter() {
25         return _super !== null && _super.apply(this, arguments) || this;
26     }
27     /* tslint:enable:object-literal-sort-keys */
28     Formatter.prototype.format = function (failures) {
29         var output = ["TAP version 13"];
30         output =
31             failures.length === 0
32                 ? output.concat(["1..0 # SKIP No failures"])
33                 : output.concat(["1.." + failures.length]).concat(this.mapToMessages(failures));
34         return output.join("\n") + "\n";
35     };
36     Formatter.prototype.mapToMessages = function (failures) {
37         return failures.map(function (failure, i) {
38             var fileName = failure.getFileName();
39             var failureString = failure.getFailure();
40             var ruleName = failure.getRuleName();
41             var failureMessage = failure.getFailure();
42             var failureSeverity = failure.getRuleSeverity();
43             var failureRaw = failure.getRawLines();
44             var lineAndCharacter = failure.getStartPosition().getLineAndCharacter();
45             return Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n                not ok ", " - ", "\n                  ---\n                  message : ", "\n                  severity: ", "\n                  data:\n                    ruleName: ", "\n                    fileName: ", "\n                    line: ", "\n                    character: ", "\n                    failureString: ", "\n                    rawLines: ", "\n                  ..."], ["\n                not ok ", " - ", "\n                  ---\n                  message : ", "\n                  severity: ", "\n                  data:\n                    ruleName: ", "\n                    fileName: ", "\n                    line: ", "\n                    character: ", "\n                    failureString: ", "\n                    rawLines: ", "\n                  ..."])), String(i + 1), failureMessage, failureMessage, failureSeverity, ruleName, fileName, String(lineAndCharacter.line), String(lineAndCharacter.character), failureString, failureRaw);
46         });
47     };
48     /* tslint:disable:object-literal-sort-keys */
49     Formatter.metadata = {
50         formatterName: "tap",
51         description: "Formats output as TAP stream.",
52         descriptionDetails: "Provides error messages output in TAP13 format which can be consumed by any TAP formatter.",
53         sample: Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n            TAP version 13\n            1..1\n            not ok 1 - Some error\n              ---\n              message: Variable has any type\n              severity: error\n              data:\n                 ruleName: no-any\n                 fileName: test-file.ts\n                 line: 10\n                 character: 10\n                 failureString: Some error\n                 rawLines: Some raw output\n              ..."], ["\n            TAP version 13\n            1..1\n            not ok 1 - Some error\n              ---\n              message: Variable has any type\n              severity: error\n              data:\n                 ruleName: no-any\n                 fileName: test-file.ts\n                 line: 10\n                 character: 10\n                 failureString: Some error\n                 rawLines: Some raw output\n              ..."]))),
54         consumer: "machine",
55     };
56     return Formatter;
57 }(abstractFormatter_1.AbstractFormatter));
58 exports.Formatter = Formatter;
59 var templateObject_1, templateObject_2;