diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-08-14 05:01:11 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-08-14 05:02:09 +0200 |
commit | 363723fc84f7b8477592e0105aeb331ec9a017af (patch) | |
tree | 29f92724f34131bac64d6a318dd7e30612e631c7 /node_modules/tslint/lib/rules/quotemarkRule.js | |
parent | 5634e77ad96bfe1818f6b6ee70b7379652e5487f (diff) |
node_modules
Diffstat (limited to 'node_modules/tslint/lib/rules/quotemarkRule.js')
-rw-r--r-- | node_modules/tslint/lib/rules/quotemarkRule.js | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/node_modules/tslint/lib/rules/quotemarkRule.js b/node_modules/tslint/lib/rules/quotemarkRule.js index 4226e8ed1..1f1a76b4c 100644 --- a/node_modules/tslint/lib/rules/quotemarkRule.js +++ b/node_modules/tslint/lib/rules/quotemarkRule.js @@ -19,6 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var tsutils_1 = require("tsutils"); var ts = require("typescript"); +var error_1 = require("../error"); var Lint = require("../index"); var OPTION_SINGLE = "single"; var OPTION_DOUBLE = "double"; @@ -42,7 +43,8 @@ var Rule = (function (_super) { var args = this.ruleArguments; if (args.length > 0) { if (args[0] !== OPTION_SINGLE && args[0] !== OPTION_DOUBLE) { - throw new Error("First argument to 'quotemark' rule should be \"" + OPTION_SINGLE + "\" or \"" + OPTION_DOUBLE + "\""); + error_1.showWarningOnce("Warning: First argument to 'quotemark' rule should be \"" + OPTION_SINGLE + "\" or \"" + OPTION_DOUBLE + "\""); + return []; } } var quoteMark = args[0] === OPTION_SINGLE ? "'" : '"'; @@ -56,30 +58,30 @@ var Rule = (function (_super) { return args.indexOf(name) !== -1; } }; + /* tslint:disable:object-literal-sort-keys */ + Rule.metadata = { + ruleName: "quotemark", + description: "Requires single or double quotes for string literals.", + hasFix: true, + optionsDescription: (_a = ["\n Five arguments may be optionally provided:\n\n * `\"", "\"` enforces single quotes.\n * `\"", "\"` enforces double quotes.\n * `\"", "\"` enforces single quotes for JSX attributes.\n * `\"", "\"` enforces double quotes for JSX attributes.\n * `\"", "\"` forbids single-line untagged template strings that do not contain string interpolations.\n * `\"", "\"` allows you to use the \"other\" quotemark in cases where escaping would normally be required.\n For example, `[true, \"", "\", \"", "\"]` would not report a failure on the string literal\n `'Hello \"World\"'`."], _a.raw = ["\n Five arguments may be optionally provided:\n\n * \\`\"", "\"\\` enforces single quotes.\n * \\`\"", "\"\\` enforces double quotes.\n * \\`\"", "\"\\` enforces single quotes for JSX attributes.\n * \\`\"", "\"\\` enforces double quotes for JSX attributes.\n * \\`\"", "\"\\` forbids single-line untagged template strings that do not contain string interpolations.\n * \\`\"", "\"\\` allows you to use the \"other\" quotemark in cases where escaping would normally be required.\n For example, \\`[true, \"", "\", \"", "\"]\\` would not report a failure on the string literal\n \\`'Hello \"World\"'\\`."], Lint.Utils.dedent(_a, OPTION_SINGLE, OPTION_DOUBLE, OPTION_JSX_SINGLE, OPTION_JSX_DOUBLE, OPTION_AVOID_TEMPLATE, OPTION_AVOID_ESCAPE, OPTION_DOUBLE, OPTION_AVOID_ESCAPE)), + options: { + type: "array", + items: { + type: "string", + enum: [OPTION_SINGLE, OPTION_DOUBLE, OPTION_JSX_SINGLE, OPTION_JSX_DOUBLE, OPTION_AVOID_ESCAPE], + }, + minLength: 0, + maxLength: 5, + }, + optionExamples: [ + [true, OPTION_SINGLE, OPTION_AVOID_ESCAPE, OPTION_AVOID_TEMPLATE], + [true, OPTION_SINGLE, OPTION_JSX_DOUBLE], + ], + type: "style", + typescriptOnly: false, + }; return Rule; }(Lint.Rules.AbstractRule)); -/* tslint:disable:object-literal-sort-keys */ -Rule.metadata = { - ruleName: "quotemark", - description: "Requires single or double quotes for string literals.", - hasFix: true, - optionsDescription: (_a = ["\n Five arguments may be optionally provided:\n\n * `\"", "\"` enforces single quotes.\n * `\"", "\"` enforces double quotes.\n * `\"", "\"` enforces single quotes for JSX attributes.\n * `\"", "\"` enforces double quotes for JSX attributes.\n * `\"", "\"` forbids single-line untagged template strings that do not contain string interpolations.\n * `\"", "\"` allows you to use the \"other\" quotemark in cases where escaping would normally be required.\n For example, `[true, \"", "\", \"", "\"]` would not report a failure on the string literal\n `'Hello \"World\"'`."], _a.raw = ["\n Five arguments may be optionally provided:\n\n * \\`\"", "\"\\` enforces single quotes.\n * \\`\"", "\"\\` enforces double quotes.\n * \\`\"", "\"\\` enforces single quotes for JSX attributes.\n * \\`\"", "\"\\` enforces double quotes for JSX attributes.\n * \\`\"", "\"\\` forbids single-line untagged template strings that do not contain string interpolations.\n * \\`\"", "\"\\` allows you to use the \"other\" quotemark in cases where escaping would normally be required.\n For example, \\`[true, \"", "\", \"", "\"]\\` would not report a failure on the string literal\n \\`'Hello \"World\"'\\`."], Lint.Utils.dedent(_a, OPTION_SINGLE, OPTION_DOUBLE, OPTION_JSX_SINGLE, OPTION_JSX_DOUBLE, OPTION_AVOID_TEMPLATE, OPTION_AVOID_ESCAPE, OPTION_DOUBLE, OPTION_AVOID_ESCAPE)), - options: { - type: "array", - items: { - type: "string", - enum: [OPTION_SINGLE, OPTION_DOUBLE, OPTION_JSX_SINGLE, OPTION_JSX_DOUBLE, OPTION_AVOID_ESCAPE], - }, - minLength: 0, - maxLength: 5, - }, - optionExamples: [ - [true, OPTION_SINGLE, OPTION_AVOID_ESCAPE, OPTION_AVOID_TEMPLATE], - [true, OPTION_SINGLE, OPTION_JSX_DOUBLE], - ], - type: "style", - typescriptOnly: false, -}; exports.Rule = Rule; function walk(ctx) { var sourceFile = ctx.sourceFile, options = ctx.options; |