Socket
Socket
Sign inDemoInstall

tslint

Package Overview
Dependencies
Maintainers
1
Versions
182
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tslint - npm Package Compare versions

Comparing version 5.9.1 to 5.10.0

lib/rules/code-examples/curly.examples.d.ts

1

lib/configs/all.d.ts

@@ -148,2 +148,3 @@ export declare const rules: {

"prefer-template": boolean;
"prefer-while": boolean;
"quotemark": (string | boolean)[];

@@ -150,0 +151,0 @@ "return-undefined": boolean;

@@ -227,2 +227,3 @@ "use strict";

"prefer-template": true,
"prefer-while": true,
"quotemark": [

@@ -229,0 +230,0 @@ true,

2

lib/enableDisableRules.js

@@ -86,3 +86,3 @@ "use strict";

}
else {
else { // disable
if (disableRanges === undefined) {

@@ -89,0 +89,0 @@ map.set(ruleName, [{ pos: start, end: end }]);

@@ -23,1 +23,2 @@ /**

export declare function showWarningOnce(message: string): void;
export declare function showRuleCrashWarning(message: string, ruleName: string, fileName: string): void;

@@ -50,1 +50,5 @@ "use strict";

exports.showWarningOnce = showWarningOnce;
function showRuleCrashWarning(message, ruleName, fileName) {
console.warn("The '" + ruleName + "' rule threw an error in '" + fileName + "':\n" + message);
}
exports.showRuleCrashWarning = showRuleCrashWarning;

@@ -76,5 +76,15 @@ /**

typescriptOnly: boolean;
/**
* Examples demonstrating what the lint rule will pass and fail
*/
codeExamples?: ICodeExample[];
}
export declare type RuleType = "functionality" | "maintainability" | "style" | "typescript";
export declare type RuleSeverity = "warning" | "error" | "off";
export interface ICodeExample {
config: string;
description: string;
pass: string;
fail?: string;
}
export interface IOptions {

@@ -81,0 +91,0 @@ ruleArguments: any[];

@@ -202,6 +202,6 @@ "use strict";

if (error_1.isError(error) && error.stack !== undefined) {
error_1.showWarningOnce(error.stack);
error_1.showRuleCrashWarning(error.stack, rule.getOptions().ruleName, sourceFile.fileName);
}
else {
error_1.showWarningOnce(String(error));
error_1.showRuleCrashWarning(String(error), rule.getOptions().ruleName, sourceFile.fileName);
}

@@ -231,3 +231,3 @@ return [];

};
Linter.VERSION = "5.9.1";
Linter.VERSION = "5.10.0";
Linter.findConfiguration = configuration_1.findConfiguration;

@@ -234,0 +234,0 @@ Linter.findConfigurationPath = configuration_1.findConfigurationPath;

@@ -64,3 +64,4 @@ "use strict";

if (rules.length === 0) {
error_1.showWarningOnce("No valid rules have been specified");
var fileType = isJs ? "JavaScript" : "TypeScript";
error_1.showWarningOnce("No valid rules have been specified for " + fileType + " files");
}

@@ -67,0 +68,0 @@ return rules;

@@ -47,4 +47,4 @@ "use strict";

hasFix: true,
rationale: "Helps maintain a readable, consistent style in your codebase.",
optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Five arguments may be optionally provided:\n\n * `\"", "\"` checks alignment of function parameters.\n * `\"", "\"` checks alignment of function call arguments.\n * `\"", "\"` checks alignment of statements.\n * `\"", "\"` checks alignment of members of classes, interfaces, type literal, object literals and\n object destructuring.\n * `\"", "\"` checks alignment of elements of array iterals, array destructuring and tuple types."], ["\n Five arguments may be optionally provided:\n\n * \\`\"", "\"\\` checks alignment of function parameters.\n * \\`\"", "\"\\` checks alignment of function call arguments.\n * \\`\"", "\"\\` checks alignment of statements.\n * \\`\"", "\"\\` checks alignment of members of classes, interfaces, type literal, object literals and\n object destructuring.\n * \\`\"", "\"\\` checks alignment of elements of array iterals, array destructuring and tuple types."])), OPTION_PARAMETERS, OPTION_ARGUMENTS, OPTION_STATEMENTS, OPTION_MEMBERS, OPTION_ELEMENTS),
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Helps maintain a readable, consistent style in your codebase.\n\n Consistent alignment for code statements helps keep code readable and clear.\n Statements misaligned from the standard can be harder to read and understand."], ["\n Helps maintain a readable, consistent style in your codebase.\n\n Consistent alignment for code statements helps keep code readable and clear.\n Statements misaligned from the standard can be harder to read and understand."]))),
optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Five arguments may be optionally provided:\n\n * `\"", "\"` checks alignment of function parameters.\n * `\"", "\"` checks alignment of function call arguments.\n * `\"", "\"` checks alignment of statements.\n * `\"", "\"` checks alignment of members of classes, interfaces, type literal, object literals and\n object destructuring.\n * `\"", "\"` checks alignment of elements of array iterals, array destructuring and tuple types."], ["\n Five arguments may be optionally provided:\n\n * \\`\"", "\"\\` checks alignment of function parameters.\n * \\`\"", "\"\\` checks alignment of function call arguments.\n * \\`\"", "\"\\` checks alignment of statements.\n * \\`\"", "\"\\` checks alignment of members of classes, interfaces, type literal, object literals and\n object destructuring.\n * \\`\"", "\"\\` checks alignment of elements of array iterals, array destructuring and tuple types."])), OPTION_PARAMETERS, OPTION_ARGUMENTS, OPTION_STATEMENTS, OPTION_MEMBERS, OPTION_ELEMENTS),
options: {

@@ -186,2 +186,2 @@ type: "array",

}
var templateObject_1;
var templateObject_1, templateObject_2;

@@ -52,2 +52,3 @@ "use strict";

],
rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n It's unnecessary to include `return` and `{}` brackets in arrow lambdas.\n Leaving them out results in simpler and easier to read code.\n "], ["\n It's unnecessary to include \\`return\\` and \\`{}\\` brackets in arrow lambdas.\n Leaving them out results in simpler and easier to read code.\n "]))),
type: "style",

@@ -102,2 +103,2 @@ typescriptOnly: false,

}
var templateObject_1;
var templateObject_1, templateObject_2;

@@ -45,3 +45,3 @@ "use strict";

optionExamples: [true, [true, "Thenable"]],
rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n While it is valid TypeScript to await a non-Promise-like value (it will resolve immediately),\n this pattern is often a programmer error and the resulting semantics can be unintuitive.\n "], ["\n While it is valid TypeScript to await a non-Promise-like value (it will resolve immediately),\n this pattern is often a programmer error and the resulting semantics can be unintuitive.\n "]))),
rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n While it is valid JavaScript to await a non-Promise-like value (it will resolve immediately),\n this pattern is often a programmer error and the resulting semantics can be unintuitive.\n\n Awaiting non-Promise-like values often is an indication of programmer error, such as\n forgetting to add parenthesis to call a function that returns a Promise.\n "], ["\n While it is valid JavaScript to await a non-Promise-like value (it will resolve immediately),\n this pattern is often a programmer error and the resulting semantics can be unintuitive.\n\n Awaiting non-Promise-like values often is an indication of programmer error, such as\n forgetting to add parenthesis to call a function that returns a Promise.\n "]))),
type: "functionality",

@@ -48,0 +48,0 @@ typescriptOnly: true,

@@ -39,2 +39,3 @@ "use strict";

optionExamples: [true],
rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Expressions like `1 + x` are sometimes referred to as \"Yoda\" expressions because they read\n opposite to how we would normally speak the expression.\n\n Sticking to a consistent grammar for conditions helps keep code readable and understandable.\n "], ["\n Expressions like \\`1 + x\\` are sometimes referred to as \"Yoda\" expressions because they read\n opposite to how we would normally speak the expression.\n\n Sticking to a consistent grammar for conditions helps keep code readable and understandable.\n "]))),
type: "style",

@@ -94,2 +95,2 @@ typescriptOnly: false,

}
var templateObject_1;
var templateObject_1, templateObject_2;

@@ -36,3 +36,3 @@ "use strict";

description: "Enforces PascalCased class and interface names.",
rationale: "Makes it easy to differentiate classes from regular variables at a glance.",
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Makes it easy to differentiate classes from regular variables at a glance.\n\n JavaScript and general programming convention is to refer to classes in PascalCase.\n It's confusing to use camelCase or other conventions for class names.\n "], ["\n Makes it easy to differentiate classes from regular variables at a glance.\n\n JavaScript and general programming convention is to refer to classes in PascalCase.\n It's confusing to use camelCase or other conventions for class names.\n "]))),
optionsDescription: "Not configurable.",

@@ -63,1 +63,2 @@ options: null,

}
var templateObject_1;

@@ -82,2 +82,3 @@ "use strict";

typescriptOnly: false,
hasFix: true,
};

@@ -144,3 +145,3 @@ /* tslint:enable:object-literal-sort-keys */

if (ctx.options.space && commentText[0] !== " ") {
ctx.addFailure(start, end, Rule.LEADING_SPACE_FAILURE);
ctx.addFailure(start, end, Rule.LEADING_SPACE_FAILURE, [Lint.Replacement.appendText(start, " ")]);
}

