diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-12-10 21:51:33 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-12-10 21:51:33 +0100 |
commit | 0469abd4a9c9270a1fdc962969e36e63699af8b4 (patch) | |
tree | f9864d4a4148621378958794cbbfdc2393733283 /node_modules/tslint/lib/rules/noTrailingWhitespaceRule.js | |
parent | 6947e79bbc258f7bc96af424ddb71a511f0c15a3 (diff) |
upgrade dependencies
Diffstat (limited to 'node_modules/tslint/lib/rules/noTrailingWhitespaceRule.js')
-rw-r--r-- | node_modules/tslint/lib/rules/noTrailingWhitespaceRule.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/node_modules/tslint/lib/rules/noTrailingWhitespaceRule.js b/node_modules/tslint/lib/rules/noTrailingWhitespaceRule.js index 3531bc9ae..5ad6cbe8a 100644 --- a/node_modules/tslint/lib/rules/noTrailingWhitespaceRule.js +++ b/node_modules/tslint/lib/rules/noTrailingWhitespaceRule.js @@ -24,6 +24,7 @@ var noConsecutiveBlankLinesRule_1 = require("./noConsecutiveBlankLinesRule"); var OPTION_IGNORE_COMMENTS = "ignore-comments"; var OPTION_IGNORE_JSDOC = "ignore-jsdoc"; var OPTION_IGNORE_TEMPLATE_STRINGS = "ignore-template-strings"; +var OPTION_IGNORE_BLANK_LINES = "ignore-blank-lines"; var Rule = /** @class */ (function (_super) { tslib_1.__extends(Rule, _super); function Rule() { @@ -32,6 +33,7 @@ var Rule = /** @class */ (function (_super) { Rule.prototype.apply = function (sourceFile) { var ignoreComments = this.ruleArguments.indexOf(OPTION_IGNORE_COMMENTS) !== -1; return this.applyWithFunction(sourceFile, walk, { + ignoreBlankLines: this.ruleArguments.indexOf(OPTION_IGNORE_BLANK_LINES) !== -1, ignoreComments: ignoreComments, ignoreJsDoc: ignoreComments || this.ruleArguments.indexOf(OPTION_IGNORE_JSDOC) !== -1, ignoreTemplates: this.ruleArguments.indexOf(OPTION_IGNORE_TEMPLATE_STRINGS) !== -1, @@ -42,13 +44,13 @@ var Rule = /** @class */ (function (_super) { ruleName: "no-trailing-whitespace", description: "Disallows trailing whitespace at the end of a line.", rationale: "Keeps version control diffs clean as it prevents accidental whitespace from being committed.", - optionsDescription: (_a = ["\n Possible settings are:\n\n * `\"", "\"`: Allows trailing whitespace in template strings.\n * `\"", "\"`: Allows trailing whitespace in comments.\n * `\"", "\"`: Allows trailing whitespace only in JSDoc comments."], _a.raw = ["\n Possible settings are:\n\n * \\`\"", "\"\\`: Allows trailing whitespace in template strings.\n * \\`\"", "\"\\`: Allows trailing whitespace in comments.\n * \\`\"", "\"\\`: Allows trailing whitespace only in JSDoc comments."], Lint.Utils.dedent(_a, OPTION_IGNORE_TEMPLATE_STRINGS, OPTION_IGNORE_COMMENTS, OPTION_IGNORE_JSDOC)), + optionsDescription: (_a = ["\n Possible settings are:\n\n * `\"", "\"`: Allows trailing whitespace in template strings.\n * `\"", "\"`: Allows trailing whitespace in comments.\n * `\"", "\"`: Allows trailing whitespace only in JSDoc comments.\n * `\"", "\"`: Allows trailing whitespace on empty lines."], _a.raw = ["\n Possible settings are:\n\n * \\`\"", "\"\\`: Allows trailing whitespace in template strings.\n * \\`\"", "\"\\`: Allows trailing whitespace in comments.\n * \\`\"", "\"\\`: Allows trailing whitespace only in JSDoc comments.\n * \\`\"", "\"\\`: Allows trailing whitespace on empty lines."], Lint.Utils.dedent(_a, OPTION_IGNORE_TEMPLATE_STRINGS, OPTION_IGNORE_COMMENTS, OPTION_IGNORE_JSDOC, OPTION_IGNORE_BLANK_LINES)), hasFix: true, options: { type: "array", items: { type: "string", - enum: [OPTION_IGNORE_COMMENTS, OPTION_IGNORE_JSDOC, OPTION_IGNORE_TEMPLATE_STRINGS], + enum: [OPTION_IGNORE_COMMENTS, OPTION_IGNORE_JSDOC, OPTION_IGNORE_TEMPLATE_STRINGS, OPTION_IGNORE_BLANK_LINES], }, }, optionExamples: [ @@ -70,8 +72,9 @@ function walk(ctx) { var text = sourceFile.text; for (var _i = 0, _a = tsutils_1.getLineRanges(sourceFile); _i < _a.length; _i++) { var line = _a[_i]; + // \s matches any whitespace character (equal to [\r\n\t\f\v ]) var match = text.substr(line.pos, line.contentLength).match(/\s+$/); - if (match !== null) { + if (match !== null && !(ctx.options.ignoreBlankLines && match.index === 0)) { possibleFailures.push({ end: line.pos + line.contentLength, pos: line.pos + match.index, |