Skip to content

Commit 4cbd1fd

Browse files
crisbetojelbourn
authored andcommitted
refactor: clean out variables that are being assigned to but not being read (#9871)
1 parent af887a3 commit 4cbd1fd

File tree

22 files changed

+19
-131
lines changed

22 files changed

+19
-131
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
@@ -33,9 +33,6 @@ import {OverlayRef} from '../overlay-ref';
3333
* of the overlay.
3434
*/
3535
export class ConnectedPositionStrategy implements PositionStrategy {
36-
/** The overlay to which this strategy is attached. */
37-
private _overlayRef: OverlayRef;
38-
3936
/** Layout direction of the position strategy. */
4037
private _dir = 'ltr';
4138

@@ -98,7 +95,6 @@ export class ConnectedPositionStrategy implements PositionStrategy {
9895

9996
/** Attach this position strategy to an overlay. */
10097
attach(overlayRef: OverlayRef): void {
101-
this._overlayRef = overlayRef;
10298
this._pane = overlayRef.overlayElement;
10399
this._resizeSubscription.unsubscribe();
104100
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
@@ -389,6 +389,11 @@ export class MatChipList extends _MatChipListMixinBase implements MatFormFieldCo
389389
if (this._changeSubscription) {
390390
this._changeSubscription.unsubscribe();
391391
}
392+
393+
if (this._chipRemoveSubscription) {
394+
this._chipRemoveSubscription.unsubscribe();
395+
}
396+
392397
this._dropSubscriptions();
393398
this.stateChanges.complete();
394399
}

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
@@ -543,14 +543,12 @@ describe('MatRipple', () => {
543543

544544
describe('configuring behavior', () => {
545545
let controller: RippleContainerWithInputBindings;
546-
let rippleComponent: MatRipple;
547546

548547
beforeEach(() => {
549548
fixture = TestBed.createComponent(RippleContainerWithInputBindings);
550549
fixture.detectChanges();
551550

552551
controller = fixture.debugElement.componentInstance;
553-
rippleComponent = controller.ripple;
554552
rippleTarget = fixture.debugElement.nativeElement.querySelector('[mat-ripple]');
555553
});
556554

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
@@ -75,7 +75,6 @@ describe('MatMultiYearView', () => {
7575

7676
describe('multi year view with date filter', () => {
7777
let fixture: ComponentFixture<MultiYearViewWithDateFilter>;
78-
let testComponent: MultiYearViewWithDateFilter;
7978
let multiYearViewNativeElement: Element;
8079

8180
beforeEach(() => {
@@ -84,7 +83,6 @@ describe('MatMultiYearView', () => {
8483

8584
const multiYearViewDebugElement = fixture.debugElement.query(By.directive(MatMultiYearView));
8685
multiYearViewNativeElement = multiYearViewDebugElement.nativeElement;
87-
testComponent = fixture.componentInstance;
8886
});
8987

9088
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
@@ -90,7 +90,6 @@ describe('MatYearView', () => {
9090

9191
describe('year view with date filter', () => {
9292
let fixture: ComponentFixture<YearViewWithDateFilter>;
93-
let testComponent: YearViewWithDateFilter;
9493
let yearViewNativeElement: Element;
9594

9695
beforeEach(() => {
@@ -99,7 +98,6 @@ describe('MatYearView', () => {
9998

10099
const yearViewDebugElement = fixture.debugElement.query(By.directive(MatYearView));
101100
yearViewNativeElement = yearViewDebugElement.nativeElement;
102-
testComponent = fixture.componentInstance;
103101
});
104102

105103
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)