@@ -147,0 +148,0 @@ if (ctx.options.case === 0 /* None */ ||

@@ -163,4 +163,4 @@ "use strict";

ruleName: "completed-docs",
description: "Enforces documentation for important items be filled out.",
optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n `true` to enable for [", "]],\n or an array with each item in one of two formats:\n\n * `string` to enable for that type\n * `object` keying types to when their documentation is required:\n * `\"", "\"` and `\"", "\"` may specify:\n * `\"", "\"`:\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`:\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * Other types may specify `\"", "\"`:\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * All types may also provide `\"", "\"`\n with members specifying tags that allow the docs to not have a body.\n * `\"", "\"`: Object mapping tags to `RegExp` bodies content allowed to count as complete docs.\n * `\"", "\"`: Array of tags that must only exist to count as complete docs.\n\n Types that may be enabled are:\n\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`"], ["\n \\`true\\` to enable for [", "]],\n or an array with each item in one of two formats:\n\n * \\`string\\` to enable for that type\n * \\`object\\` keying types to when their documentation is required:\n * \\`\"", "\"\\` and \\`\"", "\"\\` may specify:\n * \\`\"", "\"\\`:\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`:\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * Other types may specify \\`\"", "\"\\`:\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * All types may also provide \\`\"", "\"\\`\n with members specifying tags that allow the docs to not have a body.\n * \\`\"", "\"\\`: Object mapping tags to \\`RegExp\\` bodies content allowed to count as complete docs.\n * \\`\"", "\"\\`: Array of tags that must only exist to count as complete docs.\n\n Types that may be enabled are:\n\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`"])), Object.keys(Rule.defaultArguments).join(", "), exports.ARGUMENT_METHODS, exports.ARGUMENT_PROPERTIES, exports.DESCRIPTOR_PRIVACIES, exports.ALL, exports.PRIVACY_PRIVATE, exports.PRIVACY_PROTECTED, exports.PRIVACY_PUBLIC, exports.DESCRIPTOR_LOCATIONS, exports.ALL, exports.LOCATION_INSTANCE, exports.LOCATION_STATIC, exports.DESCRIPTOR_VISIBILITIES, exports.ALL, exports.VISIBILITY_EXPORTED, exports.VISIBILITY_INTERNAL, exports.DESCRIPTOR_TAGS, exports.TAGS_FOR_CONTENT, exports.TAGS_FOR_EXISTENCE, exports.ARGUMENT_CLASSES, exports.ARGUMENT_ENUMS, exports.ARGUMENT_ENUM_MEMBERS, exports.ARGUMENT_FUNCTIONS, exports.ARGUMENT_INTERFACES, exports.ARGUMENT_METHODS, exports.ARGUMENT_NAMESPACES, exports.ARGUMENT_PROPERTIES, exports.ARGUMENT_TYPES, exports.ARGUMENT_VARIABLES),
description: "Enforces JSDoc comments for important items be filled out.",
optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n `true` to enable for `[", "]`,\n or an array with each item in one of two formats:\n\n * `string` to enable for that type\n * `object` keying types to when their documentation is required:\n * `\"", "\"` and `\"", "\"` may specify:\n * `\"", "\"`:\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`:\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * Other types may specify `\"", "\"`:\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * All types may also provide `\"", "\"`\n with members specifying tags that allow the docs to not have a body.\n * `\"", "\"`: Object mapping tags to `RegExp` bodies content allowed to count as complete docs.\n * `\"", "\"`: Array of tags that must only exist to count as complete docs.\n\n Types that may be enabled are:\n\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`\n * `\"", "\"`"], ["\n \\`true\\` to enable for \\`[", "]\\`,\n or an array with each item in one of two formats:\n\n * \\`string\\` to enable for that type\n * \\`object\\` keying types to when their documentation is required:\n * \\`\"", "\"\\` and \\`\"", "\"\\` may specify:\n * \\`\"", "\"\\`:\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`:\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * Other types may specify \\`\"", "\"\\`:\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * All types may also provide \\`\"", "\"\\`\n with members specifying tags that allow the docs to not have a body.\n * \\`\"", "\"\\`: Object mapping tags to \\`RegExp\\` bodies content allowed to count as complete docs.\n * \\`\"", "\"\\`: Array of tags that must only exist to count as complete docs.\n\n Types that may be enabled are:\n\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`\n * \\`\"", "\"\\`"])), Object.keys(Rule.defaultArguments).join(", "), exports.ARGUMENT_METHODS, exports.ARGUMENT_PROPERTIES, exports.DESCRIPTOR_PRIVACIES, exports.ALL, exports.PRIVACY_PRIVATE, exports.PRIVACY_PROTECTED, exports.PRIVACY_PUBLIC, exports.DESCRIPTOR_LOCATIONS, exports.ALL, exports.LOCATION_INSTANCE, exports.LOCATION_STATIC, exports.DESCRIPTOR_VISIBILITIES, exports.ALL, exports.VISIBILITY_EXPORTED, exports.VISIBILITY_INTERNAL, exports.DESCRIPTOR_TAGS, exports.TAGS_FOR_CONTENT, exports.TAGS_FOR_EXISTENCE, exports.ARGUMENT_CLASSES, exports.ARGUMENT_ENUMS, exports.ARGUMENT_ENUM_MEMBERS, exports.ARGUMENT_FUNCTIONS, exports.ARGUMENT_INTERFACES, exports.ARGUMENT_METHODS, exports.ARGUMENT_NAMESPACES, exports.ARGUMENT_PROPERTIES, exports.ARGUMENT_TYPES, exports.ARGUMENT_VARIABLES),
options: {

@@ -227,2 +227,3 @@ type: "array",

],
rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Helps ensure important components are documented.\n\n Note: use this rule sparingly. It's better to have self-documenting names on components with single, consice responsibilities.\n Comments that only restate the names of variables add nothing to code, and can easily become outdated.\n "], ["\n Helps ensure important components are documented.\n\n Note: use this rule sparingly. It's better to have self-documenting names on components with single, consice responsibilities.\n Comments that only restate the names of variables add nothing to code, and can easily become outdated.\n "]))),
type: "style",

@@ -314,3 +315,3 @@ typescriptOnly: false,

}
var comments = symbol.getDocumentationComment();
var comments = symbol.getDocumentationComment(typeChecker);
checkComments(node, describeNode(nodeType), comments, requirementNode);

@@ -345,3 +346,3 @@ }

}
var templateObject_1;
var templateObject_1, templateObject_2;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;

@@ -23,2 +23,3 @@ "use strict";

var Lint = require("../index");
var curly_examples_1 = require("./code-examples/curly.examples");
var OPTION_AS_NEEDED = "as-needed";

@@ -46,3 +47,3 @@ var OPTION_IGNORE_SAME_LINE = "ignore-same-line";

description: "Enforces braces for `if`/`for`/`do`/`while` statements.",
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n ```ts\n if (foo === bar)\n foo++;\n bar++;\n ```\n\n In the code above, the author almost certainly meant for both `foo++` and `bar++`\n to be executed only if `foo === bar`. However, he forgot braces and `bar++` will be executed\n no matter what. This rule could prevent such a mistake."], ["\n \\`\\`\\`ts\n if (foo === bar)\n foo++;\n bar++;\n \\`\\`\\`\n\n In the code above, the author almost certainly meant for both \\`foo++\\` and \\`bar++\\`\n to be executed only if \\`foo === bar\\`. However, he forgot braces and \\`bar++\\` will be executed\n no matter what. This rule could prevent such a mistake."]))),
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n ```ts\n if (foo === bar)\n foo++;\n bar++;\n ```\n\n In the code above, the author almost certainly meant for both `foo++` and `bar++`\n to be executed only if `foo === bar`. However, they forgot braces and `bar++` will be executed\n no matter what. This rule could prevent such a mistake."], ["\n \\`\\`\\`ts\n if (foo === bar)\n foo++;\n bar++;\n \\`\\`\\`\n\n In the code above, the author almost certainly meant for both \\`foo++\\` and \\`bar++\\`\n to be executed only if \\`foo === bar\\`. However, they forgot braces and \\`bar++\\` will be executed\n no matter what. This rule could prevent such a mistake."]))),
optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n One of the following options may be provided:\n\n * `\"", "\"` forbids any unnecessary curly braces.\n * `\"", "\"` skips checking braces for control-flow statements\n that are on one line and start on the same line as their control-flow keyword\n "], ["\n One of the following options may be provided:\n\n * \\`\"", "\"\\` forbids any unnecessary curly braces.\n * \\`\"", "\"\\` skips checking braces for control-flow statements\n that are on one line and start on the same line as their control-flow keyword\n "])), OPTION_AS_NEEDED, OPTION_IGNORE_SAME_LINE),

@@ -67,2 +68,3 @@ options: {

hasFix: true,
codeExamples: curly_examples_1.codeExamples,
};

@@ -69,0 +71,0 @@ /* tslint:enable:object-literal-sort-keys */

@@ -58,3 +58,3 @@ "use strict";

descriptionDetails: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Cyclomatic complexity is assessed for each function of any type. A starting value of 0\n is assigned and this value is then incremented for every statement which can branch the\n control flow within the function. The following statements and expressions contribute\n to cyclomatic complexity:\n * `catch`\n * `if` and `? :`\n * `||` and `&&` due to short-circuit evaluation\n * `for`, `for in` and `for of` loops\n * `while` and `do while` loops\n * `case` clauses that contain statements"], ["\n Cyclomatic complexity is assessed for each function of any type. A starting value of 0\n is assigned and this value is then incremented for every statement which can branch the\n control flow within the function. The following statements and expressions contribute\n to cyclomatic complexity:\n * \\`catch\\`\n * \\`if\\` and \\`? :\\`\n * \\`||\\` and \\`&&\\` due to short-circuit evaluation\n * \\`for\\`, \\`for in\\` and \\`for of\\` loops\n * \\`while\\` and \\`do while\\` loops\n * \\`case\\` clauses that contain statements"]))),
rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Cyclomatic complexity is a code metric which indicates the level of complexity in a\n function. High cyclomatic complexity indicates confusing code which may be prone to\n errors or difficult to modify."], ["\n Cyclomatic complexity is a code metric which indicates the level of complexity in a\n function. High cyclomatic complexity indicates confusing code which may be prone to\n errors or difficult to modify."]))),
rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Cyclomatic complexity is a code metric which indicates the level of complexity in a\n function. High cyclomatic complexity indicates confusing code which may be prone to\n errors or difficult to modify.\n\n It's better to have smaller, single-purpose functions with self-documenting names."], ["\n Cyclomatic complexity is a code metric which indicates the level of complexity in a\n function. High cyclomatic complexity indicates confusing code which may be prone to\n errors or difficult to modify.\n\n It's better to have smaller, single-purpose functions with self-documenting names."]))),
optionsDescription: Lint.Utils.dedent(templateObject_3 || (templateObject_3 = tslib_1.__makeTemplateObject(["\n An optional upper limit for cyclomatic complexity can be specified. If no limit option\n is provided a default value of ", " will be used."], ["\n An optional upper limit for cyclomatic complexity can be specified. If no limit option\n is provided a default value of ", " will be used."])), Rule.DEFAULT_THRESHOLD),

@@ -61,0 +61,0 @@ options: {

@@ -43,3 +43,3 @@ "use strict";

options: null,
optionExamples: [],
optionExamples: [true],
type: "maintainability",

@@ -156,3 +156,3 @@ typescriptOnly: false,

if (tag.name === "deprecated") {
return tag.text;
return tag.text === undefined ? "" : tag.text;
}

@@ -159,0 +159,0 @@ }

