Skip to content

Commit d1e13ac

Browse files
filipesilvahansl
authored andcommitted
build: use noUnusedParameters, noUnusedLocals (#4882)
1 parent a4b43a5 commit d1e13ac

31 files changed

+49
-67
lines changed

packages/@angular/cli/commands/completion.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as fs from 'fs';
22
import * as path from 'path';
33

4-
import { oneLine, stripIndent } from 'common-tags';
4+
import { stripIndent } from 'common-tags';
55

66
const stringUtils = require('ember-cli-string-utils');
77
const Command = require('../ember-cli/lib/models/command');

packages/@angular/cli/commands/doc.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const DocCommand = Command.extend({
1010
'<keyword>'
1111
],
1212

13-
run: function(commandOptions: any, rawArgs: Array<string>) {
13+
run: function(_commandOptions: any, rawArgs: Array<string>) {
1414
const keyword = rawArgs[0];
1515

1616
const docTask = new DocTask({

packages/@angular/cli/commands/eject.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { BuildOptions } from '../models/build-options';
2-
import { Version } from '../upgrade/version';
32
import {baseBuildCommandOptions} from './build';
43

54
const Command = require('../ember-cli/lib/models/command');

packages/@angular/cli/commands/new.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as chalk from 'chalk';
21
import InitCommand from './init';
32
import { validateProjectName } from '../utilities/validate-project-name';
43

packages/@angular/cli/commands/serve.ts

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { baseBuildCommandOptions } from './build';
44
import { CliConfig } from '../models/config';
55
import { Version } from '../upgrade/version';
66
import { ServeTaskOptions } from './serve';
7-
import { checkPort } from '../utilities/check-port';
87
import { overrideOptions } from '../utilities/override-options';
98

109
const SilentError = require('silent-error');

packages/@angular/cli/lib/ast-tools/ast-utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export function insertAfterLastOccurrence(nodes: ts.Node[], toInsert: string,
8888
}
8989

9090

91-
export function getContentOfKeyLiteral(source: ts.SourceFile, node: ts.Node): string {
91+
export function getContentOfKeyLiteral(_source: ts.SourceFile, node: ts.Node): string {
9292
if (node.kind == ts.SyntaxKind.Identifier) {
9393
return (node as ts.Identifier).text;
9494
} else if (node.kind == ts.SyntaxKind.StringLiteral) {
@@ -101,7 +101,7 @@ export function getContentOfKeyLiteral(source: ts.SourceFile, node: ts.Node): st
101101

102102

103103
function _angularImportsFromNode(node: ts.ImportDeclaration,
104-
sourceFile: ts.SourceFile): {[name: string]: string} {
104+
_sourceFile: ts.SourceFile): {[name: string]: string} {
105105
const ms = node.moduleSpecifier;
106106
let modulePath: string | null = null;
107107
switch (ms.kind) {

packages/@angular/cli/lib/base-href-webpack/base-href-webpack-plugin.spec.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import {BaseHrefWebpackPlugin} from './base-href-webpack-plugin';
44

55
function mockCompiler(indexHtml: string, callback: Function) {
66
return {
7-
plugin: function (event: any, compilerCallback: Function) {
7+
plugin: function (_event: any, compilerCallback: Function) {
88
const compilation = {
9-
plugin: function (hook: any, compilationCallback: Function) {
9+
plugin: function (_hook: any, compilationCallback: Function) {
1010
const htmlPluginData = {
1111
html: indexHtml
1212
};
@@ -29,15 +29,15 @@ describe('base href webpack plugin', () => {
2929
it('should do nothing when baseHref is null', () => {
3030
const plugin = new BaseHrefWebpackPlugin({ baseHref: null });
3131

32-
const compiler = mockCompiler(html, (x: any, htmlPluginData: any) => {
32+
const compiler = mockCompiler(html, (_x: any, htmlPluginData: any) => {
3333
expect(htmlPluginData.html).toEqual('<body><head></head></body>');
3434
});
3535
plugin.apply(compiler);
3636
});
3737

3838
it('should insert base tag when not exist', function () {
3939
const plugin = new BaseHrefWebpackPlugin({ baseHref: '/' });
40-
const compiler = mockCompiler(html, (x: any, htmlPluginData: any) => {
40+
const compiler = mockCompiler(html, (_x: any, htmlPluginData: any) => {
4141
expect(htmlPluginData.html).toEqual(oneLineTrim`
4242
<html>
4343
<head><base href="/"></head>
@@ -55,7 +55,7 @@ describe('base href webpack plugin', () => {
5555
const compiler = mockCompiler(oneLineTrim`
5656
<head><base href="/" target="_blank"></head>
5757
<body></body>
58-
`, (x: any, htmlPluginData: any) => {
58+
`, (_x: any, htmlPluginData: any) => {
5959
expect(htmlPluginData.html).toEqual(oneLineTrim`
6060
<head><base href="/myUrl/" target="_blank"></head>
6161
<body></body>

packages/@angular/cli/models/webpack-configs/common.ts

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { BaseHrefWebpackPlugin } from '../../lib/base-href-webpack';
66
import { extraEntryParser, lazyChunksFilter, getOutputHashFormat } from './utils';
77
import { WebpackConfigOptions } from '../webpack-config';
88

9-
const autoprefixer = require('autoprefixer');
109
const ProgressPlugin = require('webpack/lib/ProgressPlugin');
1110
const HtmlWebpackPlugin = require('html-webpack-plugin');
1211

Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { WebpackConfigOptions } from '../webpack-config';
22

3-
export const getDevConfig = function (wco: WebpackConfigOptions) {
3+
export const getDevConfig = function (_wco: WebpackConfigOptions) {
44
return {};
55
};

packages/@angular/cli/models/webpack-configs/production.ts

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { WebpackConfigOptions } from '../webpack-config';
99

1010
export const getProdConfig = function (wco: WebpackConfigOptions) {
1111
const { projectRoot, buildOptions, appConfig } = wco;
12-
const appRoot = path.resolve(projectRoot, appConfig.root);
1312

1413
let extraPlugins: any[] = [];
1514
let entryPoints: {[key: string]: string[]} = {};

packages/@angular/cli/models/webpack-configs/styles.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as webpack from 'webpack';
22
import * as path from 'path';
3-
import { oneLineTrim } from 'common-tags';
43
import {
54
SuppressExtractedTextChunksWebpackPlugin
65
} from '../../plugins/suppress-entry-chunks-webpack-plugin';

packages/@angular/cli/models/webpack-configs/typescript.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import * as fs from 'fs';
21
import * as path from 'path';
32
import { stripIndent } from 'common-tags';
4-
import {AotPlugin, AotPluginOptions} from '@ngtools/webpack';
3+
import {AotPlugin} from '@ngtools/webpack';
54
import { WebpackConfigOptions } from '../webpack-config';
65

76
const SilentError = require('silent-error');

packages/@angular/cli/plugins/static-asset.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import * as fs from 'fs';
2-
31
export class StaticAssetPlugin {
42

53
constructor(private name: string, private contents: string) {}

packages/@angular/cli/tasks/eject.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
2424
const SilentError = require('silent-error');
2525
const Task = require('../ember-cli/lib/models/task');
2626

27-
const CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin;
2827
const LoaderOptionsPlugin = webpack.LoaderOptionsPlugin;
2928
const ProgressPlugin = require('webpack/lib/ProgressPlugin');
3029

@@ -319,7 +318,7 @@ class JsonWebpackSerializer {
319318
});
320319
}
321320

322-
private _replacer(key: string, value: any) {
321+
private _replacer(_key: string, value: any) {
323322
if (value === undefined) {
324323
return value;
325324
}

packages/@angular/cli/tasks/lint.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const Task = require('../ember-cli/lib/models/task');
22
import * as chalk from 'chalk';
3-
import * as path from 'path';
43
import * as glob from 'glob';
54
import * as ts from 'typescript';
65
import { requireProjectModule } from '../utilities/require-project-module';

packages/@angular/cli/tasks/npm-install.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default Task.extend({
1414
return new Promise(function(resolve, reject) {
1515
ui.writeLine(chalk.green(`Installing packages for tooling via ${packageManager}.`));
1616
exec(`${packageManager} install`,
17-
(err: NodeJS.ErrnoException, stdout: string, stderr: string) => {
17+
(err: NodeJS.ErrnoException, _stdout: string, stderr: string) => {
1818
if (err) {
1919
ui.writeLine(stderr);
2020
ui.writeLine(chalk.red('Package install failed, see above.'));

packages/@angular/cli/tasks/serve.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ export default Task.extend({
175175
`));
176176

177177
const server = new WebpackDevServer(webpackCompiler, webpackDevServerConfiguration);
178-
return new Promise((resolve, reject) => {
179-
server.listen(serveTaskOptions.port, serveTaskOptions.host, (err: any, stats: any) => {
178+
return new Promise((_resolve, reject) => {
179+
server.listen(serveTaskOptions.port, serveTaskOptions.host, (err: any, _stats: any) => {
180180
if (err) {
181181
return reject(err);
182182
}

packages/@angular/cli/tsconfig.json

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"moduleResolution": "node",
99
"noEmitOnError": true,
1010
"noImplicitAny": true,
11+
"noUnusedParameters": true,
12+
"noUnusedLocals": true,
1113
"outDir": "../../../dist/@angular/cli",
1214
"rootDir": ".",
1315
"sourceMap": true,

packages/@angular/cli/upgrade/version.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class Version {
5050
try {
5151
const angularCliPath = resolve.sync('@angular/cli', {
5252
basedir: process.cwd(),
53-
packageFilter: (pkg: any, pkgFile: string) => {
53+
packageFilter: (pkg: any, _pkgFile: string) => {
5454
packageJson = pkg;
5555
}
5656
});

packages/@ngtools/json-schema/src/schema-tree.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -89,21 +89,21 @@ export abstract class SchemaTreeNode<T> implements SchemaNode {
8989
return this._parent.isChildRequired(this.name);
9090
}
9191

92-
isChildRequired(name: string) { return false; }
92+
isChildRequired(_name: string) { return false; }
9393

9494
get parent(): SchemaTreeNode<any> { return this._parent; }
9595
get children(): { [key: string]: SchemaTreeNode<any> } | null { return null; }
9696
get items(): SchemaTreeNode<any>[] | null { return null; }
9797
get itemPrototype(): SchemaTreeNode<any> | null { return null; }
9898

9999
abstract get(): T;
100-
set(v: T, init = false, force = false) {
100+
set(_v: T, _init = false, _force = false) {
101101
if (!this.readOnly) {
102102
throw new MissingImplementationError();
103103
}
104104
throw new SettingReadOnlyPropertyError();
105105
};
106-
isCompatible(v: any) { return false; }
106+
isCompatible(_v: any) { return false; }
107107

108108
abstract serialize(serializer: Serializer): void;
109109

@@ -223,7 +223,7 @@ export class OneOfSchemaTreeNode extends NonLeafSchemaTreeNode<any> {
223223
this._currentTypeHolder.set(v, false, true);
224224
}
225225

226-
set(v: any, init = false, force = false) {
226+
set(v: any, _init = false, force = false) {
227227
return this._set(v, false, force);
228228
}
229229

@@ -334,7 +334,7 @@ export class ArraySchemaTreeNode extends NonLeafSchemaTreeNode<Array<any>> {
334334
'', undefined, null, metaData.schema['items'], false);
335335
}
336336

337-
_set(value: any, init: boolean, force: boolean) {
337+
_set(value: any, init: boolean, _force: boolean) {
338338
const schema = this._schema;
339339
const forward = this._forward;
340340

packages/@ngtools/json-schema/src/serializers/dts.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -141,24 +141,24 @@ export class DTsSerializer implements Serializer {
141141
this._writer(')');
142142
}
143143

144-
outputValue(node: SchemaNode) {
144+
outputValue(_node: SchemaNode) {
145145
this._willOutputValue();
146146
this._writer('any');
147147
}
148148

149-
outputString(node: SchemaNode) {
149+
outputString(_node: SchemaNode) {
150150
this._willOutputValue();
151151
this._writer('string');
152152
}
153-
outputNumber(node: SchemaNode) {
153+
outputNumber(_node: SchemaNode) {
154154
this._willOutputValue();
155155
this._writer('number');
156156
}
157-
outputInteger(node: SchemaNode) {
157+
outputInteger(_node: SchemaNode) {
158158
this._willOutputValue();
159159
this._writer('number');
160160
}
161-
outputBoolean(node: SchemaNode) {
161+
outputBoolean(_node: SchemaNode) {
162162
this._willOutputValue();
163163
this._writer('boolean');
164164
}

packages/@ngtools/json-schema/tsconfig.json

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
"moduleResolution": "node",
88
"noEmitOnError": true,
99
"noImplicitAny": true,
10+
"noUnusedParameters": true,
11+
"noUnusedLocals": true,
1012
"outDir": "../../../dist/@ngtools/json-schema",
1113
"rootDir": ".",
1214
"lib": [

packages/@ngtools/logger/src/logger.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ export class Logger extends Observable<LogEntry> {
105105
subscribe(observer: PartialObserver<LogEntry>): Subscription;
106106
subscribe(next?: (value: LogEntry) => void, error?: (error: any) => void,
107107
complete?: () => void): Subscription;
108-
subscribe(observerOrNext?: PartialObserver<LogEntry> | ((value: LogEntry) => void),
109-
error?: (error: any) => void,
110-
complete?: () => void): Subscription {
108+
subscribe(_observerOrNext?: PartialObserver<LogEntry> | ((value: LogEntry) => void),
109+
_error?: (error: any) => void,
110+
_complete?: () => void): Subscription {
111111
return this._observable.subscribe.apply(this._observable, arguments);
112112
}
113113
forEach(next: (value: LogEntry) => void, PromiseCtor?: typeof Promise): Promise<void> {

packages/@ngtools/logger/tsconfig.json

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
"moduleResolution": "node",
88
"noEmitOnError": true,
99
"noImplicitAny": true,
10+
"noUnusedParameters": true,
11+
"noUnusedLocals": true,
1012
"outDir": "../../../dist/@ngtools/logger",
1113
"rootDir": ".",
1214
"lib": [

packages/@ngtools/webpack/src/compiler_host.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ export class WebpackCompilerHost implements ts.CompilerHost {
241241
return delegated.concat(subdirs);
242242
}
243243

244-
getSourceFile(fileName: string, languageVersion: ts.ScriptTarget, onError?: OnErrorFn) {
244+
getSourceFile(fileName: string, languageVersion: ts.ScriptTarget, _onError?: OnErrorFn) {
245245
fileName = this._resolve(fileName);
246246

247247
if (this._files[fileName] == null) {
@@ -265,8 +265,8 @@ export class WebpackCompilerHost implements ts.CompilerHost {
265265
// This is due to typescript CompilerHost interface being weird on writeFile. This shuts down
266266
// typings in WebStorm.
267267
get writeFile() {
268-
return (fileName: string, data: string, writeByteOrderMark: boolean,
269-
onError?: (message: string) => void, sourceFiles?: ts.SourceFile[]): void => {
268+
return (fileName: string, data: string, _writeByteOrderMark: boolean,
269+
_onError?: (message: string) => void, _sourceFiles?: ts.SourceFile[]): void => {
270270
fileName = this._resolve(fileName);
271271
this._setFileContent(fileName, data);
272272
};

packages/@ngtools/webpack/src/lazy_routes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as ts from 'typescript';
44
import {TypeScriptFileRefactor} from './refactor';
55

66

7-
function _getContentOfKeyLiteral(source: ts.SourceFile, node: ts.Node): string {
7+
function _getContentOfKeyLiteral(_source: ts.SourceFile, node: ts.Node): string {
88
if (node.kind == ts.SyntaxKind.Identifier) {
99
return (node as ts.Identifier).text;
1010
} else if (node.kind == ts.SyntaxKind.StringLiteral) {

packages/@ngtools/webpack/src/loader.ts

+3-19
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const loaderUtils = require('loader-utils');
88
const NormalModule = require('webpack/lib/NormalModule');
99

1010

11-
function _getContentOfKeyLiteral(source: ts.SourceFile, node: ts.Node): string {
11+
function _getContentOfKeyLiteral(_source: ts.SourceFile, node: ts.Node): string {
1212
if (!node) {
1313
return null;
1414
} else if (node.kind == ts.SyntaxKind.Identifier) {
@@ -21,7 +21,7 @@ function _getContentOfKeyLiteral(source: ts.SourceFile, node: ts.Node): string {
2121
}
2222

2323

24-
function _angularImportsFromNode(node: ts.ImportDeclaration, sourceFile: ts.SourceFile): string[] {
24+
function _angularImportsFromNode(node: ts.ImportDeclaration, _sourceFile: ts.SourceFile): string[] {
2525
const ms = node.moduleSpecifier;
2626
let modulePath: string | null = null;
2727
switch (ms.kind) {
@@ -250,7 +250,7 @@ function _removeModuleId(refactor: TypeScriptFileRefactor) {
250250
});
251251
})
252252
.forEach((node: ts.ObjectLiteralExpression) => {
253-
const moduleIdProp = node.properties.filter((prop: ts.ObjectLiteralElement, idx: number) => {
253+
const moduleIdProp = node.properties.filter((prop: ts.ObjectLiteralElement, _idx: number) => {
254254
return prop.kind == ts.SyntaxKind.PropertyAssignment
255255
&& _getContentOfKeyLiteral(sourceFile, prop.name) == 'moduleId';
256256
})[0];
@@ -311,22 +311,6 @@ function _replaceResources(refactor: TypeScriptFileRefactor): void {
311311
}
312312

313313

314-
function _checkDiagnostics(refactor: TypeScriptFileRefactor) {
315-
const diagnostics: ts.Diagnostic[] = refactor.getDiagnostics();
316-
317-
if (diagnostics.length > 0) {
318-
const message = diagnostics
319-
.map(diagnostic => {
320-
const {line, character} = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
321-
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
322-
return `${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message})`;
323-
})
324-
.join('\n');
325-
throw new Error(message);
326-
}
327-
}
328-
329-
330314
/**
331315
* Recursively calls diagnose on the plugins for all the reverse dependencies.
332316
* @private

packages/@ngtools/webpack/src/plugin.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ export class AotPlugin implements Tapable {
278278
result.resource = this.skipCodeGeneration ? this.basePath : this.genDir;
279279
result.recursive = true;
280280
result.dependencies.forEach((d: any) => d.critical = false);
281-
result.resolveDependencies = (p1: any, p2: any, p3: any, p4: RegExp, cb: any ) => {
281+
result.resolveDependencies = (_fs: any, _resource: any, _recursive: any,
282+
_regExp: RegExp, cb: any) => {
282283
const dependencies = Object.keys(this._lazyRoutes)
283284
.map((key) => {
284285
const value = this._lazyRoutes[key];

0 commit comments

Comments
 (0)