Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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 2.3.0-beta to 2.3.1-beta

.settings/settings.json

2

build/formatters/jsonFormatter.js

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -18,0 +18,0 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -30,3 +30,4 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

var output = "<pmd version=\"tslint\">";
failures.forEach(function (failure) {
for (var _i = 0; _i < failures.length; _i++) {
var failure = failures[_i];
var failureString = failure.getFailure()

@@ -44,3 +45,3 @@ .replace(/&/g, "&amp;")

output += " rule=\"" + failureString + "\"> </violation></file>";
});
}
output += "</pmd>";

@@ -47,0 +48,0 @@ return output;

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -34,3 +34,3 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

var positionTuple = "[" + (lineAndCharacter.line + 1) + ", " + (lineAndCharacter.character + 1) + "]";
return fileName + positionTuple + ": " + failureString;
return "" + fileName + positionTuple + ": " + failureString;
});

@@ -37,0 +37,0 @@ return outputLines.join("\n") + "\n";

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -70,4 +70,4 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

var alignToColumn = prevPos.character;
for (var index = 1; index < nodes.length; index++) {
var node = nodes[index];
for (var _i = 0, _a = nodes.slice(1); _i < _a.length; _i++) {
var node = _a[_i];
var curPos = this.getPosition(node);

@@ -74,0 +74,0 @@ if (curPos.line !== prevPos.line && curPos.character !== alignToColumn) {

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -18,0 +18,0 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -18,0 +18,0 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -87,6 +87,3 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

CurlyWalker.prototype.isStatementBraced = function (node) {
if (node.kind === 179) {
return true;
}
return false;
return node.kind === 179;
};

@@ -93,0 +90,0 @@ CurlyWalker.prototype.addFailureForNode = function (node, failure) {

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -36,4 +36,5 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

var start = eofToken.getStart();
var failure = new Lint.RuleFailure(sourceFile, start, start, Rule.FAILURE_STRING, this.getOptions().ruleName);
return [failure];
return [
new Lint.RuleFailure(sourceFile, start, start, Rule.FAILURE_STRING, this.getOptions().ruleName)
];
}

@@ -40,0 +41,0 @@ return [];

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -60,3 +60,3 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

var ifStatement = firstBlockStatement.thenStatement;
if (this.nodeIsContinue(ifStatement)) {
if (ForInWalker.nodeIsContinue(ifStatement)) {
return;

@@ -70,3 +70,3 @@ }

};
ForInWalker.prototype.nodeIsContinue = function (node) {
ForInWalker.nodeIsContinue = function (node) {
var kind = node.kind;

@@ -78,4 +78,3 @@ if (kind === 189) {

var blockStatements = node.statements;
if (blockStatements.length === 1 &&
blockStatements[0].kind === 189) {
if (blockStatements.length === 1 && blockStatements[0].kind === 189) {
return true;

@@ -82,0 +81,0 @@ }

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -52,3 +52,2 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

IndentWalker.prototype.visitSourceFile = function (node) {
var _this = this;
if (!this.hasOption(OPTION_USE_TABS) && !this.hasOption(OPTION_USE_SPACES)) {

@@ -58,4 +57,4 @@ return;

var scanner = ts.createScanner(1, false, node.text);
var lineStarts = node.getLineStarts();
lineStarts.forEach(function (lineStart) {
for (var _i = 0, _a = node.getLineStarts(); _i < _a.length; _i++) {
var lineStart = _a[_i];
scanner.setTextPos(lineStart);

@@ -74,13 +73,13 @@ var currentScannedType = scanner.scan();

}
if (currentScannedType === 2 ||
currentScannedType === 3 ||
currentScannedType === 4) {
return;
if (currentScannedType === 2
|| currentScannedType === 3
|| currentScannedType === 4) {
continue;
}
if (fullLeadingWhitespace.match(_this.regExp)) {
_this.addFailure(_this.createFailure(lineStart, fullLeadingWhitespace.length, _this.failureString));
if (fullLeadingWhitespace.match(this.regExp)) {
this.addFailure(this.createFailure(lineStart, fullLeadingWhitespace.length, this.failureString));
}
});
}
};
return IndentWalker;
})(Lint.RuleWalker);

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -18,0 +18,0 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -58,7 +58,6 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

JsdocWalker.prototype.findFailuresForJsdocComment = function (commentText, startingPosition, sourceFile) {
var _this = this;
var currentPosition = startingPosition;
var lines = commentText.split(/\r?\n/);
var firstLine = lines[0];
var jsdocPosition = currentPosition;
var firstLine = lines[0];
var isJsdocMatch = firstLine.match(/^\s*\/\*\*/);

@@ -76,13 +75,14 @@ if (isJsdocMatch != null) {

jsdocPosition += firstLine.length + 1;
otherLines.forEach(function (line) {
for (var _i = 0; _i < otherLines.length; _i++) {
var line = otherLines[_i];
var asteriskMatch = line.match(/^\s*\*( |$)/);
if (asteriskMatch == null) {
_this.addFailureAt(jsdocPosition, line.length, Rule.FORMAT_FAILURE_STRING);
this.addFailureAt(jsdocPosition, line.length, Rule.FORMAT_FAILURE_STRING);
}
var asteriskIndex = line.indexOf("*");
if (asteriskIndex !== indexToMatch) {
_this.addFailureAt(jsdocPosition, line.length, Rule.ALIGNMENT_FAILURE_STRING);
this.addFailureAt(jsdocPosition, line.length, Rule.ALIGNMENT_FAILURE_STRING);
}
jsdocPosition += line.length + 1;
});
}
var lastLine = lines[lines.length - 1];

@@ -89,0 +89,0 @@ var endBlockCommentMatch = lastLine.match(/^\s*\*\/$/);

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -42,7 +42,7 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

var statement = node.statement;
if (statement.kind !== 184 &&
statement.kind !== 186 &&
statement.kind !== 187 &&
statement.kind !== 185 &&
statement.kind !== 193) {
if (statement.kind !== 184
&& statement.kind !== 186
&& statement.kind !== 187
&& statement.kind !== 185
&& statement.kind !== 193) {
var failure = this.createFailure(node.label.getStart(), node.label.getWidth(), Rule.FAILURE_STRING);

@@ -49,0 +49,0 @@ this.addFailure(failure);

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -18,0 +18,0 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -45,5 +45,5 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

return {
isInstance: modifierStrings.indexOf("static") === -1,
isMethod: isMethod,
isPrivate: modifierStrings.indexOf("private") !== -1,
isInstance: modifierStrings.indexOf("static") === -1
isPrivate: modifierStrings.indexOf("private") !== -1
};

@@ -92,5 +92,5 @@ }

this.previous = {
isInstance: false,
isMethod: false,
isPrivate: false,
isInstance: false
isPrivate: false
};

@@ -97,0 +97,0 @@ };

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -18,0 +18,0 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -18,0 +18,0 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -18,0 +18,0 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -32,5 +32,6 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

var consoleBanWalker = new BanRule.BanFunctionWalker(sourceFile, this.getOptions());
options.ruleArguments.forEach(function (option) {
for (var _i = 0, _a = options.ruleArguments; _i < _a.length; _i++) {
var option = _a[_i];
consoleBanWalker.addBannedFunction(["console", option]);
});
}
return this.applyWithWalker(consoleBanWalker);

@@ -37,0 +38,0 @@ };

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -41,13 +41,13 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

NoConstructorVariableDeclarationsWalker.prototype.visitConstructorDeclaration = function (node) {
var _this = this;
var parameters = node.parameters;
parameters.forEach(function (parameter) {
for (var _i = 0; _i < parameters.length; _i++) {
var parameter = parameters[_i];
if (parameter.modifiers != null && parameter.modifiers.length > 0) {
var name = parameter.name;
var errorMessage = "'" + name.text + "'" + Rule.FAILURE_STRING_PART;
var name_1 = parameter.name;
var errorMessage = "'" + name_1.text + "'" + Rule.FAILURE_STRING_PART;
var lastModifier = parameter.modifiers[parameter.modifiers.length - 1];
var position = lastModifier.getEnd() - parameter.getStart();
_this.addFailure(_this.createFailure(parameter.getStart(), position, errorMessage));
this.addFailure(this.createFailure(parameter.getStart(), position, errorMessage));
}
});
}
_super.prototype.visitConstructorDeclaration.call(this, node);

@@ -54,0 +54,0 @@ };

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -18,0 +18,0 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -18,0 +18,0 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -41,58 +41,50 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

NoDuplicateVariableWalker.prototype.createScope = function () {
return null;
};
NoDuplicateVariableWalker.prototype.createBlockScope = function () {
return new ScopeInfo();
};
NoDuplicateVariableWalker.prototype.visitParameterDeclaration = function (node) {
var propertyName = node.name;
var variableName = propertyName.text;
var currentScope = this.getCurrentScope();
if (currentScope.varNames.indexOf(variableName) >= 0) {
this.addFailureOnIdentifier(node.name);
NoDuplicateVariableWalker.prototype.visitBindingElement = function (node) {
var isSingleVariable = node.name.kind === 65;
var isBlockScoped = Lint.isBlockScopedBindingElement(node);
if (isSingleVariable && !isBlockScoped) {
this.handleSingleVariableIdentifier(node.name);
}
else {
currentScope.varNames.push(variableName);
}
_super.prototype.visitParameterDeclaration.call(this, node);
_super.prototype.visitBindingElement.call(this, node);
};
NoDuplicateVariableWalker.prototype.visitTypeLiteral = function (node) {
NoDuplicateVariableWalker.prototype.visitCatchClause = function (node) {
this.visitBlock(node.block);
};
NoDuplicateVariableWalker.prototype.visitMethodSignature = function (node) {
};
NoDuplicateVariableWalker.prototype.visitFunctionType = function (node) {
NoDuplicateVariableWalker.prototype.visitTypeLiteral = function (node) {
};
NoDuplicateVariableWalker.prototype.visitCatchClause = function (node) {
this.visitBlock(node.block);
};
NoDuplicateVariableWalker.prototype.visitVariableDeclaration = function (node) {
var propertyName = node.name;
var variableName = propertyName.text;
var currentScope = this.getCurrentScope();
var declarationIsLet = (Math.floor(node.parent.flags / 4096) % 2) === 1;
if (currentScope.varNames.indexOf(variableName) >= 0) {
this.addFailureOnIdentifier(propertyName);
var isSingleVariable = node.name.kind === 65;
if (isSingleVariable && !Lint.isBlockScopedVariable(node)) {
this.handleSingleVariableIdentifier(node.name);
}
else if (!declarationIsLet) {
if (currentScope.letNames.indexOf(variableName) >= 0) {
this.addFailureOnIdentifier(propertyName);
}
else {
currentScope.varNames.push(variableName);
}
_super.prototype.visitVariableDeclaration.call(this, node);
};
NoDuplicateVariableWalker.prototype.handleSingleVariableIdentifier = function (variableIdentifier) {
var variableName = variableIdentifier.text;
var currentBlockScope = this.getCurrentBlockScope();
if (currentBlockScope.varNames.indexOf(variableName) >= 0) {
this.addFailureOnIdentifier(variableIdentifier);
}
else {
currentScope.letNames.push(variableName);
currentBlockScope.varNames.push(variableName);
}
_super.prototype.visitVariableDeclaration.call(this, node);
};
NoDuplicateVariableWalker.prototype.addFailureOnIdentifier = function (ident) {
var failureString = Rule.FAILURE_STRING + ident.text + "'";
var failureString = "" + Rule.FAILURE_STRING + ident.text + "'";
this.addFailure(this.createFailure(ident.getStart(), ident.getWidth(), failureString));
};
return NoDuplicateVariableWalker;
})(Lint.ScopeAwareRuleWalker);
})(Lint.BlockScopeAwareRuleWalker);
var ScopeInfo = (function () {
function ScopeInfo() {
this.varNames = [];
this.letNames = [];
}
return ScopeInfo;
})();

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -54,12 +54,11 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

BlockWalker.prototype.visitConstructorDeclaration = function (node) {
var parameters = node.parameters;
var isSkipped = false;
var parameters = node.parameters;
for (var i = 0; i < parameters.length; i++) {
var param = parameters[i];
for (var j = 0; param.modifiers != null && j < param.modifiers.length; j++) {
if (this.isPropertyAccessModifier(param.modifiers[j].kind)) {
isSkipped = true;
this.ignoredBlocks.push(node.body);
break;
}
for (var _i = 0; _i < parameters.length; _i++) {
var param = parameters[_i];
var hasPropertyAccessModifier = Lint.hasModifier(param.modifiers, 106, 107, 108);
if (hasPropertyAccessModifier) {
isSkipped = true;
this.ignoredBlocks.push(node.body);
break;
}

@@ -72,8 +71,3 @@ if (isSkipped) {

};
BlockWalker.prototype.isPropertyAccessModifier = function (modifier) {
return modifier === 106
|| modifier === 107
|| modifier === 108;
};
return BlockWalker;
})(Lint.RuleWalker);

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -18,0 +18,0 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -18,0 +18,0 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -31,3 +31,3 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

};
Rule.FAILURE_STRING_PART = "Expected a 'break' before ";
Rule.FAILURE_STRING_PART = "expected a 'break' before ";
return Rule;

@@ -71,4 +71,4 @@ })(Lint.Rules.AbstractRule);

if (commentRanges != null) {
for (var i = 0; i < commentRanges.length; i++) {
var commentRange = commentRanges[i];
for (var _i = 0; _i < commentRanges.length; _i++) {
var commentRange = commentRanges[_i];
var commentText = sourceFileText.substring(commentRange.pos, commentRange.end);

@@ -82,12 +82,8 @@ if (commentText === "/* falls through */") {

};
NoSwitchCaseFallThroughWalker.prototype.fallsThrough = function (list) {
for (var i = 0; i < list.length; i++) {
var nodeKind = list[i].kind;
if (nodeKind === 190 ||
nodeKind === 195 ||
nodeKind === 191) {
return false;
}
}
return true;
NoSwitchCaseFallThroughWalker.prototype.fallsThrough = function (statements) {
return !statements.some(function (statement) {
return statement.kind === 190
|| statement.kind === 195
|| statement.kind === 191;
});
};

@@ -94,0 +90,0 @@ return NoSwitchCaseFallThroughWalker;

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -18,0 +18,0 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -18,0 +18,0 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -18,0 +18,0 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -18,0 +18,0 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

@@ -57,3 +57,3 @@ /*

var importClause = node.importClause;
if (importClause.name != null) {
if (importClause != null && importClause.name != null) {
var variableIdentifier = importClause.name;

@@ -67,4 +67,4 @@ this.validateReferencesForVariable(variableIdentifier.text, variableIdentifier.getStart());

if (!Lint.hasModifier(node.modifiers, 78)) {
var name = node.name;
this.validateReferencesForVariable(name.text, name.getStart());
var name_1 = node.name;
this.validateReferencesForVariable(name_1.text, name_1.getStart());
}

@@ -120,4 +120,4 @@ _super.prototype.visitImportEqualsDeclaration.call(this, node);

NoUnusedVariablesWalker.prototype.visitFunctionDeclaration = function (node) {
var variableName = node.name.text;
if (!Lint.hasModifier(node.modifiers, 78)) {
if (!Lint.hasModifier(node.modifiers, 78, 115)) {
var variableName = node.name.text;
this.validateReferencesForVariable(variableName, node.name.getStart());

@@ -124,0 +124,0 @@ }

@@ -47,9 +47,16 @@ /*

};
NoUseBeforeDeclareWalker.prototype.visitBindingElement = function (node) {
var isSingleVariable = node.name.kind === 65;
var isBlockScoped = Lint.isBlockScopedBindingElement(node);
if (isSingleVariable && !isBlockScoped) {
var variableName = node.name.text;
this.validateUsageForVariable(variableName, node.getStart());
}
_super.prototype.visitBindingElement.call(this, node);
};
NoUseBeforeDeclareWalker.prototype.visitImportDeclaration = function (node) {
if (node.importClause != null) {
var importClause = node.importClause;
if (importClause.name != null) {
var variableIdentifier = importClause.name;
this.validateUsageForVariable(variableIdentifier.text, variableIdentifier.getStart());
}
var importClause = node.importClause;
if (importClause != null && importClause.name != null) {
var variableIdentifier = importClause.name;
this.validateUsageForVariable(variableIdentifier.text, variableIdentifier.getStart());
}

@@ -64,6 +71,6 @@ _super.prototype.visitImportDeclaration.call(this, node);

NoUseBeforeDeclareWalker.prototype.visitNamedImports = function (node) {
var _this = this;
node.elements.forEach(function (namedImport) {
_this.validateUsageForVariable(namedImport.name.text, namedImport.name.getStart());
});
for (var _i = 0, _a = node.elements; _i < _a.length; _i++) {
var namedImport = _a[_i];
this.validateUsageForVariable(namedImport.name.text, namedImport.name.getStart());
}
_super.prototype.visitNamedImports.call(this, node);

@@ -77,6 +84,5 @@ };

var isSingleVariable = node.name.kind === 65;
var nameNode = node.name;
var variableName = nameNode.text;
var variableName = node.name.text;
var currentScope = this.getCurrentScope();
if (currentScope[variableName] == null) {
if (isSingleVariable && currentScope[variableName] == null) {
this.validateUsageForVariable(variableName, node.getStart());

@@ -88,14 +94,13 @@ }

NoUseBeforeDeclareWalker.prototype.validateUsageForVariable = function (name, position) {
var _this = this;
var highlights = this.languageService.getDocumentHighlights("file.ts", position, ["file.ts"]);
if (highlights) {
highlights.forEach(function (highlight) {
highlight.highlightSpans.forEach(function (highlightSpan) {
var referencePosition = highlightSpan.textSpan.start;
if (referencePosition < position) {
var failureString = Rule.FAILURE_STRING_PREFIX + name + Rule.FAILURE_STRING_POSTFIX;
_this.addFailure(_this.createFailure(referencePosition, name.length, failureString));
}
});
});
for (var _i = 0; _i < highlights.length; _i++) {
var highlight = highlights[_i];
for (var _a = 0, _b = highlight.highlightSpans; _a < _b.length; _a++) {
var highlightSpan = _b[_a];
var referencePosition = highlightSpan.textSpan.start;
if (referencePosition < position) {
var failureString = Rule.FAILURE_STRING_PREFIX + name + Rule.FAILURE_STRING_POSTFIX;
this.addFailure(this.createFailure(referencePosition, name.length, failureString));
}
}
}

@@ -102,0 +107,0 @@ };

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -23,3 +23,2 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

};
///<reference path='../../lib/tslint.d.ts' />
var OPTION_LEADING_UNDERSCORE = "no-var-keyword";

@@ -35,3 +34,3 @@ var Rule = (function (_super) {

};
Rule.FAILURE_STRING = "use of the var-keyword is disallowed, use 'let' or 'const' instead";
Rule.FAILURE_STRING = "forbidden const keyword";
return Rule;

@@ -46,10 +45,5 @@ })(Lint.Rules.AbstractRule);

NoVarKeywordWalker.prototype.visitVariableStatement = function (node) {
if (!Lint.hasModifier(node.modifiers, 78)
&& !Lint.hasModifier(node.modifiers, 115)) {
var flags = node.declarationList.flags;
var declarationIsLet = (Math.floor(flags / 4096) % 2) === 1;
var declarationIsConst = (Math.floor(flags / 8192) % 2) === 1;
if (!declarationIsConst && !declarationIsLet) {
this.addFailure(this.createFailure(node.getStart(), "var".length, Rule.FAILURE_STRING));
}
if (!Lint.hasModifier(node.modifiers, 78, 115)
&& !Lint.isBlockScopedVariable(node)) {
this.addFailure(this.createFailure(node.getStart(), "var".length, Rule.FAILURE_STRING));
}

@@ -56,0 +50,0 @@ _super.prototype.visitVariableStatement.call(this, node);

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -18,0 +18,0 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -18,0 +18,0 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -65,3 +65,3 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

QuoteWalker.prototype.handleNode = function (node) {
var failure = null;
var failure;
if (node.kind === 8) {

@@ -84,3 +84,3 @@ var text = node.getText();

}
if (failure) {
if (failure != null) {
this.addFailure(failure);

@@ -87,0 +87,0 @@ }

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -43,5 +43,5 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

var expression = node.expression;
if (expression.kind === 65 &&
node.getFirstToken().getText() === "parseInt" &&
node.arguments.length < 2) {
if (expression.kind === 65
&& node.getFirstToken().getText() === "parseInt"
&& node.arguments.length < 2) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING));

@@ -48,0 +48,0 @@ }

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -85,6 +85,6 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

SemicolonWalker.prototype.visitInterfaceDeclaration = function (node) {
var _this = this;
node.members.forEach(function (member) {
_this.checkSemicolonAt(member);
});
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
var member = _a[_i];
this.checkSemicolonAt(member);
}
_super.prototype.visitInterfaceDeclaration.call(this, node);

@@ -94,4 +94,4 @@ };

var children = node.getChildren(this.getSourceFile());
for (var i = 0; i < children.length; i++) {
var child = children[i];
for (var _i = 0; _i < children.length; _i++) {
var child = children[_i];
if (child.kind === 22) {

@@ -98,0 +98,0 @@ return;

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -18,0 +18,0 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

@@ -15,3 +15,3 @@ /*

* limitations under the License.
*/
*/
var __extends = this.__extends || function (d, b) {

@@ -41,5 +41,3 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];

SwitchDefaultWalker.prototype.visitSwitchStatement = function (node) {
var hasDefaultCase = node.caseBlock.clauses.some(function (clause) {
return clause.kind === 221;
});
var hasDefaultCase = node.caseBlock.clauses.some(function (clause) { return clause.kind === 221; });
if (!hasDefaultCase) {

@@ -46,0 +44,0 @@ this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING));

@@ -61,4 +61,4 @@ /*

var nullKeyword = 89;
return this.hasOption(OPTION_ALLOW_NULL_CHECK) &&
(node.left.kind === nullKeyword || node.right.kind === nullKeyword);
return this.hasOption(OPTION_ALLOW_NULL_CHECK)
&& (node.left.kind === nullKeyword || node.right.kind === nullKeyword);
};

@@ -65,0 +65,0 @@ ComparisonWalker.COMPARISON_OPERATOR_WIDTH = 2;

@@ -61,19 +61,19 @@ /*

TypedefWalker.prototype.visitObjectLiteralExpression = function (node) {
var _this = this;
node.properties.forEach(function (property) {
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
var property = _a[_i];
switch (property.kind) {
case 224:
_this.visitPropertyAssignment(property);
this.visitPropertyAssignment(property);
break;
case 134:
_this.visitMethodDeclaration(property);
this.visitMethodDeclaration(property);
break;
case 136:
_this.visitGetAccessor(property);
this.visitGetAccessor(property);
break;
case 137:
_this.visitSetAccessor(property);
this.visitSetAccessor(property);
break;
}
});
}
};

@@ -110,4 +110,4 @@ TypedefWalker.prototype.visitParameterDeclaration = function (node) {

TypedefWalker.prototype.visitVariableDeclaration = function (node) {
if (node.parent.parent.kind !== 187 &&
node.parent.kind !== 223) {
if (node.parent.parent.kind !== 187
&& node.parent.kind !== 223) {
this.checkTypeAnnotation("variable-declaration", node.name.getEnd(), node.type, node.name);

@@ -114,0 +114,0 @@ }

@@ -88,4 +88,4 @@ /*

if (this.hasOption(option) && typeNode != null && positionBeforeColon != null) {
var scanner = ts.createScanner(1, false, node.getText());
var hasLeadingWhitespace;
var scanner = ts.createScanner(1, false, node.getText());
scanner.setTextPos(positionBeforeColon - node.getStart());

@@ -92,0 +92,0 @@ hasLeadingWhitespace = scanner.scan() === 5;

@@ -44,11 +44,8 @@ /*

UseStrictWalker.prototype.visitModuleDeclaration = function (node) {
var modifiers = node.modifiers;
var hasDeclareModifier = (modifiers != null) && (modifiers.length > 0) && (modifiers[0].kind === 115);
if (this.getCurrentDepth() === 2 && !hasDeclareModifier) {
if (this.hasOption(UseStrictWalker.OPTION_CHECK_MODULE) &&
node.body != null &&
node.body.kind === 206 &&
this.hasOption(UseStrictWalker.OPTION_CHECK_MODULE)) {
this.handleBlock(node, node.body);
}
if (this.getCurrentDepth() === 2
&& !Lint.hasModifier(node.modifiers, 115)
&& this.hasOption(UseStrictWalker.OPTION_CHECK_MODULE)
&& node.body != null
&& node.body.kind === 206) {
this.handleBlock(node, node.body);
}

@@ -71,4 +68,4 @@ _super.prototype.visitModuleDeclaration.call(this, node);

var firstChild = firstStatement.getChildAt(0);
if (firstChild.kind === 8 &&
firstChild.text === UseStrictWalker.USE_STRICT_STRING) {
if (firstChild.kind === 8
&& firstChild.text === UseStrictWalker.USE_STRICT_STRING) {
isFailure = false;

@@ -75,0 +72,0 @@ }

@@ -193,5 +193,5 @@ /*

var nextTokenType = this.scanner.scan();
if (nextTokenType !== 5 &&
nextTokenType !== 4 &&
nextTokenType !== 1) {
if (nextTokenType !== 5
&& nextTokenType !== 4
&& nextTokenType !== 1) {
this.addFailure(this.createFailure(position, 1, Rule.FAILURE_STRING));

@@ -198,0 +198,0 @@ }

Change Log
===
v2.3.1-beta
---
* [bugs] #137 #434 #451 #456
* [new-rule] `no-require-imports` disallows `require()` style imports
* [new-rule] `no-shadowed-variable` moves over shadowed variable checking from `no-duplicate-variable` into its own rule
* **BREAKING**
* `no-duplicate-variable` now only checks for duplicates within the same block scope; enable `no-shadowed-variable` to get duplicate-variable checking across block scopes
* [enhancement] `no-duplicate-variable`, `no-shadowed-variable`, and `no-use-before-declare` now support ES6 destructuring
* [enhancement] tslint CLI now uses a default configuration if no config file is found
v2.3.0-beta

@@ -12,3 +23,2 @@ ---

===
v2.2.0-beta

@@ -27,3 +37,2 @@ ---

===
v2.1.1

@@ -38,3 +47,3 @@ ---

* Fix crash on Windows
---
v2.0.1

@@ -65,3 +74,2 @@ ---

---
* upgrade TypeScript compiler to 1.3

@@ -76,3 +84,2 @@ * **BREAKING CHANGES**

---
* multiple files with -f on cli

@@ -83,3 +90,2 @@ * config file search starts with input file

---
* [bugs] #136, #163

@@ -90,3 +96,2 @@ * internal refactors

---
* [bugs] #138, #145, #146, #148

@@ -96,5 +101,4 @@

---
* [new-rule] `no-any` disallows all uses of `any`
* [bug] /* tslint:disable */ now disables semicolon rule as well
* [bug] `/* tslint:disable */` now disables semicolon rule as well
* [bug] delete operator no longer results in a false positive for `no-unused-expression`

@@ -104,3 +108,2 @@

---
* [new-rule] `no-var-requires` disallows require statements not part of an import statement

@@ -115,3 +118,2 @@ * [new-rule] `typedef` rule also checks for member variables

---
* [new-rule] added `no-unused-expression` rule which disallows unused expression statements

@@ -146,3 +148,2 @@ * [feature] the `check-operator` option for the `whitespace` rule now checks whitespace around the => token

---
* [new-rule] `no-unused-variable`

@@ -149,0 +150,0 @@ * [new-rule] `no-trailing-comma`

@@ -41,5 +41,7 @@ {

"no-duplicate-key": true,
"no-shadowed-variable": true,
"no-duplicate-variable": true,
"no-empty": true,
"no-eval": true,
"no-require-imports": true,
"no-string-literal": true,

@@ -46,0 +48,0 @@ "no-switch-case-fall-through": true,

@@ -70,2 +70,37 @@ declare module Lint {

}
declare module Lint {
class RuleWalker extends Lint.SyntaxWalker {
private limit;
private position;
private options;
private failures;
private sourceFile;
private disabledIntervals;
private ruleName;
constructor(sourceFile: ts.SourceFile, options: Lint.IOptions);
getSourceFile(): ts.SourceFile;
getFailures(): RuleFailure[];
getLimit(): number;
getOptions(): any;
hasOption(option: string): boolean;
skip(node: ts.Node): void;
createFailure(start: number, width: number, failure: string): RuleFailure;
addFailure(failure: RuleFailure): void;
private existsFailure(failure);
}
}
declare module Lint {
class ScopeAwareRuleWalker<T> extends RuleWalker {
private scopeStack;
constructor(sourceFile: ts.SourceFile, options?: any);
createScope(): T;
getCurrentScope(): T;
getAllScopes(): T[];
getCurrentDepth(): number;
onScopeStart(): void;
onScopeEnd(): void;
protected visitNode(node: ts.Node): void;
protected isScopeBoundary(node: ts.Node): boolean;
}
}
declare module Lint.Formatters {

@@ -118,5 +153,5 @@ class AbstractFormatter implements Lint.IFormatter {

toJson(): {
character: number;
line: number;
position: number;
line: number;
character: number;
};

@@ -135,4 +170,4 @@ equals(ruleFailurePosition: RuleFailurePosition): boolean;

getRuleName(): string;
getStartPosition(): Lint.RuleFailurePosition;
getEndPosition(): Lint.RuleFailurePosition;
getStartPosition(): RuleFailurePosition;
getEndPosition(): RuleFailurePosition;
getFailure(): string;

@@ -151,35 +186,16 @@ toJson(): any;

function hasModifier(modifiers: ts.ModifiersArray, ...modifierKinds: ts.SyntaxKind[]): boolean;
function isBlockScopedVariable(node: ts.VariableDeclaration | ts.VariableStatement): boolean;
function isBlockScopedBindingElement(node: ts.BindingElement): boolean;
}
declare module Lint {
class RuleWalker extends Lint.SyntaxWalker {
private limit;
private position;
private options;
private failures;
private sourceFile;
private disabledIntervals;
private ruleName;
constructor(sourceFile: ts.SourceFile, options: Lint.IOptions);
getSourceFile(): ts.SourceFile;
getFailures(): RuleFailure[];
getLimit(): number;
getOptions(): any;
hasOption(option: string): boolean;
skip(node: ts.Node): void;
createFailure(start: number, width: number, failure: string): Lint.RuleFailure;
addFailure(failure: RuleFailure): void;
private existsFailure(failure);
}
}
declare module Lint {
class ScopeAwareRuleWalker<T> extends RuleWalker {
private scopeStack;
class BlockScopeAwareRuleWalker<T, U> extends ScopeAwareRuleWalker<T> {
private blockScopeStack;
constructor(sourceFile: ts.SourceFile, options?: any);
createScope(): T;
getCurrentScope(): T;
getCurrentDepth(): number;
onScopeStart(): void;
onScopeEnd(): void;
createBlockScope(): U;
getCurrentBlockScope(): U;
onBlockScopeStart(): void;
getCurrentBlockDepth(): number;
onBlockScopeEnd(): void;
protected visitNode(node: ts.Node): void;
private isScopeBoundary(node);
private isBlockScopeBoundary(node);
}

@@ -249,1 +265,4 @@ }

}
declare module "tslint" {
export = Lint;
}
{
"name": "tslint",
"version": "2.3.0-beta",
"version": "2.3.1-beta",
"description": "a static analysis linter for TypeScript",

@@ -5,0 +5,0 @@ "bin": {

@@ -46,3 +46,3 @@ [![NPM version](https://badge.fury.io/js/tslint.svg)](http://badge.fury.io/js/tslint)

The location of the TypeScript file that you wish to lint. This
option is required. Muliptle files are processed consecutively.
option is required. Multiple files are processed consecutively.

@@ -163,5 +163,7 @@ -c, --config:

* `no-duplicate-key` disallows duplicate keys in object literals.
* `no-duplicate-variable` disallows duplicate variable declarations.
* `no-duplicate-variable` disallows duplicate variable declarations in the same block scope.
* `no-shadowed-variable` disallows shadowed variable declarations.
* `no-empty` disallows empty blocks.
* `no-eval` disallows `eval` function invocations.
* `no-require-imports` disallows require() style imports
* `no-string-literal` disallows object access via string literals.

@@ -168,0 +170,0 @@ * `no-switch-case-fall-through` disallows falling through case statements.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

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