@@ -44,3 +44,3 @@ "use strict";

descriptionDetails: "Fix for single-line files is not supported.",
rationale: "It is a [standard convention](http://stackoverflow.com/q/729692/3124288) to end files with a newline.",
rationale: "It is a [standard convention](https://stackoverflow.com/q/729692/3124288) to end files with a newline.",
optionsDescription: "Not configurable.",

@@ -47,0 +47,0 @@ options: null,

@@ -55,4 +55,4 @@ "use strict";

return lineEnding.repeat(leadingNewlines) + [
"/*"
].concat(commentText.split(/\r?\n/g).map(function (line) { return " * " + line; }), [
"/*!"
].concat(commentText.split(/\r?\n/g).map(function (line) { return (" * " + line).replace(/\s+$/, ""); }), [
" */",

@@ -59,0 +59,0 @@ ]).join(lineEnding) + lineEnding.repeat(trailingNewlines);

@@ -35,3 +35,3 @@ "use strict";

description: "Requires a `for ... in` statement to be filtered with an `if` statement.",
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n ```ts\n for (let key in someObject) {\n if (someObject.hasOwnProperty(key)) {\n // code here\n }\n }\n ```\n Prevents accidental iteration over properties inherited from an object's prototype.\n See [MDN's `for...in`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in)\n documentation for more information about `for...in` loops."], ["\n \\`\\`\\`ts\n for (let key in someObject) {\n if (someObject.hasOwnProperty(key)) {\n // code here\n }\n }\n \\`\\`\\`\n Prevents accidental iteration over properties inherited from an object's prototype.\n See [MDN's \\`for...in\\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in)\n documentation for more information about \\`for...in\\` loops."]))),
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n ```ts\n for (let key in someObject) {\n if (someObject.hasOwnProperty(key)) {\n // code here\n }\n }\n ```\n Prevents accidental iteration over properties inherited from an object's prototype.\n See [MDN's `for...in`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in)\n documentation for more information about `for...in` loops.\n\n Also consider using a [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)\n or [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)\n if you're storing collections of objects.\n Using `Object`s can cause occasional edge case bugs, such as if a key is named \"hasOwnProperty\".\n "], ["\n \\`\\`\\`ts\n for (let key in someObject) {\n if (someObject.hasOwnProperty(key)) {\n // code here\n }\n }\n \\`\\`\\`\n Prevents accidental iteration over properties inherited from an object's prototype.\n See [MDN's \\`for...in\\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in)\n documentation for more information about \\`for...in\\` loops.\n\n Also consider using a [\\`Map\\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)\n or [\\`Set\\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)\n if you're storing collections of objects.\n Using \\`Object\\`s can cause occasional edge case bugs, such as if a key is named \"hasOwnProperty\".\n "]))),
optionsDescription: "Not configurable.",

@@ -38,0 +38,0 @@ options: null,

@@ -58,3 +58,3 @@ "use strict";

rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Limiting the length of a line of code improves code readability.\n It also makes comparing code side-by-side easier and improves compatibility with\n various editors, IDEs, and diff viewers."], ["\n Limiting the length of a line of code improves code readability.\n It also makes comparing code side-by-side easier and improves compatibility with\n various editors, IDEs, and diff viewers."]))),
optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n It can take one argument, which can be any of the following:\n * integer indicating maximum length of lines.\n * object with keys:\n * `limit` - number < 0 defining max line length\n * `ignore-pattern` - string defining ignore pattern for this rule, being parsed by `new RegExp()`.\n For example:\n * `// ` pattern will ignore all in-line comments.\n * `^import ` pattern will ignore all import statements.\n * `^export {(.*?)}` pattern will ignore all multiple export statements.\n * `class [a-zA-Z] implements ` pattern will ignore all class declarations implementing interfaces.\n * `^import |^export {(.*?)}|class [a-zA-Z] implements |// ` pattern will ignore all the cases listed above.\n "], ["\n It can take one argument, which can be any of the following:\n * integer indicating maximum length of lines.\n * object with keys:\n * \\`limit\\` - number < 0 defining max line length\n * \\`ignore-pattern\\` - string defining ignore pattern for this rule, being parsed by \\`new RegExp()\\`.\n For example:\n * \\`\\/\\/ \\` pattern will ignore all in-line comments.\n * \\`^import \\` pattern will ignore all import statements.\n * \\`^export \\{(.*?)\\}\\` pattern will ignore all multiple export statements.\n * \\`class [a-zA-Z] implements \\` pattern will ignore all class declarations implementing interfaces.\n * \\`^import |^export \\{(.*?)\\}|class [a-zA-Z] implements |// \\` pattern will ignore all the cases listed above.\n "]))),
optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n It can take one argument, which can be any of the following:\n * integer indicating maximum length of lines.\n * object with keys:\n * `limit` - number < 0 defining max line length\n * `ignore-pattern` - string defining ignore pattern for this rule, being parsed by `new RegExp()`.\n For example:\n * `// ` pattern will ignore all in-line comments.\n * `^import ` pattern will ignore all import statements.\n * `^export {(.*?)}` pattern will ignore all multiple export statements.\n * `class [a-zA-Z]+ implements ` pattern will ignore all class declarations implementing interfaces.\n * `^import |^export {(.*?)}|class [a-zA-Z]+ implements |// ` pattern will ignore all the cases listed above.\n "], ["\n It can take one argument, which can be any of the following:\n * integer indicating maximum length of lines.\n * object with keys:\n * \\`limit\\` - number < 0 defining max line length\n * \\`ignore-pattern\\` - string defining ignore pattern for this rule, being parsed by \\`new RegExp()\\`.\n For example:\n * \\`\\/\\/ \\` pattern will ignore all in-line comments.\n * \\`^import \\` pattern will ignore all import statements.\n * \\`^export \\{(.*?)\\}\\` pattern will ignore all multiple export statements.\n * \\`class [a-zA-Z]+ implements \\` pattern will ignore all class declarations implementing interfaces.\n * \\`^import |^export \\{(.*?)\\}|class [a-zA-Z]+ implements |// \\` pattern will ignore all the cases listed above.\n "]))),
options: {

@@ -61,0 +61,0 @@ type: "array",

@@ -61,4 +61,4 @@ "use strict";

description: "Requires explicit visibility declarations for class members.",
rationale: "Explicit visibility declarations can make code more readable and accessible for those new to TS.",
optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n These arguments may be optionally provided:\n\n * `\"no-public\"` forbids public accessibility to be specified, because this is the default.\n * `\"check-accessor\"` enforces explicit visibility on get/set accessors\n * `\"check-constructor\"` enforces explicit visibility on constructors\n * `\"check-parameter-property\"` enforces explicit visibility on parameter properties"], ["\n These arguments may be optionally provided:\n\n * \\`\"no-public\"\\` forbids public accessibility to be specified, because this is the default.\n * \\`\"check-accessor\"\\` enforces explicit visibility on get/set accessors\n * \\`\"check-constructor\"\\` enforces explicit visibility on constructors\n * \\`\"check-parameter-property\"\\` enforces explicit visibility on parameter properties"]))),
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Explicit visibility declarations can make code more readable and accessible for those new to TS.\n\n Other languages such as C# default to `private`, unlike TypeScript's default of `public`.\n Members lacking a visibility declaration may be an indication of an accidental leak of class internals.\n "], ["\n Explicit visibility declarations can make code more readable and accessible for those new to TS.\n\n Other languages such as C# default to \\`private\\`, unlike TypeScript's default of \\`public\\`.\n Members lacking a visibility declaration may be an indication of an accidental leak of class internals.\n "]))),
optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n These arguments may be optionally provided:\n\n * `\"no-public\"` forbids public accessibility to be specified, because this is the default.\n * `\"check-accessor\"` enforces explicit visibility on get/set accessors\n * `\"check-constructor\"` enforces explicit visibility on constructors\n * `\"check-parameter-property\"` enforces explicit visibility on parameter properties"], ["\n These arguments may be optionally provided:\n\n * \\`\"no-public\"\\` forbids public accessibility to be specified, because this is the default.\n * \\`\"check-accessor\"\\` enforces explicit visibility on get/set accessors\n * \\`\"check-constructor\"\\` enforces explicit visibility on constructors\n * \\`\"check-parameter-property\"\\` enforces explicit visibility on parameter properties"]))),
options: {

@@ -161,2 +161,2 @@ type: "array",

}
var templateObject_1;
var templateObject_1, templateObject_2;

@@ -128,3 +128,3 @@ "use strict";

description: "Enforces member ordering.",
rationale: "A consistent ordering for class members can make classes easier to read, navigate, and edit.",
rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n A consistent ordering for class members can make classes easier to read, navigate, and edit.\n\n A common opposite practice to `member-ordering` is to keep related groups of classes together.\n Instead of creating clases with multiple separate groups, consider splitting class responsibilities\n apart across multiple single-responsibility classes.\n "], ["\n A consistent ordering for class members can make classes easier to read, navigate, and edit.\n\n A common opposite practice to \\`member-ordering\\` is to keep related groups of classes together.\n Instead of creating clases with multiple separate groups, consider splitting class responsibilities\n apart across multiple single-responsibility classes.\n "]))),
optionsDescription: optionsDescription,

@@ -438,2 +438,2 @@ options: {

}
var templateObject_1;
var templateObject_1, templateObject_2;

@@ -70,6 +70,7 @@ "use strict";

tsutils_1.isElementAccessExpression(expression)) {
(expression = expression.expression);
(_a = expression, expression = _a.expression);
}
return expression.kind === ts.SyntaxKind.CallExpression;
var _a;
}
var templateObject_1, templateObject_2;

@@ -35,3 +35,3 @@ "use strict";

hasFix: false,
rationale: "Using `any` as a type declaration nullifies the compile-time benefits of the type system.",
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Using `any` as a type declaration nullifies the compile-time benefits of the type system.\n\n If you're dealing with data of unknown or \"any\" types, you shouldn't be accessing members of it.\n Either add type annotations for properties that may exist or change the data type to the empty object type `{}`.\n\n Alternately, if you're creating storage or handling for consistent but unknown types, such as in data structures\n or serialization, use `<T>` template types for generic type handling.\n\n Also see the `no-unsafe-any` rule.\n "], ["\n Using \\`any\\` as a type declaration nullifies the compile-time benefits of the type system.\n\n If you're dealing with data of unknown or \"any\" types, you shouldn't be accessing members of it.\n Either add type annotations for properties that may exist or change the data type to the empty object type \\`{}\\`.\n\n Alternately, if you're creating storage or handling for consistent but unknown types, such as in data structures\n or serialization, use \\`<T>\\` template types for generic type handling.\n\n Also see the \\`no-unsafe-any\\` rule.\n "]))),
optionsDescription: "Not configurable.",

