forked from cwoolum/ionicV4-tslint
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rules): add ion-fab-button-is-now-an-element rule
* feat(rules): add ion-fab-button-is-now-an-element rule * docs(readme): update readme with completed rule
- Loading branch information
1 parent
c48e556
commit f793b16
Showing
3 changed files
with
100 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { createDirectiveToElementRuleClass } from './helpers/directiveToElement'; | ||
|
||
const directive = 'ion-fab'; | ||
const resultantElement = 'ion-fab-button'; | ||
|
||
export const ruleName = 'ion-fab-button-is-now-an-element'; | ||
export const Rule = createDirectiveToElementRuleClass(ruleName, directive, resultantElement); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { ruleName } from '../src/ionFabButtonIsNowAnElementRule'; | ||
import { assertAnnotated, assertSuccess } from './testHelper'; | ||
|
||
describe(ruleName, () => { | ||
describe('success', () => { | ||
it('should not trigger for parent ion-fab', () => { | ||
let source = ` | ||
@Component({ | ||
template: \` | ||
<ion-fab> | ||
<ion-fab-button></ion-fab-button> | ||
<ion-fab-list> | ||
<ion-fab-button></ion-fab-button> | ||
<ion-fab-button></ion-fab-button> | ||
</ion-fab-list> | ||
</ion-fab> | ||
\` | ||
}) | ||
class Bar{} | ||
`; | ||
assertSuccess(ruleName, source); | ||
}); | ||
|
||
it('should work with proper style', () => { | ||
let source = ` | ||
@Component({ | ||
template: \`<ion-fab-button></ion-fab-button>\` | ||
}) | ||
class Bar{} | ||
`; | ||
assertSuccess(ruleName, source); | ||
}); | ||
}); | ||
|
||
describe('failure', () => { | ||
it('should fail when ion-fab attribute is used on button', () => { | ||
let source = ` | ||
@Component({ | ||
template: \` | ||
<button ion-fab></button>\` | ||
~~~~~~~ | ||
}) | ||
class Bar{} | ||
`; | ||
|
||
assertAnnotated({ | ||
ruleName, | ||
message: 'ion-fab is now an ion-fab-button element instead of an Angular directive.', | ||
source | ||
}); | ||
}); | ||
|
||
it('should fail when ion-fab attribute is used on anchor', () => { | ||
let source = ` | ||
@Component({ | ||
template: \` | ||
<a ion-fab (click)="doSomething()"></a>\` | ||
~~~~~~~ | ||
}) | ||
class Bar{} | ||
`; | ||
|
||
assertAnnotated({ | ||
ruleName, | ||
message: 'ion-fab is now an ion-fab-button element instead of an Angular directive.', | ||
source | ||
}); | ||
}); | ||
|
||
it('should fail when ion-fab attribute is used with multiline', () => { | ||
let source = ` | ||
@Component({ | ||
template: \` | ||
<a | ||
ion-fab | ||
~~~~~~~ | ||
(click)="doSomething()">Click Me</a>\` | ||
}) | ||
class Bar{} | ||
`; | ||
|
||
assertAnnotated({ | ||
ruleName, | ||
message: 'ion-fab is now an ion-fab-button element instead of an Angular directive.', | ||
source | ||
}); | ||
}); | ||
}); | ||
}); |