From 0b7e459f7826995e50dab05169d528bebb58c9b4 Mon Sep 17 00:00:00 2001 From: Nathan White Date: Sat, 18 Feb 2017 20:31:48 -0700 Subject: [PATCH] fix(templatesUsePublicRule): Pass member name back through error Pass the class member name to the error for more clarification fixes #229 --- src/templatesUsePublicRule.ts | 2 +- test/templatesUsePublicRule.spec.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/templatesUsePublicRule.ts b/src/templatesUsePublicRule.ts index 8ec0719d7..b7be45288 100644 --- a/src/templatesUsePublicRule.ts +++ b/src/templatesUsePublicRule.ts @@ -41,7 +41,7 @@ class SymbolAccessValidator extends RecursiveAngularExpressionVisitor { .some(m => m.kind === SyntaxKind.current().PrivateKeyword || m.kind === SyntaxKind.current().ProtectedKeyword); const width = ast.name.length; if (!isPublic) { - const failureString = 'You can bind only to public class members.'; + const failureString = `You can bind only to public class members. ${member.name.getText()} is not a public class member.`; this.addFailure(this.createFailure(ast.span.start, width, failureString)); } } diff --git a/test/templatesUsePublicRule.spec.ts b/test/templatesUsePublicRule.spec.ts index 86d339b0c..908b27ce6 100644 --- a/test/templatesUsePublicRule.spec.ts +++ b/test/templatesUsePublicRule.spec.ts @@ -12,7 +12,7 @@ describe('templates-use-public', () => { constructor(private foo: number) {} }`; assertFailure('templates-use-public', source, { - message: 'You can bind only to public class members.', + message: 'You can bind only to public class members. foo is not a public class member.', startPosition: { line: 3, character: 24 @@ -34,7 +34,7 @@ describe('templates-use-public', () => { private foo: number; }`; assertFailure('templates-use-public', source, { - message: 'You can bind only to public class members.', + message: 'You can bind only to public class members. foo is not a public class member.', startPosition: { line: 3, character: 29 @@ -56,7 +56,7 @@ describe('templates-use-public', () => { protected foo: number; }`; assertFailure('templates-use-public', source, { - message: 'You can bind only to public class members.', + message: 'You can bind only to public class members. foo is not a public class member.', startPosition: { line: 3, character: 29 @@ -78,7 +78,7 @@ describe('templates-use-public', () => { protected foo: number; }`; assertFailure('templates-use-public', source, { - message: 'You can bind only to public class members.', + message: 'You can bind only to public class members. foo is not a public class member.', startPosition: { line: 3, character: 29 @@ -100,7 +100,7 @@ describe('templates-use-public', () => { protected foo: number; }`; assertFailure('templates-use-public', source, { - message: 'You can bind only to public class members.', + message: 'You can bind only to public class members. foo is not a public class member.', startPosition: { line: 3, character: 35 @@ -122,7 +122,7 @@ describe('templates-use-public', () => { protected foo() {}; }`; assertFailure('templates-use-public', source, { - message: 'You can bind only to public class members.', + message: 'You can bind only to public class members. foo is not a public class member.', startPosition: { line: 3, character: 33