@@ -57,1 +57,2 @@ options: null,

}
var templateObject_1;

@@ -43,2 +43,3 @@ "use strict";

optionExamples: [true],
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Comparing boolean values to boolean literals is unnecessary, as those expressions will result in booleans too.\n Just use the boolean values directly or negate them.\n "], ["\n Comparing boolean values to boolean literals is unnecessary, as those expressions will result in booleans too.\n Just use the boolean values directly or negate them.\n "]))),
type: "style",

@@ -123,1 +124,2 @@ typescriptOnly: true,

}
var templateObject_1;

@@ -51,4 +51,4 @@ "use strict";

hasFix: true,
rationale: "Helps maintain a readable style in your codebase.",
optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n An optional number of maximum allowed sequential blanks can be specified. If no value\n is provided, a default of ", " will be used."], ["\n An optional number of maximum allowed sequential blanks can be specified. If no value\n is provided, a default of ", " will be used."])), Rule.DEFAULT_ALLOWED_BLANKS),
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Helps maintain a readable style in your codebase.\n\n Extra blank lines take up extra space and add little to a semantic understanding of the code.\n It can be harder to read through files when fewer components can fit into the screen.\n If you find a file is so large you feel a need to split them up with extra blank lines or comments,\n consider splitting your file into smaller files.\n "], ["\n Helps maintain a readable style in your codebase.\n\n Extra blank lines take up extra space and add little to a semantic understanding of the code.\n It can be harder to read through files when fewer components can fit into the screen.\n If you find a file is so large you feel a need to split them up with extra blank lines or comments,\n consider splitting your file into smaller files.\n "]))),
optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n An optional number of maximum allowed sequential blanks can be specified. If no value\n is provided, a default of ", " will be used."], ["\n An optional number of maximum allowed sequential blanks can be specified. If no value\n is provided, a default of ", " will be used."])), Rule.DEFAULT_ALLOWED_BLANKS),
options: {

@@ -129,2 +129,2 @@ type: "number",

exports.getTemplateRanges = getTemplateRanges;
var templateObject_1;
var templateObject_1, templateObject_2;

@@ -36,3 +36,3 @@ "use strict";

optionsDescription: "Not configurable.",
rationale: "Deleting dynamically computed keys is dangerous and not well optimized.",
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Deleting dynamically computed keys is dangerous and not well optimized.\n\n Also consider using a [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)\n or [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)\n if you're storing collections of objects.\n Using `Object`s can cause occasional edge case bugs, such as if a key is named \"hasOwnProperty\".\n "], ["\n Deleting dynamically computed keys is dangerous and not well optimized.\n\n Also consider using a [\\`Map\\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)\n or [\\`Set\\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)\n if you're storing collections of objects.\n Using \\`Object\\`s can cause occasional edge case bugs, such as if a key is named \"hasOwnProperty\".\n "]))),
ruleName: "no-dynamic-delete",

@@ -96,1 +96,2 @@ type: "functionality",

}
var templateObject_1;

@@ -24,2 +24,3 @@ "use strict";

var ALLOW_EMPTY_CATCH = "allow-empty-catch";
var ALLOW_EMPTY_FUNCTIONS = "allow-empty-functions";
var Rule = /** @class */ (function (_super) {

@@ -33,2 +34,3 @@ tslib_1.__extends(Rule, _super);

allowEmptyCatch: this.ruleArguments.indexOf(ALLOW_EMPTY_CATCH) !== -1,
allowEmptyFunctions: this.ruleArguments.indexOf(ALLOW_EMPTY_FUNCTIONS) !== -1,
});

@@ -42,8 +44,24 @@ };

rationale: "Empty blocks are often indicators of missing code.",
optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n If `", "` is specified, then catch blocks are allowed to be empty."], ["\n If \\`", "\\` is specified, then catch blocks are allowed to be empty."])), ALLOW_EMPTY_CATCH),
optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n If `", "` is specified, then catch blocks are allowed to be empty.\n If `", "` is specified, then function definitions are allowed to be empty."], ["\n If \\`", "\\` is specified, then catch blocks are allowed to be empty.\n If \\`", "\\` is specified, then function definitions are allowed to be empty."])), ALLOW_EMPTY_CATCH, ALLOW_EMPTY_FUNCTIONS),
options: {
type: "string",
enum: [ALLOW_EMPTY_CATCH],
type: "array",
items: {
anyOf: [
{
type: "string",
enum: [ALLOW_EMPTY_CATCH],
},
{
type: "string",
enum: [ALLOW_EMPTY_FUNCTIONS],
},
],
},
},
optionExamples: [true, [true, ALLOW_EMPTY_CATCH]],
optionExamples: [
true,
[true, ALLOW_EMPTY_CATCH],
[true, ALLOW_EMPTY_FUNCTIONS],
[true, ALLOW_EMPTY_CATCH, ALLOW_EMPTY_FUNCTIONS],
],
type: "functionality",

@@ -77,2 +95,8 @@ typescriptOnly: false,

}
if (options.allowEmptyFunctions &&
(node.kind === ts.SyntaxKind.FunctionDeclaration ||
node.kind === ts.SyntaxKind.FunctionExpression ||
node.kind === ts.SyntaxKind.ArrowFunction)) {
return true;
}
return tsutils_1.isConstructorDeclaration(node) &&

@@ -79,0 +103,0 @@ (

@@ -35,3 +35,3 @@ "use strict";

description: "Promises returned by functions must be handled appropriately.",
descriptionDetails: "Use `no-unused-expression` in addition to this rule to reveal even more floating promises.",
descriptionDetails: "Unhandled Promises can cause unexpected behavior, such as resolving at unexpected times.",
optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n A list of 'string' names of any additional classes that should also be handled as Promises.\n "], ["\n A list of \\'string\\' names of any additional classes that should also be handled as Promises.\n "]))),

@@ -46,3 +46,3 @@ options: {

optionExamples: [true, [true, "JQueryPromise"]],
rationale: "Unhandled Promises can cause unexpected behavior, such as resolving at unexpected times.",
rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Creating a Promise and not storing or returning may lets other code run independent of of its results.\n This can cause unexpected and/or non-deterministic behavior depending on external timing factors.\n\n It's typically better to return Promises from functions that start them, then handle them in calling code.\n\n Use `no-unused-expression` in addition to this rule to reveal even more floating promises.\n "], ["\n Creating a Promise and not storing or returning may lets other code run independent of of its results.\n This can cause unexpected and/or non-deterministic behavior depending on external timing factors.\n\n It's typically better to return Promises from functions that start them, then handle them in calling code.\n\n Use \\`no-unused-expression\\` in addition to this rule to reveal even more floating promises.\n "]))),
type: "functionality",

@@ -81,2 +81,2 @@ typescriptOnly: true,

}
var templateObject_1;
var templateObject_1, templateObject_2;

@@ -38,2 +38,3 @@ "use strict";

optionExamples: [true],
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n When function or constructor may be called with a type parameter but one isn't supplied or inferrable,\n TypeScript defaults to `{}`.\n This is often undesirable as the call is meant to be of a more specific type.\n "], ["\n When function or constructor may be called with a type parameter but one isn't supplied or inferrable,\n TypeScript defaults to \\`{}\\`.\n This is often undesirable as the call is meant to be of a more specific type.\n "]))),
type: "functionality",

@@ -105,1 +106,2 @@ typescriptOnly: true,

}(Lint.AbstractWalker));
var templateObject_1;

@@ -38,2 +38,3 @@ "use strict";

optionExamples: [true],
rationale: "Interpolation will only work for template strings.",
type: "functionality",

@@ -40,0 +41,0 @@ typescriptOnly: false,

@@ -37,3 +37,3 @@ "use strict";

description: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Disallows the use constant number values outside of variable assignments.\n When no list of allowed values is specified, -1, 0 and 1 are allowed by default."], ["\n Disallows the use constant number values outside of variable assignments.\n When no list of allowed values is specified, -1, 0 and 1 are allowed by default."]))),
rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Magic numbers should be avoided as they often lack documentation, forcing\n them to be stored in variables gives them implicit documentation."], ["\n Magic numbers should be avoided as they often lack documentation, forcing\n them to be stored in variables gives them implicit documentation."]))),
rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Magic numbers should be avoided as they often lack documentation.\n Forcing them to be stored in variables gives them implicit documentation.\n "], ["\n Magic numbers should be avoided as they often lack documentation.\n Forcing them to be stored in variables gives them implicit documentation.\n "]))),
optionsDescription: "A list of allowed numbers.",

@@ -40,0 +40,0 @@ options: {

@@ -38,2 +38,3 @@ "use strict";

optionExamples: [true],
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Interfaces in TypeScript aren't meant to describe constructors on their implementations.\n The `new` descriptor is primarily for describing JavaScript libraries.\n If you're trying to describe a function known to be a class, it's typically better to `declare class`.\n "], ["\n Interfaces in TypeScript aren't meant to describe constructors on their implementations.\n The \\`new\\` descriptor is primarily for describing JavaScript libraries.\n If you're trying to describe a function known to be a class, it's typically better to \\`declare class\\`.\n "]))),
type: "functionality",

@@ -76,1 +77,2 @@ typescriptOnly: true,

}
var templateObject_1;

@@ -34,3 +34,3 @@ "use strict";

