tslint-eslint-rules
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -9,3 +9,3 @@ "use strict"; | ||
} | ||
Rule.FAILURE_STRING = 'error parameter not handled'; | ||
Rule.FAILURE_STRING = 'Expected error to be handled'; | ||
exports.Rule = Rule; | ||
@@ -17,3 +17,3 @@ class ErrCallbackHandlerWalker extends Lint.RuleWalker { | ||
const customExpression = options.ruleArguments[0] || 'err'; | ||
if (customExpression.indexOf('^') === 0) { | ||
if (customExpression.charAt(0) === '^') { | ||
this.errorRegex = new RegExp(customExpression); | ||
@@ -26,14 +26,13 @@ } | ||
visitFunctionDeclaration(node) { | ||
node.parameters | ||
.filter(parameter => this.errorRegex.test(parameter.name.getText())) | ||
.forEach((parameter) => { | ||
this.validateReferencesForVariable(parameter.name.getText(), parameter.pos); | ||
}); | ||
const parameter = node.parameters[0]; | ||
if (parameter && this.errorRegex.test(parameter.name.getText())) { | ||
this.validateReferencesForVariable(parameter); | ||
} | ||
super.visitFunctionDeclaration(node); | ||
} | ||
validateReferencesForVariable(name, position) { | ||
validateReferencesForVariable(node) { | ||
const fileName = this.getSourceFile().fileName; | ||
const highlights = this.languageService.getDocumentHighlights(fileName, position, [fileName]); | ||
const highlights = this.languageService.getDocumentHighlights(fileName, node.pos, [fileName]); | ||
if (!highlights || highlights[0].highlightSpans.length <= 1) { | ||
this.addFailure(this.createFailure(position, name.length, `${Rule.FAILURE_STRING}'${name}'`)); | ||
this.addFailure(this.createFailure(node.name.getStart(), node.name.getWidth(), Rule.FAILURE_STRING)); | ||
} | ||
@@ -43,2 +42,2 @@ } | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL2hhbmRsZUNhbGxiYWNrRXJyUnVsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQ0EsTUFBWSxJQUFJLFdBQU0saUJBQWlCLENBQUMsQ0FBQTtBQUV4QyxtQkFBMEIsSUFBSSxDQUFDL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ENBQUMsQ0FBQyxjQUFjLENBQUMsTUFBTSxJQUFJLENBQUMsQ0FBQyxDQUFDLENBQUM7WUFDNUQsSUFBSSxDQUFDLFVBQVUsQ0FBQyxJQUFJLENBQUMsYUFBYSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsUUFBUSxFQUFFLEVBQUUsSUFBSSxDQUFDLElBQUksQ0FBQyxRQUFRLEVBQUUsRUFBRSxJQUFJLENBQUMsY0FBYyxDQUFDLENBQUMsQ0FBQztRQUN2RyxDQUFDO0lBQ0gsQ0FBQztBQUNILENBQUM7QUFBQSIsImZpbGUiOiJydWxlcy9oYW5kbGVDYWxsYmFja0VyclJ1bGUuanMiLCJzb3VyY2VSb290IjoiZDpcXHByb2plY3RzXFx0c2xpbnQtZXNsaW50LXJ1bGVzXFxzcmMifQ== |
{ | ||
"name": "tslint-eslint-rules", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Improve your TSLint with the missing ESLint Rules", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
391310
5524