Skip to content

build: stricter unused variable checking #6633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/cdk/overlay/position/connected-position-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ export class ConnectedPositionStrategy implements PositionStrategy {
}

constructor(
originPos: OriginConnectionPosition,
overlayPos: OverlayConnectionPosition,
private _connectedTo: ElementRef,
private _originPos: OriginConnectionPosition,
private _overlayPos: OverlayConnectionPosition,
private _viewportRuler: ViewportRuler) {
this._origin = this._connectedTo.nativeElement;
this.withFallbackPosition(_originPos, _overlayPos);
this.withFallbackPosition(originPos, overlayPos);
}

/** Ordered list of preferred positions, from most to least desirable. */
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/overlay/position/overlay-position-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ export class OverlayPositionBuilder {
elementRef: ElementRef,
originPos: OriginConnectionPosition,
overlayPos: OverlayConnectionPosition): ConnectedPositionStrategy {
return new ConnectedPositionStrategy(elementRef, originPos, overlayPos, this._viewportRuler);
return new ConnectedPositionStrategy(originPos, overlayPos, elementRef, this._viewportRuler);
}
}
3 changes: 2 additions & 1 deletion src/cdk/rxjs/rx-operators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export interface StrictRxChain<T> {
result(): Observable<T>;
}


/* tslint:disable:no-unused-variable */
export class FinallyBrand { private _; }
export class CatchBrand { private _; }
export class DoBrand { private _; }
Expand All @@ -89,6 +89,7 @@ export class StartWithBrand { private _; }
export class DebounceTimeBrand { private _; }
export class AuditTimeBrand { private _; }
export class TakeUntilBrand { private _; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be ok with having these properties be public. They're not a part of any API or generated JS anyway.

Copy link
Member Author

@devversion devversion Aug 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I don't mind either. I just changed it

Edit: Actually it looks like making the property public causes TypeScript to complain.

Copy link
Member

@jelbourn jelbourn Aug 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The brand properties actually must be private, otherwise they are structurally identical to each other

/* tslint:enable:no-unused-variable */


export type finallyOperatorType<T> = typeof _finallyOperator & FinallyBrand;
Expand Down
2 changes: 0 additions & 2 deletions src/lib/dialog/dialog-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
EmbeddedViewRef,
EventEmitter,
Inject,
NgZone,
Optional,
ChangeDetectorRef,
ViewChild,
Expand Down Expand Up @@ -100,7 +99,6 @@ export class MdDialogContainer extends BasePortalHost {
_isAnimating = false;

constructor(
private _ngZone: NgZone,
private _elementRef: ElementRef,
private _focusTrapFactory: FocusTrapFactory,
private _changeDetectorRef: ChangeDetectorRef,
Expand Down
6 changes: 3 additions & 3 deletions src/lib/dialog/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ export class MdDialog {
constructor(
private _overlay: Overlay,
private _injector: Injector,
@Optional() location: Location,
@Inject(MD_DIALOG_SCROLL_STRATEGY) private _scrollStrategy,
@Optional() private _location: Location,
@Optional() @SkipSelf() private _parentDialog: MdDialog) {

// Close all of the dialogs when the user goes forwards/backwards in history or when the
// location hash changes. Note that this usually doesn't include clicking on links (unless
// the user is using the `HashLocationStrategy`).
if (!_parentDialog && _location) {
_location.subscribe(() => this.closeAll());
if (!_parentDialog && location) {
location.subscribe(() => this.closeAll());
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/expansion/expansion-panel-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ export class MdExpansionPanelHeader implements OnDestroy {
private _parentChangeSubscription: Subscription | null = null;

constructor(
renderer: Renderer2,
@Host() public panel: MdExpansionPanel,
private _renderer: Renderer2,
private _element: ElementRef,
private _focusOriginMonitor: FocusOriginMonitor,
private _changeDetectorRef: ChangeDetectorRef) {
Expand All @@ -90,7 +90,7 @@ export class MdExpansionPanelHeader implements OnDestroy {
)
.subscribe(() => this._changeDetectorRef.markForCheck());

_focusOriginMonitor.monitor(_element.nativeElement, _renderer, false);
_focusOriginMonitor.monitor(_element.nativeElement, renderer, false);
}

/** Toggles the expanded state of the panel. */
Expand Down
4 changes: 1 addition & 3 deletions src/lib/paginator/paginator.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {async, ComponentFixture, TestBed, inject} from '@angular/core/testing';
import {MdPaginatorModule} from './index';
import {MdPaginator, PageEvent} from './paginator';
import {Component, ElementRef, ViewChild} from '@angular/core';
import {Component, ViewChild} from '@angular/core';
import {MdPaginatorIntl} from './paginator-intl';
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
import {dispatchMouseEvent} from '@angular/cdk/testing';
Expand Down Expand Up @@ -281,8 +281,6 @@ class MdPaginatorApp {

@ViewChild(MdPaginator) mdPaginator: MdPaginator;

constructor(private _elementRef: ElementRef) { }

goToLastPage() {
this.pageIndex = Math.ceil(this.length / this.pageSize);
}
Expand Down
1 change: 0 additions & 1 deletion src/lib/select/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
constructor(
private _viewportRuler: ViewportRuler,
private _changeDetectorRef: ChangeDetectorRef,
private _overlay: Overlay,
private _platform: Platform,
renderer: Renderer2,
elementRef: ElementRef,
Expand Down
6 changes: 3 additions & 3 deletions src/lib/slide-toggle/slide-toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,12 @@ class SlideToggleRenderer {
/** Whether the thumb is currently being dragged. */
dragging: boolean = false;

constructor(private _elementRef: ElementRef, platform: Platform) {
constructor(elementRef: ElementRef, platform: Platform) {
// We only need to interact with these elements when we're on the browser, so only grab
// the reference in that case.
if (platform.isBrowser) {
this._thumbEl = _elementRef.nativeElement.querySelector('.mat-slide-toggle-thumb-container');
this._thumbBarEl = _elementRef.nativeElement.querySelector('.mat-slide-toggle-bar');
this._thumbEl = elementRef.nativeElement.querySelector('.mat-slide-toggle-thumb-container');
this._thumbBarEl = elementRef.nativeElement.querySelector('.mat-slide-toggle-bar');
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/tabs/tab-header.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
async, ComponentFixture, TestBed, fakeAsync, tick, discardPeriodicTasks
} from '@angular/core/testing';
import {Component, ViewChild, ViewContainerRef} from '@angular/core';
import {Component, ViewChild} from '@angular/core';
import {CommonModule} from '@angular/common';
import {By} from '@angular/platform-browser';
import {ENTER, LEFT_ARROW, RIGHT_ARROW, SPACE} from '@angular/cdk/keycodes';
Expand Down Expand Up @@ -328,7 +328,7 @@ class SimpleTabHeaderApp {

@ViewChild(MdTabHeader) mdTabHeader: MdTabHeader;

constructor(private _viewContainerRef: ViewContainerRef) {
constructor() {
this.tabs[this.disabledTabIndex].disabled = true;
}

Expand Down
6 changes: 3 additions & 3 deletions src/lib/tooltip/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ export class MdTooltip implements OnDestroy {
private _leaveListener: Function;

constructor(
renderer: Renderer2,
private _overlay: Overlay,
private _elementRef: ElementRef,
private _scrollDispatcher: ScrollDispatcher,
private _viewContainerRef: ViewContainerRef,
private _ngZone: NgZone,
private _renderer: Renderer2,
private _platform: Platform,
@Inject(MD_TOOLTIP_SCROLL_STRATEGY) private _scrollStrategy,
@Optional() private _dir: Directionality) {
Expand All @@ -211,9 +211,9 @@ export class MdTooltip implements OnDestroy {
// they can prevent the first tap from firing its click event.
if (!_platform.IOS) {
this._enterListener =
_renderer.listen(_elementRef.nativeElement, 'mouseenter', () => this.show());
renderer.listen(_elementRef.nativeElement, 'mouseenter', () => this.show());
this._leaveListener =
_renderer.listen(_elementRef.nativeElement, 'mouseleave', () => this.hide());
renderer.listen(_elementRef.nativeElement, 'mouseleave', () => this.hide());
}
}

Expand Down
6 changes: 3 additions & 3 deletions tools/screenshot-test/src/app/viewer/viewer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ export class ViewerComponent {
}

constructor(private _service: FirebaseService,
private _route: ActivatedRoute,
public snackBar: MdSnackBar) {
_route.params.subscribe(p => {
public snackBar: MdSnackBar,
activatedRoute: ActivatedRoute) {
activatedRoute.params.subscribe(p => {
this._service.prNumber = p['id'];
});
}
Expand Down
2 changes: 1 addition & 1 deletion tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"no-var-keyword": true,
"member-access": [true, "no-public"],
"no-debugger": true,
"no-unused-variable": [true, {"ignore-pattern": "^_"}],
"no-unused-variable": true,
"one-line": [
true,
"check-catch",
Expand Down