description: "Disallows non-null assertions using the `!` postfix operator.",
rationale: "Using non-null assertion cancels the benefits of the strict null checking mode.",
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Using non-null assertion cancels the benefits of the strict null checking mode.\n\n Instead of assuming objects exist:\n\n ```\n function foo(instance: MyClass | undefined) {\n instance!.doWork();\n }\n ```\n\n Either inform the strict type system that the object must exist:\n\n ```\n function foo(instance: MyClass) {\n instance.doWork();\n }\n ```\n\n Or verify that the instance exists, which will inform the type checker:\n\n ```\n function foo(instance: MyClass | undefined) {\n if (instance !== undefined) {\n instance.doWork();\n }\n }\n ```\n "], ["\n Using non-null assertion cancels the benefits of the strict null checking mode.\n\n Instead of assuming objects exist:\n\n \\`\\`\\`\n function foo(instance: MyClass | undefined) {\n instance!.doWork();\n }\n \\`\\`\\`\n\n Either inform the strict type system that the object must exist:\n\n \\`\\`\\`\n function foo(instance: MyClass) {\n instance.doWork();\n }\n \\`\\`\\`\n\n Or verify that the instance exists, which will inform the type checker:\n\n \\`\\`\\`\n function foo(instance: MyClass | undefined) {\n if (instance !== undefined) {\n instance.doWork();\n }\n }\n \\`\\`\\`\n "]))),
optionsDescription: "Not configurable.",

@@ -55,1 +55,2 @@ options: null,

}
var templateObject_1;

@@ -36,3 +36,3 @@ "use strict";

description: "Disallows use of the `null` keyword literal.",
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Instead of having the dual concepts of `null` and`undefined` in a codebase,\n this rule ensures that only `undefined` is used."], ["\n Instead of having the dual concepts of \\`null\\` and\\`undefined\\` in a codebase,\n this rule ensures that only \\`undefined\\` is used."]))),
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Instead of having the dual concepts of `null` and`undefined` in a codebase,\n this rule ensures that only `undefined` is used.\n\n JavaScript originally intended `undefined` to refer to a value that doesn't yet exist,\n while `null` was meant to refer to a value that does exist but points to nothing.\n That's confusing.\n `undefined` is the default value when object members don't exist, and is the return value\n for newer native collection APIs such as `Map.get` when collection values don't exist.\n\n ```\n const myObject = {};\n myObject.doesNotExist; // undefined\n ```\n\n ```\n const myMap = new Map<string, number>();\n myMap.get(\"doesNotExist\"); // undefined\n ```\n\n To remove confusion over the two similar values, it's better to stick with just `undefined`.\n "], ["\n Instead of having the dual concepts of \\`null\\` and\\`undefined\\` in a codebase,\n this rule ensures that only \\`undefined\\` is used.\n\n JavaScript originally intended \\`undefined\\` to refer to a value that doesn't yet exist,\n while \\`null\\` was meant to refer to a value that does exist but points to nothing.\n That's confusing.\n \\`undefined\\` is the default value when object members don't exist, and is the return value\n for newer native collection APIs such as \\`Map.get\\` when collection values don't exist.\n\n \\`\\`\\`\n const myObject = {};\n myObject.doesNotExist; // undefined\n \\`\\`\\`\n\n \\`\\`\\`\n const myMap = new Map<string, number>();\n myMap.get(\"doesNotExist\"); // undefined\n \\`\\`\\`\n\n To remove confusion over the two similar values, it's better to stick with just \\`undefined\\`.\n "]))),
optionsDescription: "Not configurable.",

@@ -39,0 +39,0 @@ options: null,

@@ -39,3 +39,3 @@ "use strict";

description: "Disallows parameter properties in class constructors.",
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Parameter properties can be confusing to those new to TS as they are less explicit\n than other ways of declaring and initializing class members."], ["\n Parameter properties can be confusing to those new to TS as they are less explicit\n than other ways of declaring and initializing class members."]))),
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Parameter properties can be confusing to those new to TS as they are less explicit\n than other ways of declaring and initializing class members.\n\n It can be cleaner to keep member variable declarations in one list directly only the class\n (instead of mixed between direct class members and constructor parameter properties).\n "], ["\n Parameter properties can be confusing to those new to TS as they are less explicit\n than other ways of declaring and initializing class members.\n\n It can be cleaner to keep member variable declarations in one list directly only the class\n (instead of mixed between direct class members and constructor parameter properties).\n "]))),
optionsDescription: "Not configurable.",

@@ -42,0 +42,0 @@ options: null,

