Skip to content
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

build: use noUnusedParameters, noUnusedLocals #4882

Merged
merged 1 commit into from
Feb 21, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/@angular/cli/commands/completion.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as fs from 'fs';
import * as path from 'path';

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

const stringUtils = require('ember-cli-string-utils');
const Command = require('../ember-cli/lib/models/command');
Expand Down
2 changes: 1 addition & 1 deletion packages/@angular/cli/commands/doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const DocCommand = Command.extend({
'<keyword>'
],

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

const docTask = new DocTask({
Expand Down
1 change: 0 additions & 1 deletion packages/@angular/cli/commands/eject.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { BuildOptions } from '../models/build-options';
import { Version } from '../upgrade/version';
import {baseBuildCommandOptions} from './build';

const Command = require('../ember-cli/lib/models/command');
Expand Down
1 change: 0 additions & 1 deletion packages/@angular/cli/commands/new.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as chalk from 'chalk';
import InitCommand from './init';
import { validateProjectName } from '../utilities/validate-project-name';

Expand Down
1 change: 0 additions & 1 deletion packages/@angular/cli/commands/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { baseBuildCommandOptions } from './build';
import { CliConfig } from '../models/config';
import { Version } from '../upgrade/version';
import { ServeTaskOptions } from './serve';
import { checkPort } from '../utilities/check-port';
import { overrideOptions } from '../utilities/override-options';

const SilentError = require('silent-error');
Expand Down
4 changes: 2 additions & 2 deletions packages/@angular/cli/lib/ast-tools/ast-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function insertAfterLastOccurrence(nodes: ts.Node[], toInsert: string,
}


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


function _angularImportsFromNode(node: ts.ImportDeclaration,
sourceFile: ts.SourceFile): {[name: string]: string} {
_sourceFile: ts.SourceFile): {[name: string]: string} {
const ms = node.moduleSpecifier;
let modulePath: string | null = null;
switch (ms.kind) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {BaseHrefWebpackPlugin} from './base-href-webpack-plugin';

function mockCompiler(indexHtml: string, callback: Function) {
return {
plugin: function (event: any, compilerCallback: Function) {
plugin: function (_event: any, compilerCallback: Function) {
const compilation = {
plugin: function (hook: any, compilationCallback: Function) {
plugin: function (_hook: any, compilationCallback: Function) {
const htmlPluginData = {
html: indexHtml
};
Expand All @@ -29,15 +29,15 @@ describe('base href webpack plugin', () => {
it('should do nothing when baseHref is null', () => {
const plugin = new BaseHrefWebpackPlugin({ baseHref: null });

const compiler = mockCompiler(html, (x: any, htmlPluginData: any) => {
const compiler = mockCompiler(html, (_x: any, htmlPluginData: any) => {
expect(htmlPluginData.html).toEqual('<body><head></head></body>');
});
plugin.apply(compiler);
});

it('should insert base tag when not exist', function () {
const plugin = new BaseHrefWebpackPlugin({ baseHref: '/' });
const compiler = mockCompiler(html, (x: any, htmlPluginData: any) => {
const compiler = mockCompiler(html, (_x: any, htmlPluginData: any) => {
expect(htmlPluginData.html).toEqual(oneLineTrim`
<html>
<head><base href="/"></head>
Expand All @@ -55,7 +55,7 @@ describe('base href webpack plugin', () => {
const compiler = mockCompiler(oneLineTrim`
<head><base href="/" target="_blank"></head>
<body></body>
`, (x: any, htmlPluginData: any) => {
`, (_x: any, htmlPluginData: any) => {
expect(htmlPluginData.html).toEqual(oneLineTrim`
<head><base href="/myUrl/" target="_blank"></head>
<body></body>
Expand Down
1 change: 0 additions & 1 deletion packages/@angular/cli/models/webpack-configs/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { BaseHrefWebpackPlugin } from '../../lib/base-href-webpack';
import { extraEntryParser, lazyChunksFilter, getOutputHashFormat } from './utils';
import { WebpackConfigOptions } from '../webpack-config';

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { WebpackConfigOptions } from '../webpack-config';

export const getDevConfig = function (wco: WebpackConfigOptions) {
export const getDevConfig = function (_wco: WebpackConfigOptions) {
return {};
};
1 change: 0 additions & 1 deletion packages/@angular/cli/models/webpack-configs/production.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { WebpackConfigOptions } from '../webpack-config';

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

let extraPlugins: any[] = [];
let entryPoints: {[key: string]: string[]} = {};
Expand Down
1 change: 0 additions & 1 deletion packages/@angular/cli/models/webpack-configs/styles.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as webpack from 'webpack';
import * as path from 'path';
import { oneLineTrim } from 'common-tags';
import {
SuppressExtractedTextChunksWebpackPlugin
} from '../../plugins/suppress-entry-chunks-webpack-plugin';
Expand Down
3 changes: 1 addition & 2 deletions packages/@angular/cli/models/webpack-configs/typescript.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as fs from 'fs';
import * as path from 'path';
import { stripIndent } from 'common-tags';
import {AotPlugin, AotPluginOptions} from '@ngtools/webpack';
import {AotPlugin} from '@ngtools/webpack';
import { WebpackConfigOptions } from '../webpack-config';

const SilentError = require('silent-error');
Expand Down
2 changes: 0 additions & 2 deletions packages/@angular/cli/plugins/static-asset.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as fs from 'fs';

export class StaticAssetPlugin {

constructor(private name: string, private contents: string) {}
Expand Down
3 changes: 1 addition & 2 deletions packages/@angular/cli/tasks/eject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const SilentError = require('silent-error');
const Task = require('../ember-cli/lib/models/task');

const CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin;
const LoaderOptionsPlugin = webpack.LoaderOptionsPlugin;
const ProgressPlugin = require('webpack/lib/ProgressPlugin');

Expand Down Expand Up @@ -319,7 +318,7 @@ class JsonWebpackSerializer {
});
}

private _replacer(key: string, value: any) {
private _replacer(_key: string, value: any) {
if (value === undefined) {
return value;
}
Expand Down
1 change: 0 additions & 1 deletion packages/@angular/cli/tasks/lint.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const Task = require('../ember-cli/lib/models/task');
import * as chalk from 'chalk';
import * as path from 'path';
import * as glob from 'glob';
import * as ts from 'typescript';
import { requireProjectModule } from '../utilities/require-project-module';
Expand Down
2 changes: 1 addition & 1 deletion packages/@angular/cli/tasks/npm-install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default Task.extend({
return new Promise(function(resolve, reject) {
ui.writeLine(chalk.green(`Installing packages for tooling via ${packageManager}.`));
exec(`${packageManager} install`,
(err: NodeJS.ErrnoException, stdout: string, stderr: string) => {
(err: NodeJS.ErrnoException, _stdout: string, stderr: string) => {
if (err) {
ui.writeLine(stderr);
ui.writeLine(chalk.red('Package install failed, see above.'));
Expand Down
4 changes: 2 additions & 2 deletions packages/@angular/cli/tasks/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ export default Task.extend({
`));

const server = new WebpackDevServer(webpackCompiler, webpackDevServerConfiguration);
return new Promise((resolve, reject) => {
server.listen(serveTaskOptions.port, serveTaskOptions.host, (err: any, stats: any) => {
return new Promise((_resolve, reject) => {
server.listen(serveTaskOptions.port, serveTaskOptions.host, (err: any, _stats: any) => {
if (err) {
return reject(err);
}
Expand Down
2 changes: 2 additions & 0 deletions packages/@angular/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"moduleResolution": "node",
"noEmitOnError": true,
"noImplicitAny": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"outDir": "../../../dist/@angular/cli",
"rootDir": ".",
"sourceMap": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/@angular/cli/upgrade/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class Version {
try {
const angularCliPath = resolve.sync('@angular/cli', {
basedir: process.cwd(),
packageFilter: (pkg: any, pkgFile: string) => {
packageFilter: (pkg: any, _pkgFile: string) => {
packageJson = pkg;
}
});
Expand Down
10 changes: 5 additions & 5 deletions packages/@ngtools/json-schema/src/schema-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,21 @@ export abstract class SchemaTreeNode<T> implements SchemaNode {
return this._parent.isChildRequired(this.name);
}

isChildRequired(name: string) { return false; }
isChildRequired(_name: string) { return false; }

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

abstract get(): T;
set(v: T, init = false, force = false) {
set(_v: T, _init = false, _force = false) {
if (!this.readOnly) {
throw new MissingImplementationError();
}
throw new SettingReadOnlyPropertyError();
};
isCompatible(v: any) { return false; }
isCompatible(_v: any) { return false; }

abstract serialize(serializer: Serializer): void;

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

set(v: any, init = false, force = false) {
set(v: any, _init = false, force = false) {
return this._set(v, false, force);
}

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

_set(value: any, init: boolean, force: boolean) {
_set(value: any, init: boolean, _force: boolean) {
const schema = this._schema;
const forward = this._forward;

Expand Down
10 changes: 5 additions & 5 deletions packages/@ngtools/json-schema/src/serializers/dts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,24 +141,24 @@ export class DTsSerializer implements Serializer {
this._writer(')');
}

outputValue(node: SchemaNode) {
outputValue(_node: SchemaNode) {
this._willOutputValue();
this._writer('any');
}

outputString(node: SchemaNode) {
outputString(_node: SchemaNode) {
this._willOutputValue();
this._writer('string');
}
outputNumber(node: SchemaNode) {
outputNumber(_node: SchemaNode) {
this._willOutputValue();
this._writer('number');
}
outputInteger(node: SchemaNode) {
outputInteger(_node: SchemaNode) {
this._willOutputValue();
this._writer('number');
}
outputBoolean(node: SchemaNode) {
outputBoolean(_node: SchemaNode) {
this._willOutputValue();
this._writer('boolean');
}
Expand Down
2 changes: 2 additions & 0 deletions packages/@ngtools/json-schema/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"moduleResolution": "node",
"noEmitOnError": true,
"noImplicitAny": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"outDir": "../../../dist/@ngtools/json-schema",
"rootDir": ".",
"lib": [
Expand Down
6 changes: 3 additions & 3 deletions packages/@ngtools/logger/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ export class Logger extends Observable<LogEntry> {
subscribe(observer: PartialObserver<LogEntry>): Subscription;
subscribe(next?: (value: LogEntry) => void, error?: (error: any) => void,
complete?: () => void): Subscription;
subscribe(observerOrNext?: PartialObserver<LogEntry> | ((value: LogEntry) => void),
error?: (error: any) => void,
complete?: () => void): Subscription {
subscribe(_observerOrNext?: PartialObserver<LogEntry> | ((value: LogEntry) => void),
_error?: (error: any) => void,
_complete?: () => void): Subscription {
return this._observable.subscribe.apply(this._observable, arguments);
}
forEach(next: (value: LogEntry) => void, PromiseCtor?: typeof Promise): Promise<void> {
Expand Down
2 changes: 2 additions & 0 deletions packages/@ngtools/logger/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"moduleResolution": "node",
"noEmitOnError": true,
"noImplicitAny": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"outDir": "../../../dist/@ngtools/logger",
"rootDir": ".",
"lib": [
Expand Down
6 changes: 3 additions & 3 deletions packages/@ngtools/webpack/src/compiler_host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export class WebpackCompilerHost implements ts.CompilerHost {
return delegated.concat(subdirs);
}

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

if (this._files[fileName] == null) {
Expand All @@ -265,8 +265,8 @@ export class WebpackCompilerHost implements ts.CompilerHost {
// This is due to typescript CompilerHost interface being weird on writeFile. This shuts down
// typings in WebStorm.
get writeFile() {
return (fileName: string, data: string, writeByteOrderMark: boolean,
onError?: (message: string) => void, sourceFiles?: ts.SourceFile[]): void => {
return (fileName: string, data: string, _writeByteOrderMark: boolean,
_onError?: (message: string) => void, _sourceFiles?: ts.SourceFile[]): void => {
fileName = this._resolve(fileName);
this._setFileContent(fileName, data);
};
Expand Down
2 changes: 1 addition & 1 deletion packages/@ngtools/webpack/src/lazy_routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as ts from 'typescript';
import {TypeScriptFileRefactor} from './refactor';


function _getContentOfKeyLiteral(source: ts.SourceFile, node: ts.Node): string {
function _getContentOfKeyLiteral(_source: ts.SourceFile, node: ts.Node): string {
if (node.kind == ts.SyntaxKind.Identifier) {
return (node as ts.Identifier).text;
} else if (node.kind == ts.SyntaxKind.StringLiteral) {
Expand Down
22 changes: 3 additions & 19 deletions packages/@ngtools/webpack/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const loaderUtils = require('loader-utils');
const NormalModule = require('webpack/lib/NormalModule');


function _getContentOfKeyLiteral(source: ts.SourceFile, node: ts.Node): string {
function _getContentOfKeyLiteral(_source: ts.SourceFile, node: ts.Node): string {
if (!node) {
return null;
} else if (node.kind == ts.SyntaxKind.Identifier) {
Expand All @@ -21,7 +21,7 @@ function _getContentOfKeyLiteral(source: ts.SourceFile, node: ts.Node): string {
}


function _angularImportsFromNode(node: ts.ImportDeclaration, sourceFile: ts.SourceFile): string[] {
function _angularImportsFromNode(node: ts.ImportDeclaration, _sourceFile: ts.SourceFile): string[] {
const ms = node.moduleSpecifier;
let modulePath: string | null = null;
switch (ms.kind) {
Expand Down Expand Up @@ -250,7 +250,7 @@ function _removeModuleId(refactor: TypeScriptFileRefactor) {
});
})
.forEach((node: ts.ObjectLiteralExpression) => {
const moduleIdProp = node.properties.filter((prop: ts.ObjectLiteralElement, idx: number) => {
const moduleIdProp = node.properties.filter((prop: ts.ObjectLiteralElement, _idx: number) => {
return prop.kind == ts.SyntaxKind.PropertyAssignment
&& _getContentOfKeyLiteral(sourceFile, prop.name) == 'moduleId';
})[0];
Expand Down Expand Up @@ -311,22 +311,6 @@ function _replaceResources(refactor: TypeScriptFileRefactor): void {
}


function _checkDiagnostics(refactor: TypeScriptFileRefactor) {
const diagnostics: ts.Diagnostic[] = refactor.getDiagnostics();

if (diagnostics.length > 0) {
const message = diagnostics
.map(diagnostic => {
const {line, character} = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
return `${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message})`;
})
.join('\n');
throw new Error(message);
}
}


/**
* Recursively calls diagnose on the plugins for all the reverse dependencies.
* @private
Expand Down
3 changes: 2 additions & 1 deletion packages/@ngtools/webpack/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ export class AotPlugin implements Tapable {
result.resource = this.skipCodeGeneration ? this.basePath : this.genDir;
result.recursive = true;
result.dependencies.forEach((d: any) => d.critical = false);
result.resolveDependencies = (p1: any, p2: any, p3: any, p4: RegExp, cb: any ) => {
result.resolveDependencies = (_fs: any, _resource: any, _recursive: any,
_regExp: RegExp, cb: any) => {
const dependencies = Object.keys(this._lazyRoutes)
.map((key) => {
const value = this._lazyRoutes[key];
Expand Down