Skip to content

Commit dc3d35b

Browse files
committed
build: enable no-unused-variable lint rule
* Now TSLint starts reporting unused variables again (Rule has been un-deprecated and now uses the type checker * In favor of linting the whole project the tsconfig file inside of `src/` needs to live in the project root.
1 parent 0aaeb69 commit dc3d35b

32 files changed

+81
-105
lines changed

e2e/components/checkbox-e2e.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ describe('checkbox', () => {
1010
it('should be checked when clicked, and unchecked when clicked again', async () => {
1111
let checkboxEl = element(by.id('test-checkbox'));
1212
let inputEl = element(by.css('input[id=input-test-checkbox]'));
13-
let checked: string;
1413

1514
screenshot('start');
1615
checkboxEl.click();

e2e/components/icon-e2e.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {browser, by, element} from 'protractor';
2-
import {screenshot} from '../screenshot';
32

43

54
describe('icon', () => {

e2e/components/menu-e2e.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Key, protractor, browser, by, element, ElementFinder} from 'protractor';
1+
import {Key, protractor, browser, by, element} from 'protractor';
22
import {screenshot} from '../screenshot';
33
import {
44
expectToExist,

src/demo-app/overlay/overlay-demo.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import {
1111
OverlayState,
1212
OverlayOrigin,
1313
ComponentPortal,
14+
// This import is only used to define a generic type. The current TypeScript version incorrectly
15+
// considers such imports as unused (https://github.com/Microsoft/TypeScript/issues/14953)
16+
// tslint:disable-next-line:no-unused-variable
1417
Portal,
1518
TemplatePortalDirective,
1619
} from '@angular/material';

src/lib/chips/chip-list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
import {MdChip} from './chip';
2121
import {FocusKeyManager} from '../core/a11y/focus-key-manager';
2222
import {coerceBooleanProperty} from '../core/coercion/boolean-property';
23-
import {SPACE, LEFT_ARROW, RIGHT_ARROW, TAB} from '../core/keyboard/keycodes';
23+
import {SPACE, LEFT_ARROW, RIGHT_ARROW} from '../core/keyboard/keycodes';
2424
import {Subscription} from 'rxjs/Subscription';
2525

2626
/**

src/lib/core/a11y/activedescendant-key-manager.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {QueryList} from '@angular/core';
109
import {ListKeyManager, CanDisable} from './list-key-manager';
1110

1211
/**

src/lib/core/data-table/cell.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,8 @@ export class CdkColumnDef {
4747
},
4848
})
4949
export class CdkHeaderCell {
50-
constructor(private columnDef: CdkColumnDef,
51-
private elementRef: ElementRef,
52-
private renderer: Renderer2) {
53-
this.renderer.addClass(elementRef.nativeElement, `cdk-column-${columnDef.name}`);
50+
constructor(columnDef: CdkColumnDef, elementRef: ElementRef, renderer: Renderer2) {
51+
renderer.addClass(elementRef.nativeElement, `cdk-column-${columnDef.name}`);
5452
}
5553
}
5654

@@ -63,9 +61,7 @@ export class CdkHeaderCell {
6361
},
6462
})
6563
export class CdkCell {
66-
constructor(private columnDef: CdkColumnDef,
67-
private elementRef: ElementRef,
68-
private renderer: Renderer2) {
69-
this.renderer.addClass(elementRef.nativeElement, `cdk-column-${columnDef.name}`);
64+
constructor(columnDef: CdkColumnDef, elementRef: ElementRef, renderer: Renderer2) {
65+
renderer.addClass(elementRef.nativeElement, `cdk-column-${columnDef.name}`);
7066
}
7167
}

src/lib/core/data-table/data-table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
ViewEncapsulation
2828
} from '@angular/core';
2929
import {CollectionViewer, DataSource} from './data-source';
30-
import {BaseRowDef, CdkCellOutlet, CdkHeaderRowDef, CdkRowDef} from './row';
30+
import {CdkCellOutlet, CdkHeaderRowDef, CdkRowDef} from './row';
3131
import {CdkCellDef, CdkColumnDef, CdkHeaderCellDef} from './cell';
3232
import {Observable} from 'rxjs/Observable';
3333
import {BehaviorSubject} from 'rxjs/BehaviorSubject';

src/lib/core/datetime/native-date-adapter.spec.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
import {NativeDateAdapter} from './native-date-adapter';
22
import {Platform} from '../platform/index';
3-
3+
import {DEC, FEB, JAN, MAR} from '../testing/date-shortcuts';
44

55
const SUPPORTS_INTL = typeof Intl != 'undefined';
66

7-
8-
// When constructing a Date, the month is zero-based. This can be confusing, since people are
9-
// used to seeing them one-based. So we create these aliases to make reading the tests easier.
10-
const JAN = 0, FEB = 1, MAR = 2, APR = 3, MAY = 4, JUN = 5, JUL = 6, AUG = 7, SEP = 8, OCT = 9,
11-
NOV = 10, DEC = 11;
12-
13-
147
describe('NativeDateAdapter', () => {
158
let adapter;
169
let platform;

src/lib/core/option/optgroup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {Component, ViewEncapsulation, ContentChildren, QueryList, Input} from '@angular/core';
9+
import {Component, ViewEncapsulation, Input} from '@angular/core';
1010
import {mixinDisabled, CanDisable} from '../common-behaviors/disabled';
1111

1212
// Boilerplate for applying mixins to MdOptgroup.

src/lib/core/option/option.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
EventEmitter,
1313
Input,
1414
Output,
15-
NgModule,
1615
ViewEncapsulation,
1716
Inject,
1817
Optional,

src/lib/core/overlay/overlay-directives.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ import {TemplatePortal} from '../portal/portal';
2727
import {OverlayState} from './overlay-state';
2828
import {
2929
ConnectionPositionPair,
30+
// This import is only used to define a generic type. The current TypeScript version incorrectly
31+
// considers such imports as unused (https://github.com/Microsoft/TypeScript/issues/14953)
32+
// tslint:disable-next-line:no-unused-variable
3033
ConnectedOverlayPositionChange
3134
} from './position/connected-position';
3235
import {PortalModule} from '../portal/portal-directives';
3336
import {ConnectedPositionStrategy} from './position/connected-position-strategy';
3437
import {Dir, LayoutDirection} from '../rtl/dir';
35-
import {Scrollable} from './scroll/scrollable';
3638
import {ScrollStrategy} from './scroll/scroll-strategy';
3739
import {coerceBooleanProperty} from '../coercion/boolean-property';
3840
import {ESCAPE} from '../keyboard/keycodes';

src/lib/core/overlay/overlay.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import {OverlayState} from './overlay-state';
88
import {OverlayRef} from './overlay-ref';
99
import {PositionStrategy} from './position/position-strategy';
1010
import {OverlayModule} from './overlay-directives';
11-
import {ViewportRuler} from './position/viewport-ruler';
12-
import {ScrollStrategy, ScrollDispatcher} from './scroll/index';
11+
import {ScrollStrategy} from './scroll/index';
1312

1413

1514
describe('Overlay', () => {
@@ -333,7 +332,6 @@ describe('Overlay', () => {
333332
overlayRef.attach(componentPortal);
334333
viewContainerFixture.detectChanges();
335334

336-
let backdrop = overlayContainerElement.querySelector('.cdk-overlay-backdrop') as HTMLElement;
337335
let completeHandler = jasmine.createSpy('backdrop complete handler');
338336

339337
overlayRef.backdropClick().subscribe(null, null, completeHandler);

src/lib/core/overlay/scroll/scroll-strategy-options.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
import {Injectable} from '@angular/core';
10-
import {ScrollStrategy} from './scroll-strategy';
1110
import {CloseScrollStrategy} from './close-scroll-strategy';
1211
import {NoopScrollStrategy} from './noop-scroll-strategy';
1312
import {BlockScrollStrategy} from './block-scroll-strategy';
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
/**
10+
* When constructing a Date, the month is zero-based. This can be confusing, since people are
11+
* used to seeing them one-based. So we create these aliases to make writing the tests easier.
12+
*/
13+
export const JAN = 0, FEB = 1, MAR = 2, APR = 3, MAY = 4, JUN = 5, JUL = 6, AUG = 7, SEP = 8,
14+
OCT = 9, NOV = 10, DEC = 11;

src/lib/datepicker/calendar.spec.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,7 @@ import {MdDatepickerIntl} from './datepicker-intl';
2525
import {MdNativeDateModule} from '../core/datetime/index';
2626
import {NoConflictStyleCompatibilityMode} from '../core';
2727
import {MdButtonModule} from '../button/index';
28-
29-
30-
// When constructing a Date, the month is zero-based. This can be confusing, since people are
31-
// used to seeing them one-based. So we create these aliases to make reading the tests easier.
32-
const JAN = 0, FEB = 1, MAR = 2, APR = 3, MAY = 4, JUN = 5, JUL = 6, AUG = 7, SEP = 8, OCT = 9,
33-
NOV = 10, DEC = 11;
34-
28+
import {AUG, DEC, FEB, JAN, JUL, NOV, MAR, MAY, JUN, SEP} from '../core/testing/date-shortcuts';
3529

3630
describe('MdCalendar', () => {
3731
beforeEach(async(() => {

src/lib/datepicker/datepicker.spec.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,7 @@ import {
1414
dispatchMouseEvent,
1515
dispatchKeyboardEvent,
1616
} from '../core/testing/dispatch-events';
17-
18-
19-
// When constructing a Date, the month is zero-based. This can be confusing, since people are
20-
// used to seeing them one-based. So we create these aliases to make reading the tests easier.
21-
const JAN = 0, FEB = 1, MAR = 2, APR = 3, MAY = 4, JUN = 5, JUL = 6, AUG = 7, SEP = 8, OCT = 9,
22-
NOV = 10, DEC = 11;
23-
17+
import {DEC, JAN} from '../core/testing/date-shortcuts';
2418

2519
describe('MdDatepicker', () => {
2620
describe('with MdNativeDateModule', () => {

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@ import {By} from '@angular/platform-browser';
44
import {MdMonthView} from './month-view';
55
import {MdCalendarBody} from './calendar-body';
66
import {MdNativeDateModule, DateAdapter, NativeDateAdapter} from '../core/datetime/index';
7-
8-
9-
// When constructing a Date, the month is zero-based. This can be confusing, since people are
10-
// used to seeing them one-based. So we create these aliases to make reading the tests easier.
11-
const JAN = 0, FEB = 1, MAR = 2, APR = 3, MAY = 4, JUN = 5, JUL = 6, AUG = 7, SEP = 8, OCT = 9,
12-
NOV = 10, DEC = 11;
13-
7+
import {JAN, MAR} from '../core/testing/date-shortcuts';
148

159
describe('MdMonthView', () => {
1610
beforeEach(async(() => {

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@ import {By} from '@angular/platform-browser';
44
import {MdYearView} from './year-view';
55
import {MdCalendarBody} from './calendar-body';
66
import {MdNativeDateModule, DateAdapter, NativeDateAdapter} from '../core/datetime/index';
7-
8-
9-
// When constructing a Date, the month is zero-based. This can be confusing, since people are
10-
// used to seeing them one-based. So we create these aliases to make reading the tests easier.
11-
const JAN = 0, FEB = 1, MAR = 2, APR = 3, MAY = 4, JUN = 5, JUL = 6, AUG = 7, SEP = 8, OCT = 9,
12-
NOV = 10, DEC = 11;
13-
7+
import {FEB, JAN, MAR} from '../core/testing/date-shortcuts';
148

159
describe('MdYearView', () => {
1610
beforeEach(async(() => {

src/lib/dialog/dialog-container.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
ViewChild,
1313
ViewEncapsulation,
1414
NgZone,
15-
OnDestroy,
1615
ElementRef,
1716
EventEmitter,
1817
Inject,

src/lib/dialog/dialog.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ describe('MdDialog', () => {
313313
});
314314

315315
it('should allow setting the layout direction', () => {
316-
let dialogRef = dialog.open(PizzaMsg, { direction: 'rtl' });
316+
dialog.open(PizzaMsg, { direction: 'rtl' });
317317

318318
viewContainerFixture.detectChanges();
319319

src/lib/expansion/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {NgModule, ModuleWithProviders} from '@angular/core';
9+
import {NgModule} from '@angular/core';
1010
import {CommonModule} from '@angular/common';
1111
import {CompatibilityModule, UNIQUE_SELECTION_DISPATCHER_PROVIDER} from '../core';
1212
import {

src/lib/select/select.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {MdSelect} from './select';
1616
import {getMdSelectDynamicMultipleError, getMdSelectNonArrayValueError} from './select-errors';
1717
import {MdOption} from '../core/option/option';
1818
import {Dir} from '../core/rtl/dir';
19-
import {DOWN_ARROW, UP_ARROW, ENTER, SPACE, HOME, END, TAB} from '../core/keyboard/keycodes';
19+
import {DOWN_ARROW, UP_ARROW, SPACE, HOME, END, TAB} from '../core/keyboard/keycodes';
2020
import {
2121
ControlValueAccessor, FormControl, FormsModule, NG_VALUE_ACCESSOR, ReactiveFormsModule
2222
} from '@angular/forms';

src/lib/snack-bar/snack-bar-container.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import {
2626
import {
2727
BasePortalHost,
2828
ComponentPortal,
29-
TemplatePortal,
3029
PortalHostDirective,
3130
} from '../core';
3231
import {MdSnackBarConfig} from './snack-bar-config';

src/tsconfig.json

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/universal-app/kitchen-sink/kitchen-sink.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import {BrowserModule} from '@angular/platform-browser';
44
import {
55
MdAutocompleteModule,
66
MdButtonModule,
7-
MdButtonToggleModule,
87
MdCardModule,
9-
MdCheckboxModule,
108
MdChipsModule,
119
MdDatepickerModule,
1210
MdDialogModule,

tools/gulp/tasks/lint.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import {buildConfig} from 'material2-build-tools';
77
const stylesGlob = '+(tools|src)/**/*.+(css|scss)';
88

99
/** List of flags that will passed to the different TSLint tasks. */
10-
const tsLintBaseFlags = [
11-
'-c', 'tslint.json', '+(src|e2e|tools)/**/*.ts', '--exclude', '**/node_modules/**/*'
12-
];
10+
const tsLintBaseFlags = ['-c', 'tslint.json', '--project', './tsconfig.json'];
1311

1412
/** Path to the output of the Material package. */
1513
const materialOutPath = join(buildConfig.outputDir, 'packages', 'material');

tools/package-tools/build-bundles.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ import {remapSourcemap} from './sourcemap-remap';
66
import {transpileFile} from './typescript-transpile';
77
import {buildConfig} from './build-config';
88

9-
// There are no type definitions available for these imports.
10-
const uglify = require('uglify-js');
11-
const sorcery = require('sorcery');
12-
139
/** Directory where all bundles will be created in. */
1410
const bundlesDir = join(buildConfig.outputDir, 'bundles');
1511

tools/screenshot-test/functions/util/github.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,13 @@ export function setGithubStatus(commitSHA: string,
2828
'Content-Type': 'application/json'
2929
};
3030

31-
return new Promise((resolve) => {
31+
return new Promise((resolve, reject) => {
3232
request({
3333
url: `https://api.github.com/repos/${repoSlug}/statuses/${commitSHA}`,
3434
method: 'POST',
3535
form: data,
3636
headers: headers
37-
}, function (error: any, response: any) {
38-
console.log(response.statusCode);
39-
resolve(response.statusCode);
40-
});
41-
});
37+
}, (error: any, response: any) => error ? reject(error) : resolve(response.statusCode));
38+
39+
});
4240
}

tools/screenshot-test/src/app/viewer/viewer.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ export class ViewerComponent {
4646
}
4747

4848
approve() {
49-
this._service.approvePullRequest().then((result) => {
49+
this._service.approvePullRequest().then(() => {
5050
this.snackBar.open(`Approved`, '', this.messageDuration);
5151
}).catch((error) => {
5252
this.snackBar.open(`Error ${error}`, '', this.messageDuration);
5353
});
5454
}
5555

5656
updateGithubStatus() {
57-
this._service.updatePullRequestResult().then((result) => {
57+
this._service.updatePullRequestResult().then(() => {
5858
this.snackBar.open(`Approved`, '', this.messageDuration);
5959
}).catch((error) => {
6060
this.snackBar.open(error.message, '', this.messageDuration);

0 commit comments

Comments
 (0)