@@ -97,3 +97,3 @@ "use strict";

}
if (comment === "") {
if (comment === undefined || comment === "") {
// Redundant if no documentation

@@ -100,0 +100,0 @@ ctx.addFailureAtNode(tag.tagName, Rule.FAILURE_STRING_NO_COMMENT(tag.tagName.text));

@@ -39,4 +39,4 @@ "use strict";

description: "Disallows shadowing variable declarations.",
rationale: "Shadowing a variable masks access to it and obscures to what value an identifier actually refers.",
optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n You can optionally pass an object to disable checking for certain kinds of declarations.\n Possible keys are `\"class\"`, `\"enum\"`, `\"function\"`, `\"import\"`, `\"interface\"`, `\"namespace\"`, `\"typeAlias\"`\n and `\"typeParameter\"`. Just set the value to `false` for the check you want to disable.\n All checks default to `true`, i.e. are enabled by default.\n Note that you cannot disable variables and parameters.\n\n The option `\"temporalDeadZone\"` defaults to `true` which shows errors when shadowing block scoped declarations in their\n temporal dead zone. When set to `false` parameters, classes, enums and variables declared\n with `let` or `const` are not considered shadowed if the shadowing occurs within their\n [temporal dead zone](http://jsrocks.org/2015/01/temporal-dead-zone-tdz-demystified).\n\n The following example shows how the `\"temporalDeadZone\"` option changes the linting result:\n\n ```ts\n function fn(value) {\n if (value) {\n const tmp = value; // no error on this line if \"temporalDeadZone\" is false\n return tmp;\n }\n let tmp = undefined;\n if (!value) {\n const tmp = value; // this line always contains an error\n return tmp;\n }\n }\n ```\n "], ["\n You can optionally pass an object to disable checking for certain kinds of declarations.\n Possible keys are \\`\"class\"\\`, \\`\"enum\"\\`, \\`\"function\"\\`, \\`\"import\"\\`, \\`\"interface\"\\`, \\`\"namespace\"\\`, \\`\"typeAlias\"\\`\n and \\`\"typeParameter\"\\`. Just set the value to \\`false\\` for the check you want to disable.\n All checks default to \\`true\\`, i.e. are enabled by default.\n Note that you cannot disable variables and parameters.\n\n The option \\`\"temporalDeadZone\"\\` defaults to \\`true\\` which shows errors when shadowing block scoped declarations in their\n temporal dead zone. When set to \\`false\\` parameters, classes, enums and variables declared\n with \\`let\\` or \\`const\\` are not considered shadowed if the shadowing occurs within their\n [temporal dead zone](http://jsrocks.org/2015/01/temporal-dead-zone-tdz-demystified).\n\n The following example shows how the \\`\"temporalDeadZone\"\\` option changes the linting result:\n\n \\`\\`\\`ts\n function fn(value) {\n if (value) {\n const tmp = value; // no error on this line if \"temporalDeadZone\" is false\n return tmp;\n }\n let tmp = undefined;\n if (!value) {\n const tmp = value; // this line always contains an error\n return tmp;\n }\n }\n \\`\\`\\`\n "]))),
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Shadowing a variable masks access to it and obscures to what value an identifier actually refers.\n For example, in the following code, it can be confusing why the filter is likely never true:\n\n ```\n const findNeighborsWithin = (instance: MyClass, instances: MyClass[]): MyClass[] => {\n return instances.filter((instance) => instance.neighbors.includes(instance));\n };\n ```\n "], ["\n Shadowing a variable masks access to it and obscures to what value an identifier actually refers.\n For example, in the following code, it can be confusing why the filter is likely never true:\n\n \\`\\`\\`\n const findNeighborsWithin = (instance: MyClass, instances: MyClass[]): MyClass[] => {\n return instances.filter((instance) => instance.neighbors.includes(instance));\n };\n \\`\\`\\`\n "]))),
optionsDescription: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n You can optionally pass an object to disable checking for certain kinds of declarations.\n Possible keys are `\"class\"`, `\"enum\"`, `\"function\"`, `\"import\"`, `\"interface\"`, `\"namespace\"`, `\"typeAlias\"`\n and `\"typeParameter\"`. Just set the value to `false` for the check you want to disable.\n All checks default to `true`, i.e. are enabled by default.\n Note that you cannot disable variables and parameters.\n\n The option `\"temporalDeadZone\"` defaults to `true` which shows errors when shadowing block scoped declarations in their\n temporal dead zone. When set to `false` parameters, classes, enums and variables declared\n with `let` or `const` are not considered shadowed if the shadowing occurs within their\n [temporal dead zone](http://jsrocks.org/2015/01/temporal-dead-zone-tdz-demystified).\n\n The following example shows how the `\"temporalDeadZone\"` option changes the linting result:\n\n ```ts\n function fn(value) {\n if (value) {\n const tmp = value; // no error on this line if \"temporalDeadZone\" is false\n return tmp;\n }\n let tmp = undefined;\n if (!value) {\n const tmp = value; // this line always contains an error\n return tmp;\n }\n }\n ```\n "], ["\n You can optionally pass an object to disable checking for certain kinds of declarations.\n Possible keys are \\`\"class\"\\`, \\`\"enum\"\\`, \\`\"function\"\\`, \\`\"import\"\\`, \\`\"interface\"\\`, \\`\"namespace\"\\`, \\`\"typeAlias\"\\`\n and \\`\"typeParameter\"\\`. Just set the value to \\`false\\` for the check you want to disable.\n All checks default to \\`true\\`, i.e. are enabled by default.\n Note that you cannot disable variables and parameters.\n\n The option \\`\"temporalDeadZone\"\\` defaults to \\`true\\` which shows errors when shadowing block scoped declarations in their\n temporal dead zone. When set to \\`false\\` parameters, classes, enums and variables declared\n with \\`let\\` or \\`const\\` are not considered shadowed if the shadowing occurs within their\n [temporal dead zone](http://jsrocks.org/2015/01/temporal-dead-zone-tdz-demystified).\n\n The following example shows how the \\`\"temporalDeadZone\"\\` option changes the linting result:\n\n \\`\\`\\`ts\n function fn(value) {\n if (value) {\n const tmp = value; // no error on this line if \"temporalDeadZone\" is false\n return tmp;\n }\n let tmp = undefined;\n if (!value) {\n const tmp = value; // this line always contains an error\n return tmp;\n }\n }\n \\`\\`\\`\n "]))),
options: {

@@ -320,2 +320,2 @@ type: "object",

}
var templateObject_1;
var templateObject_1, templateObject_2;

@@ -23,2 +23,3 @@ "use strict";

var Lint = require("../index");
var noStringThrowRule_examples_1 = require("./code-examples/noStringThrowRule.examples");
var Rule = /** @class */ (function (_super) {

@@ -35,7 +36,9 @@ tslib_1.__extends(Rule, _super);

ruleName: "no-string-throw",
description: "Flags throwing plain strings or concatenations of strings " +
"because only Errors produce proper stack traces.",
description: "Flags throwing plain strings or concatenations of strings.",
hasFix: true,
options: null,
optionExamples: [true],
optionsDescription: "Not configurable.",
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Example \u2013 Doing it right\n\n ```ts\n // throwing an Error from typical function, whether sync or async\n if (!productToAdd) {\n throw new Error(\"How can I add new product when no value provided?\");\n }\n ```\n\n Example \u2013 Anti Pattern\n\n ```ts\n // throwing a string lacks any stack trace information and other important data properties\n if (!productToAdd) {\n throw (\"How can I add new product when no value provided?\");\n }\n ```\n\n Only Error objects contain a `.stack` member equivalent to the current stack trace.\n Primitives such as strings do not.\n "], ["\n Example \u2013 Doing it right\n\n \\`\\`\\`ts\n // throwing an Error from typical function, whether sync or async\n if (!productToAdd) {\n throw new Error(\"How can I add new product when no value provided?\");\n }\n \\`\\`\\`\n\n Example \u2013 Anti Pattern\n\n \\`\\`\\`ts\n // throwing a string lacks any stack trace information and other important data properties\n if (!productToAdd) {\n throw (\"How can I add new product when no value provided?\");\n }\n \\`\\`\\`\n\n Only Error objects contain a \\`.stack\\` member equivalent to the current stack trace.\n Primitives such as strings do not.\n "]))),
codeExamples: noStringThrowRule_examples_1.codeExamples,
type: "functionality",

@@ -80,1 +83,2 @@ typescriptOnly: false,

}
var templateObject_1;

@@ -75,4 +75,3 @@ "use strict";

optionsDescription: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Two options may be provided on an object:\n\n * `", "` allows using destructuring to access members of `this` (e.g. `{ foo, bar } = this;`).\n * `", "` may be specified as a list of regular expressions to match allowed variable names."], ["\n Two options may be provided on an object:\n\n * \\`", "\\` allows using destructuring to access members of \\`this\\` (e.g. \\`{ foo, bar } = this;\\`).\n * \\`", "\\` may be specified as a list of regular expressions to match allowed variable names."])), ALLOW_THIS_DESTRUCTURING, ALLOWED_THIS_NAMES),
rationale: "Assigning a variable to `this` instead of properly using arrow lambdas "
+ "may be a symptom of pre-ES6 practices or not manging scope well.",
rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n Assigning a variable to `this` instead of properly using arrow lambdas may be a symptom of pre-ES6 practices\n or not managing scope well.\n\n Instead of storing a reference to `this` and using it inside a `function () {`:\n\n ```\n const self = this;\n\n setTimeout(function () {\n self.doWork();\n });\n ```\n\n Use `() =>` arrow lambdas, as they preserve `this` scope for you:\n\n ```\n setTimeout(() => {\n this.doWork();\n });\n ```\n "], ["\n Assigning a variable to \\`this\\` instead of properly using arrow lambdas may be a symptom of pre-ES6 practices\n or not managing scope well.\n\n Instead of storing a reference to \\`this\\` and using it inside a \\`function () {\\`:\n\n \\`\\`\\`\n const self = this;\n\n setTimeout(function () {\n self.doWork();\n });\n \\`\\`\\`\n\n Use \\`() =>\\` arrow lambdas, as they preserve \\`this\\` scope for you:\n\n \\`\\`\\`\n setTimeout(() => {\n this.doWork();\n });\n \\`\\`\\`\n "]))),
ruleName: "no-this-assignment",

@@ -129,3 +128,3 @@ type: "functionality",

}(Lint.AbstractWalker));
var templateObject_1;
var templateObject_1, templateObject_2;
var _a, _b;

@@ -37,3 +37,3 @@ "use strict";

ruleName: "no-unbound-method",
description: "Warns when a method is used as outside of a method call.",
description: "Warns when a method is used outside of a method call.",
optionsDescription: "You may optionally pass \"" + OPTION_IGNORE_STATIC + "\" to ignore static methods.",

@@ -45,2 +45,3 @@ options: {

optionExamples: [true, [true, OPTION_IGNORE_STATIC]],
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Class functions don't preserve the class scope when passed as standalone variables.\n For example, this code will log the global scope (`window`/`global`), not the class instance:\n\n ```\n class MyClass {\n public log(): void {\n console.log(this);\n }\n }\n\n const instance = new MyClass();\n const log = instance.log;\n\n log();\n ```\n\n You need to either use an arrow lambda (`() => {...}`) or call the function with the correct scope.\n\n ```\n class MyClass {\n public logArrowBound = (): void => {\n console.log(bound);\n };\n\n public logManualBind(): void {\n console.log(this);\n }\n }\n\n const instance = new MyClass();\n const logArrowBound = instance.logArrowBound;\n const logManualBind = instance.logManualBind.bind(instance);\n\n logArrowBound();\n logManualBind();\n ```\n "], ["\n Class functions don't preserve the class scope when passed as standalone variables.\n For example, this code will log the global scope (\\`window\\`/\\`global\\`), not the class instance:\n\n \\`\\`\\`\n class MyClass {\n public log(): void {\n console.log(this);\n }\n }\n\n const instance = new MyClass();\n const log = instance.log;\n\n log();\n \\`\\`\\`\n\n You need to either use an arrow lambda (\\`() => {...}\\`) or call the function with the correct scope.\n\n \\`\\`\\`\n class MyClass {\n public logArrowBound = (): void => {\n console.log(bound);\n };\n\n public logManualBind(): void {\n console.log(this);\n }\n }\n\n const instance = new MyClass();\n const logArrowBound = instance.logArrowBound;\n const logManualBind = instance.logManualBind.bind(instance);\n\n logArrowBound();\n logManualBind();\n \\`\\`\\`\n "]))),
type: "functionality",

@@ -83,4 +84,5 @@ typescriptOnly: true,

return parent.tag === node;
// E.g. `obj.method.bind(obj)`.
// E.g. `obj.method.bind(obj) or obj.method["prop"]`.
case ts.SyntaxKind.PropertyAccessExpression:
case ts.SyntaxKind.ElementAccessExpression:
return true;

@@ -108,1 +110,2 @@ // Allow most binary operators, but don't allow e.g. `myArray.forEach(obj.method || otherObj.otherMethod)`.

}
var templateObject_1;

@@ -42,2 +42,3 @@ "use strict";

optionExamples: [true],
rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n There's generally no reason to wrap a function with a callback wrapper if it's directly called anyway.\n Doing so creates extra inline lambdas that slow the runtime down.\n "], ["\n There's generally no reason to wrap a function with a callback wrapper if it's directly called anyway.\n Doing so creates extra inline lambdas that slow the runtime down.\n "]))),
type: "style",

@@ -87,2 +88,2 @@ typescriptOnly: false,

}
var templateObject_1;
var templateObject_1, templateObject_2;

@@ -39,2 +39,3 @@ "use strict";

optionExamples: [true],
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Values in JavaScript default to `undefined`.\n There's no need to do so manually.\n "], ["\n Values in JavaScript default to \\`undefined\\`.\n There's no need to do so manually.\n "]))),
type: "style",

@@ -106,1 +107,2 @@ typescriptOnly: false,

}
var templateObject_1;

@@ -23,2 +23,3 @@ "use strict";

var Lint = require("../index");
var utils_1 = require("../utils");
var Rule = /** @class */ (function (_super) {

@@ -39,2 +40,3 @@ tslib_1.__extends(Rule, _super);

optionExamples: [true],
rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n If you're dealing with data of unknown or \"any\" types, you shouldn't be accessing members of it.\n Either add type annotations for properties that may exist or change the data type to the empty object type `{}`.\n\n Alternately, if you're creating storage or handling for consistent but unknown types, such as in data structures\n or serialization, use `<T>` template types for generic type handling.\n\n Also see the `no-any` rule.\n "], ["\n If you're dealing with data of unknown or \"any\" types, you shouldn't be accessing members of it.\n Either add type annotations for properties that may exist or change the data type to the empty object type \\`{}\\`.\n\n Alternately, if you're creating storage or handling for consistent but unknown types, such as in data structures\n or serialization, use \\`<T>\\` template types for generic type handling.\n\n Also see the \\`no-any\\` rule.\n "]))),
type: "functionality",

@@ -293,6 +295,6 @@ typescriptOnly: true,

case ts.SyntaxKind.BarBarToken: // Allow `any || any`
case ts.SyntaxKind.AmpersandAmpersandToken:// Allow `any && any`
case ts.SyntaxKind.AmpersandAmpersandToken: // Allow `any && any`
allowAnyLeft = allowAnyRight = true;
break;
case ts.SyntaxKind.InstanceOfKeyword:// Allow test
case ts.SyntaxKind.InstanceOfKeyword: // Allow test
allowAnyLeft = true;

@@ -382,4 +384,23 @@ break;

}
// Lowercase JSX elements are assumed to be allowed by design
if (isJsxNativeElement(node)) {
return false;
}
return isAny(checker.getTypeAtLocation(node));
}
var jsxElementTypes = new Set([
ts.SyntaxKind.JsxClosingElement,
ts.SyntaxKind.JsxOpeningElement,
ts.SyntaxKind.JsxSelfClosingElement,
]);
function isJsxNativeElement(node) {
if (!tsutils_1.isIdentifier(node) || node.parent === undefined) {
return false;
}
// TypeScript <=2.1 incorrectly parses JSX fragments
if (node.text === "") {
return true;
}
return jsxElementTypes.has(node.parent.kind) && utils_1.isLowerCase(node.text[0]);
}
function isStringLike(expr, checker) {

@@ -391,2 +412,2 @@ return tsutils_1.isTypeFlagSet(checker.getTypeAtLocation(expr), ts.TypeFlags.StringLike);

}
var templateObject_1;
var templateObject_1, templateObject_2;

