Skip to content

Commit b5e46c3

Browse files
committed
refactor: clean out variables that are being assigned to but not being read
Clears out private properties and local variables that are declared and assigned values, but aren't actually being read at any point. This will start being caught by tslint once we update to TS 2.6.
1 parent 008ee07 commit b5e46c3

File tree

23 files changed

+20
-132
lines changed

23 files changed

+20
-132
lines changed

src/cdk/a11y/focus-trap/focus-trap.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,10 @@ describe('FocusTrap', () => {
7676

7777
describe('with bindings', () => {
7878
let fixture: ComponentFixture<FocusTrapWithBindings>;
79-
let focusTrapInstance: FocusTrap;
8079

8180
beforeEach(() => {
8281
fixture = TestBed.createComponent(FocusTrapWithBindings);
8382
fixture.detectChanges();
84-
focusTrapInstance = fixture.componentInstance.focusTrapDirective.focusTrap;
8583
});
8684

8785
it('should clean up its anchor sibling elements on destroy', () => {

src/cdk/layout/media-matcher.spec.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import {LayoutModule, BreakpointObserver} from './index';
8+
import {LayoutModule} from './index';
99
import {MediaMatcher} from './media-matcher';
1010
import {async, TestBed, inject} from '@angular/core/testing';
1111
import {Platform} from '@angular/cdk/platform';
1212

1313
describe('MediaMatcher', () => {
14-
let breakpointManager: BreakpointObserver;
1514
let mediaMatcher: MediaMatcher;
1615

1716
beforeEach(async(() => {
@@ -20,12 +19,9 @@ describe('MediaMatcher', () => {
2019
});
2120
}));
2221

23-
beforeEach(inject(
24-
[BreakpointObserver, MediaMatcher],
25-
(bm: BreakpointObserver, mm: MediaMatcher) => {
26-
breakpointManager = bm;
27-
mediaMatcher = mm;
28-
}));
22+
beforeEach(inject([MediaMatcher], (mm: MediaMatcher) => {
23+
mediaMatcher = mm;
24+
}));
2925

3026
it('correctly returns a MediaQueryList to check for matches', () => {
3127
expect(mediaMatcher.matchMedia('(min-width: 1px)').matches).toBeTruthy();

src/cdk/overlay/position/connected-position-strategy.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ import {OverlayRef} from '../overlay-ref';
3535
* of the overlay.
3636
*/
3737
export class ConnectedPositionStrategy implements PositionStrategy {
38-
/** The overlay to which this strategy is attached. */
39-
private _overlayRef: OverlayRef;
40-
4138
/** Layout direction of the position strategy. */
4239
private _dir = 'ltr';
4340

@@ -100,7 +97,6 @@ export class ConnectedPositionStrategy implements PositionStrategy {
10097

10198
/** Attach this position strategy to an overlay. */
10299
attach(overlayRef: OverlayRef): void {
103-
this._overlayRef = overlayRef;
104100
this._pane = overlayRef.overlayElement;
105101
this._resizeSubscription.unsubscribe();
106102
this._resizeSubscription = this._viewportRuler.change().subscribe(() => this.apply());

src/lib/autocomplete/autocomplete.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,6 +1437,7 @@ describe('MatAutocomplete', () => {
14371437
zone.simulateZoneExit();
14381438

14391439
expect(spy).toHaveBeenCalledWith(jasmine.any(MatOptionSelectionChange));
1440+
subscription!.unsubscribe();
14401441
}));
14411442

14421443
});

src/lib/button-toggle/button-toggle.spec.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ describe('MatButtonToggle with forms', () => {
8080
describe('button toggle group with ngModel and change event', () => {
8181
let fixture: ComponentFixture<ButtonToggleGroupWithNgModel>;
8282
let groupDebugElement: DebugElement;
83-
let groupNativeElement: HTMLElement;
8483
let buttonToggleDebugElements: DebugElement[];
85-
let buttonToggleNativeElements: HTMLElement[];
8684
let groupInstance: MatButtonToggleGroup;
8785
let buttonToggleInstances: MatButtonToggle[];
8886
let testComponent: ButtonToggleGroupWithNgModel;
@@ -95,13 +93,10 @@ describe('MatButtonToggle with forms', () => {
9593
testComponent = fixture.debugElement.componentInstance;
9694

9795
groupDebugElement = fixture.debugElement.query(By.directive(MatButtonToggleGroup));
98-
groupNativeElement = groupDebugElement.nativeElement;
9996
groupInstance = groupDebugElement.injector.get<MatButtonToggleGroup>(MatButtonToggleGroup);
10097
groupNgModel = groupDebugElement.injector.get<NgModel>(NgModel);
10198

10299
buttonToggleDebugElements = fixture.debugElement.queryAll(By.directive(MatButtonToggle));
103-
buttonToggleNativeElements =
104-
buttonToggleDebugElements.map(debugEl => debugEl.nativeElement);
105100
buttonToggleInstances = buttonToggleDebugElements.map(debugEl => debugEl.componentInstance);
106101
buttonToggleLabels = buttonToggleDebugElements.map(
107102
debugEl => debugEl.query(By.css('label')).nativeElement);
@@ -520,14 +515,11 @@ describe('MatButtonToggle without forms', () => {
520515
let buttonToggleNativeElement: HTMLElement;
521516
let buttonToggleLabelElement: HTMLLabelElement;
522517
let buttonToggleInstance: MatButtonToggle;
523-
let testComponent: StandaloneButtonToggle;
524518

525519
beforeEach(async(() => {
526520
fixture = TestBed.createComponent(StandaloneButtonToggle);
527521
fixture.detectChanges();
528522

529-
testComponent = fixture.debugElement.componentInstance;
530-
531523
buttonToggleDebugElement = fixture.debugElement.query(By.directive(MatButtonToggle));
532524
buttonToggleNativeElement = buttonToggleDebugElement.nativeElement;
533525
buttonToggleLabelElement = fixture.debugElement.query(By.css('label')).nativeElement;

src/lib/checkbox/checkbox.spec.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,6 @@ describe('MatCheckbox', () => {
748748
let checkboxNativeElement: HTMLElement;
749749
let testComponent: CheckboxWithTabIndex;
750750
let inputElement: HTMLInputElement;
751-
let labelElement: HTMLLabelElement;
752751

753752
beforeEach(() => {
754753
fixture = TestBed.createComponent(CheckboxWithTabIndex);
@@ -758,7 +757,6 @@ describe('MatCheckbox', () => {
758757
checkboxDebugElement = fixture.debugElement.query(By.directive(MatCheckbox));
759758
checkboxNativeElement = checkboxDebugElement.nativeElement;
760759
inputElement = <HTMLInputElement>checkboxNativeElement.querySelector('input');
761-
labelElement = <HTMLLabelElement>checkboxNativeElement.querySelector('label');
762760
});
763761

764762
it('should preserve any given tabIndex', () => {
@@ -940,7 +938,6 @@ describe('MatCheckbox', () => {
940938

941939
describe('without label', () => {
942940
let testComponent: CheckboxWithoutLabel;
943-
let checkboxElement: HTMLElement;
944941
let checkboxInnerContainer: HTMLElement;
945942

946943
beforeEach(() => {
@@ -949,7 +946,6 @@ describe('MatCheckbox', () => {
949946
const checkboxDebugEl = fixture.debugElement.query(By.directive(MatCheckbox));
950947

951948
testComponent = fixture.componentInstance;
952-
checkboxElement = checkboxDebugEl.nativeElement;
953949
checkboxInnerContainer = checkboxDebugEl
954950
.query(By.css('.mat-checkbox-inner-container')).nativeElement;
955951
});

src/lib/chips/chip-list.spec.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -445,15 +445,13 @@ describe('MatChipList', () => {
445445
});
446446

447447
describe('forms integration', () => {
448-
let formField: HTMLElement;
449448
let nativeChips: HTMLElement[];
450449

451450
describe('single selection', () => {
452451
beforeEach(() => {
453452
fixture = TestBed.createComponent(BasicChipList);
454453
fixture.detectChanges();
455454

456-
formField = fixture.debugElement.query(By.css('.mat-form-field')).nativeElement;
457455
nativeChips = fixture.debugElement.queryAll(By.css('mat-chip'))
458456
.map((chip) => chip.nativeElement);
459457
chips = fixture.componentInstance.chips;
@@ -617,7 +615,6 @@ describe('MatChipList', () => {
617615
fixture = TestBed.createComponent(MultiSelectionChipList);
618616
fixture.detectChanges();
619617

620-
formField = fixture.debugElement.query(By.css('.mat-form-field')).nativeElement;
621618
nativeChips = fixture.debugElement.queryAll(By.css('mat-chip'))
622619
.map((chip) => chip.nativeElement);
623620
chips = fixture.componentInstance.chips;
@@ -695,14 +692,12 @@ describe('MatChipList', () => {
695692
});
696693

697694
describe('chip list with chip input', () => {
698-
let formField: HTMLElement;
699695
let nativeChips: HTMLElement[];
700696

701697
beforeEach(() => {
702698
fixture = TestBed.createComponent(InputChipList);
703699
fixture.detectChanges();
704700

705-
formField = fixture.debugElement.query(By.css('.mat-form-field')).nativeElement;
706701
nativeChips = fixture.debugElement.queryAll(By.css('mat-chip'))
707702
.map((chip) => chip.nativeElement);
708703
});

src/lib/chips/chip-list.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,11 @@ export class MatChipList extends _MatChipListMixinBase implements MatFormFieldCo
384384
if (this._changeSubscription) {
385385
this._changeSubscription.unsubscribe();
386386
}
387+
388+
if (this._chipRemoveSubscription) {
389+
this._chipRemoveSubscription.unsubscribe();
390+
}
391+
387392
this._dropSubscriptions();
388393
this.stateChanges.complete();
389394
}

src/lib/chips/chip.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ import {createKeyboardEvent} from '@angular/cdk/testing';
44
import {Component, DebugElement} from '@angular/core';
55
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
66
import {By} from '@angular/platform-browser';
7-
import {MatChip, MatChipEvent, MatChipList, MatChipSelectionChange, MatChipsModule} from './index';
7+
import {MatChip, MatChipEvent, MatChipSelectionChange, MatChipsModule} from './index';
88

99

1010
describe('Chips', () => {
1111
let fixture: ComponentFixture<any>;
1212
let chipDebugElement: DebugElement;
13-
let chipListNativeElement: HTMLElement;
1413
let chipNativeElement: HTMLElement;
1514
let chipInstance: MatChip;
1615

@@ -59,7 +58,6 @@ describe('Chips', () => {
5958
fixture.detectChanges();
6059

6160
chipDebugElement = fixture.debugElement.query(By.directive(MatChip));
62-
chipListNativeElement = fixture.debugElement.query(By.directive(MatChipList)).nativeElement;
6361
chipNativeElement = chipDebugElement.nativeElement;
6462
chipInstance = chipDebugElement.injector.get(MatChip);
6563
testComponent = fixture.debugElement.componentInstance;

src/lib/core/ripple/ripple.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,14 +525,12 @@ describe('MatRipple', () => {
525525

526526
describe('configuring behavior', () => {
527527
let controller: RippleContainerWithInputBindings;
528-
let rippleComponent: MatRipple;
529528

530529
beforeEach(() => {
531530
fixture = TestBed.createComponent(RippleContainerWithInputBindings);
532531
fixture.detectChanges();
533532

534533
controller = fixture.debugElement.componentInstance;
535-
rippleComponent = controller.ripple;
536534
rippleTarget = fixture.debugElement.nativeElement.querySelector('[mat-ripple]');
537535
});
538536

src/lib/datepicker/month-view.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ describe('MatMonthView', () => {
8080

8181
describe('month view with date filter', () => {
8282
let fixture: ComponentFixture<MonthViewWithDateFilter>;
83-
let testComponent: MonthViewWithDateFilter;
8483
let monthViewNativeElement: Element;
8584

8685
beforeEach(() => {
@@ -89,7 +88,6 @@ describe('MatMonthView', () => {
8988

9089
let monthViewDebugElement = fixture.debugElement.query(By.directive(MatMonthView));
9190
monthViewNativeElement = monthViewDebugElement.nativeElement;
92-
testComponent = fixture.componentInstance;
9391
});
9492

9593
it('should disable filtered dates', () => {

src/lib/datepicker/multi-year-view.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ describe('MatMultiYearView', () => {
8585

8686
describe('multi year view with date filter', () => {
8787
let fixture: ComponentFixture<MultiYearViewWithDateFilter>;
88-
let testComponent: MultiYearViewWithDateFilter;
8988
let multiYearViewNativeElement: Element;
9089

9190
beforeEach(() => {
@@ -94,7 +93,6 @@ describe('MatMultiYearView', () => {
9493

9594
const multiYearViewDebugElement = fixture.debugElement.query(By.directive(MatMultiYearView));
9695
multiYearViewNativeElement = multiYearViewDebugElement.nativeElement;
97-
testComponent = fixture.componentInstance;
9896
});
9997

10098
it('should disablex years with no enabled days', () => {

src/lib/datepicker/year-view.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ describe('MatYearView', () => {
100100

101101
describe('year view with date filter', () => {
102102
let fixture: ComponentFixture<YearViewWithDateFilter>;
103-
let testComponent: YearViewWithDateFilter;
104103
let yearViewNativeElement: Element;
105104

106105
beforeEach(() => {
@@ -109,7 +108,6 @@ describe('MatYearView', () => {
109108

110109
const yearViewDebugElement = fixture.debugElement.query(By.directive(MatYearView));
111110
yearViewNativeElement = yearViewDebugElement.nativeElement;
112-
testComponent = fixture.componentInstance;
113111
});
114112

115113
it('should disable months with no enabled days', () => {

src/lib/list/list.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ export class MatListSubheaderCssMatStyler {}
109109
})
110110
export class MatListItem extends _MatListItemMixinBase implements AfterContentInit,
111111
CanDisableRipple {
112-
private _lineSetter: MatLineSetter;
113112
private _isNavList: boolean = false;
114113

115114
@ContentChildren(MatLine) _lines: QueryList<MatLine>;
@@ -130,7 +129,9 @@ export class MatListItem extends _MatListItemMixinBase implements AfterContentIn
130129
}
131130

132131
ngAfterContentInit() {
133-
this._lineSetter = new MatLineSetter(this._lines, this._element);
132+
// TODO: consider turning the setter into a function, it doesn't do anything as a class.
133+
// tslint:disable-next-line:no-unused-expression
134+
new MatLineSetter(this._lines, this._element);
134135
}
135136

136137
/** Whether this list item should show a ripple effect when clicked. */

0 commit comments

Comments
 (0)