aboutsummaryrefslogtreecommitdiff
path: root/node_modules/tslint/lib/formatters
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/tslint/lib/formatters')
-rw-r--r--node_modules/tslint/lib/formatters/codeFrameFormatter.js9
-rw-r--r--node_modules/tslint/lib/formatters/index.d.ts1
-rw-r--r--node_modules/tslint/lib/formatters/index.js2
-rw-r--r--node_modules/tslint/lib/formatters/junitFormatter.d.ts24
-rw-r--r--node_modules/tslint/lib/formatters/junitFormatter.js77
-rw-r--r--node_modules/tslint/lib/formatters/msbuildFormatter.js3
-rw-r--r--node_modules/tslint/lib/formatters/proseFormatter.js1
-rw-r--r--node_modules/tslint/lib/formatters/stylishFormatter.js13
-rw-r--r--node_modules/tslint/lib/formatters/verboseFormatter.js1
-rw-r--r--node_modules/tslint/lib/formatters/vsoFormatter.d.ts2
-rw-r--r--node_modules/tslint/lib/formatters/vsoFormatter.js6
11 files changed, 122 insertions, 17 deletions
diff --git a/node_modules/tslint/lib/formatters/codeFrameFormatter.js b/node_modules/tslint/lib/formatters/codeFrameFormatter.js
index 8a74160d1..c828c5700 100644
--- a/node_modules/tslint/lib/formatters/codeFrameFormatter.js
+++ b/node_modules/tslint/lib/formatters/codeFrameFormatter.js
@@ -19,7 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var abstractFormatter_1 = require("../language/formatter/abstractFormatter");
var codeFrame = require("babel-code-frame");
-var colors = require("colors");
+var chalk = require("chalk");
var Utils = require("../utils");
var Formatter = /** @class */ (function (_super) {
tslib_1.__extends(Formatter, _super);
@@ -31,6 +31,7 @@ var Formatter = /** @class */ (function (_super) {
if (typeof failures[0] === "undefined") {
return "\n";
}
+ failures = this.sortFailures(failures);
var outputLines = [];
var currentFile;
for (var _i = 0, failures_1 = failures; _i < failures_1.length; _i++) {
@@ -43,15 +44,15 @@ var Formatter = /** @class */ (function (_super) {
currentFile = fileName;
}
var failureString = failure.getFailure();
- failureString = colors.red(failureString);
+ failureString = chalk.red(failureString);
// Rule
var ruleName = failure.getRuleName();
- ruleName = colors.gray("(" + ruleName + ")");
+ ruleName = chalk.gray("(" + ruleName + ")");
// Frame
var lineAndCharacter = failure.getStartPosition().getLineAndCharacter();
var frame = codeFrame(failure.getRawLines(), lineAndCharacter.line + 1, // babel-code-frame is 1 index
lineAndCharacter.character, {
- forceColor: colors.enabled,
+ forceColor: chalk.enabled,
highlightCode: true,
});
// Ouput
diff --git a/node_modules/tslint/lib/formatters/index.d.ts b/node_modules/tslint/lib/formatters/index.d.ts
index e954e1705..ea60b24d6 100644
--- a/node_modules/tslint/lib/formatters/index.d.ts
+++ b/node_modules/tslint/lib/formatters/index.d.ts
@@ -22,3 +22,4 @@ export { Formatter as StylishFormatter } from "./stylishFormatter";
export { Formatter as FileslistFormatter } from "./fileslistFormatter";
export { Formatter as CodeFrameFormatter } from "./codeFrameFormatter";
export { Formatter as TapFormatter } from "./tapFormatter";
+export { Formatter as JUnitFormatter } from "./junitFormatter";
diff --git a/node_modules/tslint/lib/formatters/index.js b/node_modules/tslint/lib/formatters/index.js
index 213f23ddb..fd46be3ad 100644
--- a/node_modules/tslint/lib/formatters/index.js
+++ b/node_modules/tslint/lib/formatters/index.js
@@ -32,3 +32,5 @@ var codeFrameFormatter_1 = require("./codeFrameFormatter");
exports.CodeFrameFormatter = codeFrameFormatter_1.Formatter;
var tapFormatter_1 = require("./tapFormatter");
exports.TapFormatter = tapFormatter_1.Formatter;
+var junitFormatter_1 = require("./junitFormatter");
+exports.JUnitFormatter = junitFormatter_1.Formatter;
diff --git a/node_modules/tslint/lib/formatters/junitFormatter.d.ts b/node_modules/tslint/lib/formatters/junitFormatter.d.ts
new file mode 100644
index 000000000..8c6b27056
--- /dev/null
+++ b/node_modules/tslint/lib/formatters/junitFormatter.d.ts
@@ -0,0 +1,24 @@
+/**
+ * @license
+ * Copyright 2016 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { AbstractFormatter } from "../language/formatter/abstractFormatter";
+import { IFormatterMetadata } from "../language/formatter/formatter";
+import { RuleFailure } from "../language/rule/rule";
+export declare class Formatter extends AbstractFormatter {
+ static metadata: IFormatterMetadata;
+ format(failures: RuleFailure[]): string;
+ private escapeXml(str);
+}
diff --git a/node_modules/tslint/lib/formatters/junitFormatter.js b/node_modules/tslint/lib/formatters/junitFormatter.js
new file mode 100644
index 000000000..9e47ae89c
--- /dev/null
+++ b/node_modules/tslint/lib/formatters/junitFormatter.js
@@ -0,0 +1,77 @@
+"use strict";
+/**
+ * @license
+ * Copyright 2016 Palantir Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+Object.defineProperty(exports, "__esModule", { value: true });
+var tslib_1 = require("tslib");
+var abstractFormatter_1 = require("../language/formatter/abstractFormatter");
+var Utils = require("../utils");
+var Formatter = /** @class */ (function (_super) {
+ tslib_1.__extends(Formatter, _super);
+ function Formatter() {
+ return _super !== null && _super.apply(this, arguments) || this;
+ }
+ /* tslint:enable:object-literal-sort-keys */
+ Formatter.prototype.format = function (failures) {
+ var output = '<?xml version="1.0" encoding="utf-8"?><testsuites package="tslint">';
+ if (failures.length !== 0) {
+ var failuresSorted = failures.sort(function (a, b) { return a.getFileName().localeCompare(b.getFileName()); });
+ var previousFilename = null;
+ for (var _i = 0, failuresSorted_1 = failuresSorted; _i < failuresSorted_1.length; _i++) {
+ var failure = failuresSorted_1[_i];
+ var lineAndCharacter = failure.getStartPosition().getLineAndCharacter();
+ var message = this.escapeXml(failure.getFailure());
+ var rule = this.escapeXml(failure.getRuleName());
+ var severity = failure.getRuleSeverity();
+ if (failure.getFileName() !== previousFilename) {
+ if (previousFilename !== null) {
+ output += "</testsuite>";
+ }
+ previousFilename = failure.getFileName();
+ output += "<testsuite name=\"" + this.escapeXml(failure.getFileName()) + "\">";
+ }
+ output += "<testcase name=\"Line " + (lineAndCharacter.line + 1) + ", ";
+ output += "Column " + (lineAndCharacter.character + 1) + ": " + rule + "\">";
+ output += "<failure type=\"" + severity + "\">" + message + "</failure>";
+ output += "</testcase>";
+ }
+ if (previousFilename !== null) {
+ output += "</testsuite>";
+ }
+ }
+ output += "</testsuites>";
+ return output;
+ };
+ Formatter.prototype.escapeXml = function (str) {
+ return str
+ .replace(/&/g, "&amp;")
+ .replace(/</g, "&lt;")
+ .replace(/>/g, "&gt;")
+ .replace(/'/g, "&#39;")
+ .replace(/"/g, "&quot;");
+ };
+ /* tslint:disable:object-literal-sort-keys */
+ Formatter.metadata = {
+ formatterName: "junit",
+ description: "Formats errors as through they were JUnit output.",
+ descriptionDetails: (_a = ["\n Imitates the JUnit XML Output"], _a.raw = ["\n Imitates the JUnit XML Output"], Utils.dedent(_a)),
+ sample: (_b = ["\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <testsuites package=\"tslint\">\n <testsuite name=\"myFile.ts\">\n <testcase name=\"Line 1, Column 14: semicolon\">\n <failure type=\"warning\">Missing semicolon</failure>\n </testcase>\n </testsuite>\n </testsuites>\n "], _b.raw = ["\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <testsuites package=\"tslint\">\n <testsuite name=\"myFile.ts\">\n <testcase name=\"Line 1, Column 14: semicolon\">\n <failure type=\"warning\">Missing semicolon</failure>\n </testcase>\n </testsuite>\n </testsuites>\n "], Utils.dedent(_b)),
+ consumer: "machine",
+ };
+ return Formatter;
+}(abstractFormatter_1.AbstractFormatter));
+exports.Formatter = Formatter;
+var _a, _b;
diff --git a/node_modules/tslint/lib/formatters/msbuildFormatter.js b/node_modules/tslint/lib/formatters/msbuildFormatter.js
index b6335e02a..9edc2d9c6 100644
--- a/node_modules/tslint/lib/formatters/msbuildFormatter.js
+++ b/node_modules/tslint/lib/formatters/msbuildFormatter.js
@@ -42,11 +42,10 @@ var Formatter = /** @class */ (function (_super) {
Formatter.metadata = {
formatterName: "msbuild",
description: "Formats errors for consumption by msbuild.",
- descriptionDetails: (_a = ["\n The output is compatible with both msbuild and Visual Studio. All failures have the\n 'warning' severity."], _a.raw = ["\n The output is compatible with both msbuild and Visual Studio. All failures have the\n 'warning' severity."], utils_1.dedent(_a)),
+ descriptionDetails: "The output is compatible with both msbuild and Visual Studio.",
sample: "myFile.ts(1,14): warning: Missing semicolon",
consumer: "machine",
};
return Formatter;
}(abstractFormatter_1.AbstractFormatter));
exports.Formatter = Formatter;
-var _a;
diff --git a/node_modules/tslint/lib/formatters/proseFormatter.js b/node_modules/tslint/lib/formatters/proseFormatter.js
index 02b33e4cd..ca73001a3 100644
--- a/node_modules/tslint/lib/formatters/proseFormatter.js
+++ b/node_modules/tslint/lib/formatters/proseFormatter.js
@@ -28,6 +28,7 @@ var Formatter = /** @class */ (function (_super) {
if (failures.length === 0 && (fixes === undefined || fixes.length === 0)) {
return "\n";
}
+ failures = this.sortFailures(failures);
var fixLines = [];
if (fixes !== undefined) {
var perFileFixes = new Map();
diff --git a/node_modules/tslint/lib/formatters/stylishFormatter.js b/node_modules/tslint/lib/formatters/stylishFormatter.js
index 7c142c9e7..d3a2603c1 100644
--- a/node_modules/tslint/lib/formatters/stylishFormatter.js
+++ b/node_modules/tslint/lib/formatters/stylishFormatter.js
@@ -18,7 +18,7 @@
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var abstractFormatter_1 = require("../language/formatter/abstractFormatter");
-var colors = require("colors");
+var chalk = require("chalk");
var Utils = require("../utils");
var Formatter = /** @class */ (function (_super) {
tslib_1.__extends(Formatter, _super);
@@ -27,6 +27,7 @@ var Formatter = /** @class */ (function (_super) {
}
/* tslint:enable:object-literal-sort-keys */
Formatter.prototype.format = function (failures) {
+ failures = this.sortFailures(failures);
var outputLines = this.mapToMessages(failures);
// Removes initial blank line
if (outputLines[0] === "") {
@@ -52,18 +53,18 @@ var Formatter = /** @class */ (function (_super) {
currentFile = fileName;
}
var failureString = failure.getFailure();
- failureString = colors.yellow(failureString);
+ failureString = chalk.yellow(failureString);
// Rule
var ruleName = failure.getRuleName();
ruleName = this.pad(ruleName, ruleMaxSize);
- ruleName = colors.grey(ruleName);
+ ruleName = chalk.grey(ruleName);
// Lines
var lineAndCharacter = failure.getStartPosition().getLineAndCharacter();
var positionTuple = lineAndCharacter.line + 1 + ":" + (lineAndCharacter.character + 1);
positionTuple = this.pad(positionTuple, positionMaxSize);
positionTuple = failure.getRuleSeverity() === "warning"
- ? colors.blue(failure.getRuleSeverity().toUpperCase() + ": " + positionTuple)
- : colors.red(failure.getRuleSeverity().toUpperCase() + ": " + positionTuple);
+ ? chalk.blue(failure.getRuleSeverity().toUpperCase() + ": " + positionTuple)
+ : chalk.red(failure.getRuleSeverity().toUpperCase() + ": " + positionTuple);
// Output
var output = positionTuple + " " + ruleName + " " + failureString;
outputLines.push(output);
@@ -101,7 +102,7 @@ var Formatter = /** @class */ (function (_super) {
Formatter.metadata = {
formatterName: "stylish",
description: "Human-readable formatter which creates stylish messages.",
- descriptionDetails: (_a = ["\n The output matches that produced by eslint's stylish formatter. Its readability\n enhanced through spacing and colouring"], _a.raw = ["\n The output matches that produced by eslint's stylish formatter. Its readability\n enhanced through spacing and colouring"], Utils.dedent(_a)),
+ descriptionDetails: (_a = ["\n The output matches what is produced by ESLint's stylish formatter.\n Its readability is enhanced through spacing and colouring."], _a.raw = ["\n The output matches what is produced by ESLint's stylish formatter.\n Its readability is enhanced through spacing and colouring."], Utils.dedent(_a)),
sample: (_b = ["\n myFile.ts\n 1:14 semicolon Missing semicolon"], _b.raw = ["\n myFile.ts\n 1:14 semicolon Missing semicolon"], Utils.dedent(_b)),
consumer: "human",
};
diff --git a/node_modules/tslint/lib/formatters/verboseFormatter.js b/node_modules/tslint/lib/formatters/verboseFormatter.js
index d681a7192..eeea7310b 100644
--- a/node_modules/tslint/lib/formatters/verboseFormatter.js
+++ b/node_modules/tslint/lib/formatters/verboseFormatter.js
@@ -25,6 +25,7 @@ var Formatter = /** @class */ (function (_super) {
}
/* tslint:enable:object-literal-sort-keys */
Formatter.prototype.format = function (failures) {
+ failures = this.sortFailures(failures);
return this.mapToMessages(failures).join("\n") + "\n";
};
Formatter.prototype.mapToMessages = function (failures) {
diff --git a/node_modules/tslint/lib/formatters/vsoFormatter.d.ts b/node_modules/tslint/lib/formatters/vsoFormatter.d.ts
index d5ebd9f2b..6227c2b8c 100644
--- a/node_modules/tslint/lib/formatters/vsoFormatter.d.ts
+++ b/node_modules/tslint/lib/formatters/vsoFormatter.d.ts
@@ -19,5 +19,5 @@ import { IFormatterMetadata } from "../language/formatter/formatter";
import { RuleFailure } from "../language/rule/rule";
export declare class Formatter extends AbstractFormatter {
static metadata: IFormatterMetadata;
- format(failures: RuleFailure[], warnings?: RuleFailure[]): string;
+ format(failures: RuleFailure[]): string;
}
diff --git a/node_modules/tslint/lib/formatters/vsoFormatter.js b/node_modules/tslint/lib/formatters/vsoFormatter.js
index 1e0b35659..b98fa428d 100644
--- a/node_modules/tslint/lib/formatters/vsoFormatter.js
+++ b/node_modules/tslint/lib/formatters/vsoFormatter.js
@@ -25,10 +25,8 @@ var Formatter = /** @class */ (function (_super) {
return _super !== null && _super.apply(this, arguments) || this;
}
/* tslint:enable:object-literal-sort-keys */
- Formatter.prototype.format = function (failures, warnings) {
- if (warnings === void 0) { warnings = []; }
- var all = failures.concat(warnings);
- var outputLines = all.map(function (failure) {
+ Formatter.prototype.format = function (failures) {
+ var outputLines = failures.map(function (failure) {
var fileName = failure.getFileName();
var failureString = failure.getFailure();
var lineAndCharacter = failure.getStartPosition().getLineAndCharacter();