@@ -37,3 +37,3 @@ "use strict";

ruleName: "no-unused-variable",
description: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["Disallows unused imports, variables, functions and\n private class members. Similar to tsc's --noUnusedParameters and --noUnusedLocals\n options, but does not interrupt code compilation."], ["Disallows unused imports, variables, functions and\n private class members. Similar to tsc's --noUnusedParameters and --noUnusedLocals\n options, but does not interrupt code compilation."]))),
description: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Disallows unused imports, variables, functions and\n private class members. Similar to tsc's --noUnusedParameters and --noUnusedLocals\n options, but does not interrupt code compilation."], ["\n Disallows unused imports, variables, functions and\n private class members. Similar to tsc's --noUnusedParameters and --noUnusedLocals\n options, but does not interrupt code compilation."]))),
descriptionDetails: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n In addition to avoiding compilation errors, this rule may still be useful if you\n wish to have `tslint` automatically remove unused imports, variables, functions,\n and private class members, when using TSLint's `--fix` option."], ["\n In addition to avoiding compilation errors, this rule may still be useful if you\n wish to have \\`tslint\\` automatically remove unused imports, variables, functions,\n and private class members, when using TSLint's \\`--fix\\` option."]))),

@@ -63,2 +63,3 @@ hasFix: true,

optionExamples: [true, [true, { "ignore-pattern": "^_" }]],
rationale: Lint.Utils.dedent(templateObject_4 || (templateObject_4 = tslib_1.__makeTemplateObject(["\n Variables that are declared and not used anywhere in code are likely an error due to incomplete refactoring.\n Such variables take up space in the code, are mild performance pains, and can lead to confusion by readers.\n "], ["\n Variables that are declared and not used anywhere in code are likely an error due to incomplete refactoring.\n Such variables take up space in the code, are mild performance pains, and can lead to confusion by readers.\n "]))),
type: "functionality",

@@ -111,12 +112,15 @@ typescriptOnly: true,

}
if (kind === 0 /* VARIABLE_OR_PARAMETER */) {
var importName = findImport(diag.start, sourceFile);
if (importName !== undefined) {
if (declaration && isImportUsed(importName, sourceFile, checker)) {
continue;
if (kind === 0 /* VARIABLE_OR_PARAMETER */ || kind === 2 /* DECLARATION */) {
var importNames = findImports(diag.start, sourceFile, kind);
if (importNames.length > 0) {
for (var _b = 0, importNames_1 = importNames; _b < importNames_1.length; _b++) {
var importName = importNames_1[_b];
if (declaration && isImportUsed(importName, sourceFile, checker)) {
continue;
}
if (importSpecifierFailures.has(importName)) {
throw new Error("Should not get 2 errors for the same import.");
}
importSpecifierFailures.set(importName, failure);
}
if (importSpecifierFailures.has(importName)) {
throw new Error("Should not get 2 errors for the same import.");
}
importSpecifierFailures.set(importName, failure);
continue;

@@ -162,3 +166,3 @@ }

}
removeAll(importNode, "All imports are unused.");
removeAll(importNode, "All imports on this line are unused.");
return;

@@ -299,8 +303,9 @@ }

}
function findImport(pos, sourceFile) {
return forEachImport(sourceFile, function (i) {
function findImports(pos, sourceFile, kind) {
var imports = forEachImport(sourceFile, function (i) {
if (!isInRange(i, pos)) {
return undefined;
}
if (i.kind === ts.SyntaxKind.ImportEqualsDeclaration) {
if (i.name.getStart() === pos) {
return i.name;
}
return [i.name];
}

@@ -314,16 +319,41 @@ else {

if (namedBindings !== undefined && namedBindings.kind === ts.SyntaxKind.NamespaceImport) {
var name = namedBindings.name;
if (name.getStart() === pos) {
return name;
return [namedBindings.name];
}
// Starting from TS2.8, when all imports in an import node are not used,
// TS emits only 1 diagnostic object for the whole line as opposed
// to the previous behavior of outputting a diagnostic with kind == 6192
// (UnusedKind.VARIABLE_OR_PARAMETER) for every unused import.
// From TS2.8, in the case of none of the imports in a line being used,
// the single diagnostic TS outputs are different between the 1 import
// and 2+ imports cases:
// - 1 import in node:
// - diagnostic has kind == 6133 (UnusedKind.VARIABLE_OR_PARAMETER)
// - the text range is the whole node (`import { ... } from "..."`)
// whereas pre-TS2.8, the text range was for the import node. so
// `name.getStart()` won't equal `pos` like in pre-TS2.8
// - 2+ imports in node:
// - diagnostic has kind == 6192 (UnusedKind.DECLARATION)
// - we know that all of these are unused
if (kind === 2 /* DECLARATION */) {
var imp = [];
if (defaultName !== undefined) {
imp.push(defaultName);
}
return undefined;
if (namedBindings !== undefined) {
imp.push.apply(imp, namedBindings.elements.map(function (el) { return el.name; }));
}
return imp.length > 0 ? imp : undefined;
}
if (defaultName !== undefined && defaultName.getStart() === pos) {
return defaultName;
else if (defaultName !== undefined && (isInRange(defaultName, pos) || namedBindings === undefined // defaultName is the only option
)) {
return [defaultName];
}
else if (namedBindings !== undefined) {
if (namedBindings.elements.length === 1) {
return [namedBindings.elements[0].name];
}
for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) {
var name = _b[_i].name;
if (name.getStart() === pos) {
return name;
var element = _b[_i];
if (isInRange(element, pos)) {
return [element.name];
}

@@ -335,9 +365,18 @@ }

});
return imports !== undefined ? imports : [];
}
function isInRange(range, pos) {
return range.pos <= pos && range.end >= pos;
}
function getUnusedDiagnostic(diag) {
// https://github.com/Microsoft/TypeScript/blob/master/src/compiler/diagnosticMessages.json
switch (diag.code) {
case 6133:
return 0 /* VARIABLE_OR_PARAMETER */; // "'{0}' is declared but never used.
case 6133: // Pre TS 2.9 "'{0}' is declared but never used.
// TS 2.9+ "'{0}' is declared but its value is never read."
case 6196: // TS 2.9+ "'{0}' is declared but never used."
return 0 /* VARIABLE_OR_PARAMETER */;
case 6138:
return 1 /* PROPERTY */; // "Property '{0}' is declared but never used."
case 6192:
return 2 /* DECLARATION */; // "All imports in import declaration are unused."
default:

@@ -381,2 +420,2 @@ return undefined;

}
var templateObject_1, templateObject_2, templateObject_3;
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;

@@ -40,2 +40,3 @@ "use strict";

optionExamples: [true],
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Declaring variables using `var` has several edge case behaviors that make `var` unsuitable for modern code.\n Variables declared by `var` have their parent function block as their scope, ignoring other control flow statements.\n `var`s have declaration \"hoisting\" (similar to `function`s) and can appear to be used before declaration.\n\n Variables declared by `const` and `let` instead have as their scope the block in which they are defined,\n and are not allowed to used before declaration or be re-declared with another `const` or `let`.\n "], ["\n Declaring variables using \\`var\\` has several edge case behaviors that make \\`var\\` unsuitable for modern code.\n Variables declared by \\`var\\` have their parent function block as their scope, ignoring other control flow statements.\n \\`var\\`s have declaration \"hoisting\" (similar to \\`function\\`s) and can appear to be used before declaration.\n\n Variables declared by \\`const\\` and \\`let\\` instead have as their scope the block in which they are defined,\n and are not allowed to used before declaration or be re-declared with another \\`const\\` or \\`let\\`.\n "]))),
type: "functionality",

@@ -72,1 +73,2 @@ typescriptOnly: false,

}
var templateObject_1;

@@ -35,6 +35,7 @@ "use strict";

description: "Disallows the use of require statements except in import statements.",
descriptionDetails: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n In other words, the use of forms such as `var module = require(\"module\")` are banned.\n Instead use ES6 style imports or `import foo = require('foo')` imports."], ["\n In other words, the use of forms such as \\`var module = require(\"module\")\\` are banned.\n Instead use ES6 style imports or \\`import foo = require('foo')\\` imports."]))),
descriptionDetails: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n In other words, the use of forms such as `var module = require(\"module\")` are banned.\n Instead use ES2015-style imports or `import foo = require('foo')` imports."], ["\n In other words, the use of forms such as \\`var module = require(\"module\")\\` are banned.\n Instead use ES2015-style imports or \\`import foo = require('foo')\\` imports."]))),
optionsDescription: "Not configurable.",
options: null,
optionExamples: [true],
rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n AMD-style `require([])` and CommonJS-style `require(\"\")` statements are environment-specific\n and more difficult to statically analyze.\n\n ES2015-style `import`s are part of the JavaScript language specfication and recommended as the path going forward.\n TypeScript will compile them to environment-specific forms as needed.\n "], ["\n AMD-style \\`require([])\\` and CommonJS-style \\`require(\"\")\\` statements are environment-specific\n and more difficult to statically analyze.\n\n ES2015-style \\`import\\`s are part of the JavaScript language specfication and recommended as the path going forward.\n TypeScript will compile them to environment-specific forms as needed.\n "]))),
type: "typescript",

@@ -70,2 +71,2 @@ typescriptOnly: true,

}(Lint.ScopeAwareRuleWalker));
var templateObject_1;
var templateObject_1, templateObject_2;

@@ -47,2 +47,3 @@ "use strict";

},
rationale: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n It's misleading returning the results of an expression whose type is `void`.\n Attempting to do so is likely a symptom of expecting a different return type from a function.\n For example, the following code will log `undefined` but looks like it logs a value:\n\n ```\n const performWork = (): void => {\n workFirst();\n workSecond();\n };\n\n console.log(performWork());\n ```\n "], ["\n It's misleading returning the results of an expression whose type is \\`void\\`.\n Attempting to do so is likely a symptom of expecting a different return type from a function.\n For example, the following code will log \\`undefined\\` but looks like it logs a value:\n\n \\`\\`\\`\n const performWork = (): void => {\n workFirst();\n workSecond();\n };\n\n console.log(performWork());\n \\`\\`\\`\n "]))),
requiresTypeInfo: true,

@@ -88,2 +89,2 @@ type: "functionality",

}
var templateObject_1;
var templateObject_1, templateObject_2;

@@ -39,2 +39,3 @@ "use strict";

