From 8159a353faf4c1007cd7574e0db79630cfa7d5a3 Mon Sep 17 00:00:00 2001 From: Alexander Loktionov Date: Sun, 24 Jun 2018 10:35:44 +0700 Subject: [PATCH 1/3] fix(no-output-on-prefix): fix regular expression this commit fixes incorrect behavior when memberName contains 'on' suffix in the word, for example selectionChanged. ``` /on((?![a-z])|(?=$))/.test('selectionChanged'); // true /^on((?![a-z])|(?=$))/.test('selectionChanged'); // false ``` --- src/noOutputOnPrefixRule.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/noOutputOnPrefixRule.ts b/src/noOutputOnPrefixRule.ts index fc41e5430..4da05c3ad 100644 --- a/src/noOutputOnPrefixRule.ts +++ b/src/noOutputOnPrefixRule.ts @@ -34,7 +34,7 @@ class OutputWalker extends NgWalker { const className = getClassName(property); const memberName = property.name.getText(); - if (!memberName || !/on((?![a-z])|(?=$))/.test(memberName)) { + if (!memberName || !/^on((?![a-z])|(?=$))/.test(memberName)) { return; } From 528851c715aee31c5820cbc579110e9f5e7a7f39 Mon Sep 17 00:00:00 2001 From: Alexander Loktionov Date: Sun, 24 Jun 2018 10:55:21 +0700 Subject: [PATCH 2/3] test(no-output-on-prefix): add more test cases --- test/noOutputOnPrefixRule.spec.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/noOutputOnPrefixRule.spec.ts b/test/noOutputOnPrefixRule.spec.ts index 170caae3c..7bab29985 100644 --- a/test/noOutputOnPrefixRule.spec.ts +++ b/test/noOutputOnPrefixRule.spec.ts @@ -69,4 +69,16 @@ describe('no-output-on-prefix', () => { assertSuccess('no-output-on-prefix', source); }); }); + + describe('valid output property name', () => { + it("should succeed, when a output property containing 'on' suffix", () => { + const source = ` + @Component() + class SelectComponent { + @Output() selectionChanged = new EventEmitter(); + } + `; + assertSuccess('no-output-on-prefix', source); + }); + }); }); From 0ea7a1b8e65b85e029355efccaed850d7ec4e74d Mon Sep 17 00:00:00 2001 From: Alexander Loktionov Date: Sun, 24 Jun 2018 11:16:37 +0700 Subject: [PATCH 3/3] style(no-output-on-prefix): fix misspellings --- test/noOutputOnPrefixRule.spec.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/noOutputOnPrefixRule.spec.ts b/test/noOutputOnPrefixRule.spec.ts index 7bab29985..3bacc037e 100644 --- a/test/noOutputOnPrefixRule.spec.ts +++ b/test/noOutputOnPrefixRule.spec.ts @@ -68,10 +68,8 @@ describe('no-output-on-prefix', () => { `; assertSuccess('no-output-on-prefix', source); }); - }); - describe('valid output property name', () => { - it("should succeed, when a output property containing 'on' suffix", () => { + it("should succeed, when an output property containing 'on' suffix", () => { const source = ` @Component() class SelectComponent {