Skip to content

Commit

Permalink
feat: add additional predefined directives
Browse files Browse the repository at this point in the history
Fix #199
  • Loading branch information
mgechev committed Dec 21, 2016
1 parent 9721a62 commit 36f5cb4
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/angular/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,15 @@ export const Config: Config = {
},

predefinedDirectives: [
{ selector: 'form', exportAs: 'ngForm' }
{ selector: 'form', exportAs: 'ngForm' },
{ selector: '[routerLinkActive]', exportAs: 'routerLinkActive' },
{ selector: '[ngModel]:not([formControlName]):not([formControl])', exportAs: 'ngModel' },
{ selector: '[md-menu-item], [mat-menu-item]', exportAs: 'mdMenuItem' },
{ selector: 'md-menu, mat-menu', exportAs: 'mdMenu' },
{ selector: 'md-button-toggle-group:not([multiple])', exportAs: 'mdButtonToggleGroup' },
{ selector: '[md-menu-trigger-for], [mat-menu-trigger-for], [mdMenuTriggerFor]', exportAs: 'mdMenuTrigger' },
{ selector: '[md-tooltip], [mat-tooltip], [mdTooltip]', exportAs: 'mdTooltip' },
{ selector: 'md-select, mat-select', exportAs: 'mdSelect' }
],

logLevel: BUILD_TYPE === 'dev' ? LogLevel.Debug : LogLevel.None
Expand Down
87 changes: 87 additions & 0 deletions test/noAccessMissingMemberRule.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,93 @@ describe('no-access-missing-member', () => {
assertSuccess('no-access-missing-member', source);
});

it('should not throw when routerLinkActive template ref is used in component', () => {
let source = `
@Component({
selector: 'foobar',
template: '<a #test="routerLinkActive" [routerLinkActive]="">{{ test }}</a>'
})
class Test {}`;
assertSuccess('no-access-missing-member', source);
});


it('should not throw when ngModel template ref is used in component', () => {
let source = `
@Component({
selector: 'foobar',
template: '<input #test="ngModel" [(ngModel)]="foo">{{ test }}'
})
class Test {
foo: string;
}`;
assertSuccess('no-access-missing-member', source);
});

it('should not throw when [md-menu-item] template ref is used in component', () => {
let source = `
@Component({
selector: 'foobar',
template: '<div md-menu-item #test="mdMenuItem">{{ test }}</div>'
})
class Test {
foo: string;
}`;
assertSuccess('no-access-missing-member', source);
});

it('should not throw when md-menu template ref is used in component', () => {
let source = `
@Component({
selector: 'foobar',
template: '<md-menu #test="mdMenu">{{ test }}</md-menu>'
})
class Test {
foo: string;
}`;
assertSuccess('no-access-missing-member', source);
});

it('should not throw when md-button-toggle-group template ref is used in component', () => {
let source = `
@Component({
selector: 'foobar',
template: '<md-button-toggle-group #test="mdButtonToggleGroup">{{ test }}</md-button-toggle-group>'
})
class Test {}`;
assertSuccess('no-access-missing-member', source);
});

it('should not throw when md-menu-trigger-for template ref is used in component', () => {
let source = `
@Component({
selector: 'foobar',
template: '<div mdMenuTriggerFor #test="mdMenuTrigger">{{ test }}</div>'
})
class Test {}`;
assertSuccess('no-access-missing-member', source);
});

it('should not throw when mdTooltip template ref is used in component', () => {
let source = `
@Component({
selector: 'foobar',
template: '<div mdTooltip #test="mdTooltip">{{ test }}</div>'
})
class Test {}`;
assertSuccess('no-access-missing-member', source);
});

it('should not throw when mdSelect template ref is used in component', () => {
let source = `
@Component({
selector: 'foobar',
template: '<md-select #test="mdSelect">{{ test }}</md-select>'
})
class Test {}`;
assertSuccess('no-access-missing-member', source);
});

it('should fail with missing ref', () => {
let source = `
@Component({
Expand Down

0 comments on commit 36f5cb4

Please sign in to comment.