optionExamples: [true],
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Helps keep a consistent style with numeric literals.\n Non-standard literals are more difficult to scan through and can be a symptom of typos.\n "], ["\n Helps keep a consistent style with numeric literals.\n Non-standard literals are more difficult to scan through and can be a symptom of typos.\n "]))),
type: "style",

@@ -106,1 +107,2 @@ typescriptOnly: false,

}
var templateObject_1;

@@ -23,2 +23,23 @@ "use strict";

var Lint = require("../index");
var OPTION_FUNCTION_DECLARATION = "check-function-declaration";
var OPTION_FUNCTION_EXPRESSION = "check-function-expression";
var OPTION_ARROW_FUNCTION = "check-arrow-function";
var OPTION_METHOD_DECLARATION = "check-method-declaration";
var KIND_FOR_OPTION = (_a = {},
_a[OPTION_FUNCTION_DECLARATION] = ts.SyntaxKind.FunctionDeclaration,
_a[OPTION_FUNCTION_EXPRESSION] = ts.SyntaxKind.FunctionExpression,
_a[OPTION_ARROW_FUNCTION] = ts.SyntaxKind.ArrowFunction,
_a[OPTION_METHOD_DECLARATION] = ts.SyntaxKind.MethodDeclaration,
_a);
function parseOptions(ruleArguments) {
if (ruleArguments.length === 0) {
ruleArguments = Object.keys(KIND_FOR_OPTION);
}
var enabledKinds = new Set();
for (var _i = 0, ruleArguments_1 = ruleArguments; _i < ruleArguments_1.length; _i++) {
var arg = ruleArguments_1[_i];
enabledKinds.add(KIND_FOR_OPTION[arg]);
}
return enabledKinds;
}
var Rule = /** @class */ (function (_super) {

@@ -30,3 +51,3 @@ tslib_1.__extends(Rule, _super);

Rule.prototype.applyWithProgram = function (sourceFile, program) {
return this.applyWithFunction(sourceFile, walk, undefined, program.getTypeChecker());
return this.applyWithFunction(sourceFile, walk, parseOptions(this.ruleArguments), program.getTypeChecker());
};

@@ -37,6 +58,20 @@ /* tslint:disable:object-literal-sort-keys */

description: "Requires any function or method that returns a promise to be marked async.",
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Ensures that each function is only capable of 1) returning a rejected promise, or 2)\n throwing an Error object. In contrast, non-`async` `Promise`-returning functions\n are technically capable of either. This practice removes a requirement for consuming\n code to handle both cases.\n "], ["\n Ensures that each function is only capable of 1) returning a rejected promise, or 2)\n throwing an Error object. In contrast, non-\\`async\\` \\`Promise\\`-returning functions\n are technically capable of either. This practice removes a requirement for consuming\n code to handle both cases.\n "]))),
rationale: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Ensures that each function is only capable of 1) returning a rejected promise, or 2)\n throwing an Error object. In contrast, non-`async` `Promise`-returning functions\n are technically capable of either. This practice removes a requirement for consuming\n code to handle both cases.\n\n If no optional arguments are provided then all function types are checked,\n otherwise the specific function types are checked:\n\n * `\"", "\"` check function declarations.\n * `\"", "\"` check function expressions.\n * `\"", "\"` check arrow functions.\n * `\"", "\"` check method declarations.\n "], ["\n Ensures that each function is only capable of 1) returning a rejected promise, or 2)\n throwing an Error object. In contrast, non-\\`async\\` \\`Promise\\`-returning functions\n are technically capable of either. This practice removes a requirement for consuming\n code to handle both cases.\n\n If no optional arguments are provided then all function types are checked,\n otherwise the specific function types are checked:\n\n * \\`\"", "\"\\` check function declarations.\n * \\`\"", "\"\\` check function expressions.\n * \\`\"", "\"\\` check arrow functions.\n * \\`\"", "\"\\` check method declarations.\n "])), OPTION_FUNCTION_DECLARATION, OPTION_FUNCTION_EXPRESSION, OPTION_ARROW_FUNCTION, OPTION_METHOD_DECLARATION),
optionsDescription: "Not configurable.",
options: null,
optionExamples: [true],
options: {
type: "array",
items: {
type: "string",
enum: [
OPTION_FUNCTION_DECLARATION,
OPTION_FUNCTION_EXPRESSION,
OPTION_ARROW_FUNCTION,
OPTION_METHOD_DECLARATION,
],
},
minLength: 0,
maxLength: 4,
},
optionExamples: [true,
[true, OPTION_FUNCTION_DECLARATION, OPTION_METHOD_DECLARATION]],
type: "typescript",

@@ -52,15 +87,19 @@ typescriptOnly: false,

function walk(ctx, tc) {
return ts.forEachChild(ctx.sourceFile, function cb(node) {
switch (node.kind) {
case ts.SyntaxKind.MethodDeclaration:
case ts.SyntaxKind.FunctionDeclaration:
if (node.body === undefined) {
break;
}
// falls through
case ts.SyntaxKind.FunctionExpression:
case ts.SyntaxKind.ArrowFunction:
if (!tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.AsyncKeyword) && returnsPromise(node, tc)) {
ctx.addFailure(node.getStart(ctx.sourceFile), node.body.pos, Rule.FAILURE_STRING);
}
var sourceFile = ctx.sourceFile, options = ctx.options;
return ts.forEachChild(sourceFile, function cb(node) {
if (options.has(node.kind)) {
switch (node.kind) {
case ts.SyntaxKind.MethodDeclaration:
case ts.SyntaxKind.FunctionDeclaration:
if (node.body === undefined) {
break;
}
// falls through
case ts.SyntaxKind.FunctionExpression:
case ts.SyntaxKind.ArrowFunction:
if (!tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.AsyncKeyword)
&& returnsPromise(node, tc)) {
ctx.addFailure(node.getStart(sourceFile), node.body.pos, Rule.FAILURE_STRING);
}
}
}

@@ -75,1 +114,2 @@ return ts.forEachChild(node, cb);

var templateObject_1;
var _a;

@@ -177,3 +177,3 @@ "use strict";

}
else if (!tsutils_1.isTypeFlagSet(ty, ts.TypeFlags.Void | ts.TypeFlags.Undefined)) {
else if (!tsutils_1.isTypeFlagSet(ty, ts.TypeFlags.Void | ts.TypeFlags.Undefined)) { // tslint:disable-line:no-bitwise
return undefined;

@@ -180,0 +180,0 @@ }

@@ -109,3 +109,3 @@ "use strict";

TypedefWhitespaceWalker.prototype.checkSpace = function (node, key) {
if (node.type === undefined) {
if (!("type" in node) || node.type === undefined) {
return;

@@ -112,0 +112,0 @@ }

@@ -170,5 +170,5 @@ "use strict";

}
var linter, lastFolder, configFile, _i, files_1, file, folder, contents, _a;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
var linter, lastFolder, configFile, _i, files_1, file, folder, contents, sourceFile;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:

@@ -183,3 +183,3 @@ linter = new linter_1.Linter({

_i = 0, files_1 = files;
_b.label = 1;
_a.label = 1;
case 1:

@@ -198,15 +198,18 @@ if (!(_i < files_1.length)) return [3 /*break*/, 6];

}
contents = void 0;
if (!(program !== undefined)) return [3 /*break*/, 2];
_a = program.getSourceFile(file).text;
sourceFile = program.getSourceFile(file);
if (sourceFile !== undefined) {
contents = sourceFile.text;
}
return [3 /*break*/, 4];
case 2: return [4 /*yield*/, tryReadFile(file, logger)];
case 3:
_a = _b.sent();
_b.label = 4;
contents = _a.sent();
_a.label = 4;
case 4:
contents = _a;
if (contents !== undefined) {
linter.lint(file, contents, configFile);
}
_b.label = 5;
_a.label = 5;
case 5:

@@ -232,3 +235,3 @@ _i++;

fs.readSync(fd, buffer, 0, 256, 0);
if (buffer.readInt8(0, true) === 0x47 && buffer.readInt8(188, true) === 0x47) {
if (buffer.readInt8(0) === 0x47 && buffer.readInt8(188) === 0x47) {
// MPEG transport streams use the '.ts' file extension. They use 0x47 as the frame

@@ -235,0 +238,0 @@ // separator, repeating every 188 bytes. It is unlikely to find that pattern in

@@ -105,3 +105,3 @@ "use strict";

describe: "tsconfig.json file",
description: utils_1.dedent(templateObject_9 || (templateObject_9 = tslib_1.__makeTemplateObject(["\n The path or directory containing a tsconfig.json file that will be\n used to determine which files will be linted. This flag also enables\n rules that require the type checker."], ["\n The path or directory containing a tsconfig.json file that will be\n used to determine which files will be linted. This flag also enables\n rules that require the type checker."]))),
description: utils_1.dedent(templateObject_9 || (templateObject_9 = tslib_1.__makeTemplateObject(["\n The path to the tsconfig.json file or to the directory containing\n the tsconfig.json file. The file will be used to determine which\n files will be linted. This flag also enables rules that require the\n type checker."], ["\n The path to the tsconfig.json file or to the directory containing\n the tsconfig.json file. The file will be used to determine which\n files will be linted. This flag also enables rules that require the\n type checker."]))),
},

@@ -108,0 +108,0 @@ {

{
"name": "tslint",
"version": "5.9.1",
"version": "5.10.0",
"description": "An extensible static analysis linter for the TypeScript language",

@@ -29,3 +29,3 @@ "bin": {

"lint": "npm-run-all -p lint:global lint:from-bin",
"lint:global": "tslint --project test/tsconfig.json --format stylish # test includes 'src' too",
"lint:global": "tslint --project test/tsconfig.json --format stylish",
"lint:from-bin": "node bin/tslint --project test/tsconfig.json --format stylish",

@@ -55,3 +55,3 @@ "publish:local": "./scripts/npmPublish.sh",

"peerDependencies": {
"typescript": ">=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev || >=2.8.0-dev"
"typescript": ">=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev || >=2.8.0-dev || >=2.9.0-dev"
},

@@ -80,3 +80,3 @@ "devDependencies": {

"tslint-test-config-non-relative": "file:test/external/tslint-test-config-non-relative",
"typescript": "~2.6.1"
"typescript": "~2.8.3"
},

@@ -83,0 +83,0 @@ "license": "Apache-2.0",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc