Implement 'no Unused Parameters' typescript compilation rule (#518)

* Implement rule

* Based on Stephen's feedback.
This commit is contained in:
Prashanth 2018-04-11 11:21:48 -07:00 коммит произвёл GitHub
Родитель d8c851b002
Коммит 1653ace5ae
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
16 изменённых файлов: 32 добавлений и 31 удалений

Просмотреть файл

@ -112,7 +112,7 @@ export class CosmosEditorManager {
}
}
public async onDidSaveTextDocument(context: IActionContext, globalState: vscode.Memento, doc: vscode.TextDocument, tree: AzureTreeDataProvider): Promise<void> {
public async onDidSaveTextDocument(context: IActionContext, doc: vscode.TextDocument, tree: AzureTreeDataProvider): Promise<void> {
context.suppressTelemetry = true;
let filePath = Object.keys(this.fileMap).find((filePath) => path.relative(doc.uri.fsPath, filePath) === '');
if (!filePath) {

Просмотреть файл

@ -115,7 +115,7 @@ export function activate(context: vscode.ExtensionContext) {
actionHandler.registerCommand('cosmosDB.update', (filePath: vscode.Uri) => editorManager.updateMatchingNode(filePath, tree));
actionHandler.registerCommand('cosmosDB.loadMore', (node?: IAzureNode) => tree.loadMore(node));
actionHandler.registerEvent('cosmosDB.CosmosEditorManager.onDidSaveTextDocument', vscode.workspace.onDidSaveTextDocument, async function
(this: IActionContext, doc: vscode.TextDocument): Promise<void> { await editorManager.onDidSaveTextDocument(this, context.globalState, doc, tree) });
(this: IActionContext, doc: vscode.TextDocument): Promise<void> { await editorManager.onDidSaveTextDocument(this, doc, tree) });
}
async function getAttachedNode(tree: AzureTreeDataProvider): Promise<IAzureParentNode<AttachedAccountsTreeItem>> {

Просмотреть файл

@ -92,7 +92,7 @@ export class GraphViewServer extends EventEmitter {
}
// how know resolve/reject?
return new Promise((resolve, reject) => {
return new Promise((resolve, _reject) => {
this._httpServer = http.createServer()
this._httpServer.listen(
0, // dynamnically pick an unused port
@ -109,7 +109,7 @@ export class GraphViewServer extends EventEmitter {
this.setUpSocket();
});
this._server.on('error', socket => {
this._server.on('error', _socket => {
console.error("Error from server");
});
});
@ -468,7 +468,7 @@ export class GraphViewServer extends EventEmitter {
}
// tslint:disable-next-line:no-any
private log(message, ...args: any[]) {
private log(_message, ..._args: any[]) {
// console.log(message, ...args);
}
}

Просмотреть файл

@ -14,7 +14,7 @@ export interface IGremlinEndpoint {
export async function TryGetGremlinEndpointFromAzure(client: CosmosDBManagementClient, resourceGroup: string, account: string): Promise<IGremlinEndpoint | undefined> {
return new Promise<IGremlinEndpoint>((resolve, reject) => {
// Use the callback version of get because the Promise one currently doesn't expose gremlinEndpoint (https://github.com/Azure/azure-documentdb-node/issues/227)
client.databaseAccounts.get(resourceGroup, account, (error, result, httpRequest, response) => {
client.databaseAccounts.get(resourceGroup, account, (error, _result, _httpRequest, response) => {
if (error) {
reject(error);
} else {

Просмотреть файл

@ -123,7 +123,7 @@ export class MongoScriptDocumentVisitor extends MongoVisitor<MongoCommand[]> {
return super.visitArgumentList(ctx);
}
protected defaultResult(node: ParseTree): MongoCommand[] {
protected defaultResult(_node: ParseTree): MongoCommand[] {
return this.commands;
}
}

Просмотреть файл

@ -67,7 +67,7 @@ export class MongoVisitor<T> implements mongoVisitor<T> {
throw new Error(`Error near line ${node._symbol.line}, column ${node.symbol.charPositionInLine + 1}, text '${node.text}'. Please check syntax.`);
}
protected defaultResult(node: ParseTree): T {
protected defaultResult(_node: ParseTree): T {
return null;
}
@ -75,7 +75,7 @@ export class MongoVisitor<T> implements mongoVisitor<T> {
return nextResult === null ? aggregate : nextResult;
}
shouldVisitNextChild(node, currentResult: T): boolean {
shouldVisitNextChild(_node, _currentResult: T): boolean {
return true;
}
}

Просмотреть файл

@ -96,7 +96,7 @@ export class CompletionItemsVisitor extends MongoVisitor<Promise<CompletionItem[
return ctx.parent.accept(this);
}
private getArgumentCompletionItems(documentUri: string, collectionName: string, ctx: ParserRuleContext): Thenable<CompletionItem[]> {
private getArgumentCompletionItems(documentUri: string, _collectionName: string, ctx: ParserRuleContext): Thenable<CompletionItem[]> {
const text = this.textDocument.getText();
const document = TextDocument.create(documentUri, 'json', 1, text.substring(ctx.start.startIndex, ctx.stop.stopIndex + 1));
const positionOffset = this.textDocument.offsetAt(this.at);

Просмотреть файл

@ -25,7 +25,7 @@ export class LanguageService {
this.textDocuments.listen(connection);
// After the server has started the client sends an initilize request. The server receives
// in the passed params the rootPath of the workspace plus the client capabilities.
connection.onInitialize((params: InitializeParams): InitializeResult => {
connection.onInitialize((_params: InitializeParams): InitializeResult => {
return {
capabilities: {
textDocumentSync: this.textDocuments.syncKind, // Tell the client that the server works in FULL text document sync mode

Просмотреть файл

@ -74,7 +74,7 @@ export default class SchemaService {
private _resolveQueryCollectionSchema(collectionName: string, schemaUri: string): Thenable<string> {
const collection = this._db.collection(collectionName)
const cursor = collection.find();
return new Promise((c, e) => {
return new Promise((resolve, _reject) => {
this.readNext([], cursor, 10, (result) => {
const schema: JSONSchema = {
type: 'object',
@ -85,7 +85,7 @@ export default class SchemaService {
}
this.setGlobalOperatorProperties(schema);
this.setLogicalOperatorProperties(schema, schemaUri);
c(JSON.stringify(schema));
resolve(JSON.stringify(schema));
});
})
}
@ -93,13 +93,13 @@ export default class SchemaService {
private _resolveAggregateCollectionSchema(collectionName: string): Thenable<string> {
const collection = this._db.collection(collectionName)
const cursor = collection.find();
return new Promise((c, e) => {
this.readNext([], cursor, 10, (result) => {
return new Promise((resolve, _reject) => {
this.readNext([], cursor, 10, (_result) => {
const schema: JSONSchema = {
type: 'array',
items: this.getAggregateStagePropertiesSchema(this.queryCollectionSchema(collectionName)),
}
c(JSON.stringify(schema));
resolve(JSON.stringify(schema));
});
})
}

Просмотреть файл

@ -251,7 +251,7 @@ function reportProgress<T>(promise: Thenable<T>, title: string): Thenable<T> {
location: vscode.ProgressLocation.Window,
title
},
(progress) => {
(_progress) => {
return promise;
})
}

Просмотреть файл

@ -183,7 +183,7 @@ function reportProgress<T>(promise: Thenable<T>, title: string): Thenable<T> {
location: vscode.ProgressLocation.Window,
title
},
(progress) => {
(_progress) => {
return promise;
})
}

Просмотреть файл

@ -66,7 +66,7 @@ export class AttachedAccountsTreeItem implements IAzureParentTreeItem {
return false;
}
public async loadMoreChildren(_node: IAzureNode, clearCache: boolean): Promise<IAzureTreeItem[]> {
public async loadMoreChildren(_node: IAzureNode, _clearCache: boolean): Promise<IAzureTreeItem[]> {
const attachedAccounts: IAzureTreeItem[] = await this.getAttachedAccounts();
return attachedAccounts.length > 0 ? attachedAccounts : [{

Просмотреть файл

@ -8,7 +8,7 @@ import * as cp from 'child_process';
export async function commandSucceeds(command: string, ...args: string[]): Promise<boolean> {
return await new Promise<boolean>(resolve => {
cp.spawn(command, args)
.on('error', err => resolve(false))
.on('error', _error => resolve(false))
.on('exit', code => resolve(code === 0));
});
}
}

Просмотреть файл

@ -13,7 +13,7 @@ suite("inputValidation Tests", () => {
test("executed", async () => {
let value = await validOnTimeoutOrException(async () => {
return await new Promise<string | undefined>((resolve, reject) => {
return await new Promise<string | undefined>((resolve, _reject) => {
setTimeout(() => { resolve("invalid input"); }, 1);
});
});
@ -24,7 +24,7 @@ suite("inputValidation Tests", () => {
test("timed out",
async () => {
let value = await validOnTimeoutOrException(async () => {
return await new Promise<string | undefined>((resolve, reject) => {
return await new Promise<string | undefined>((resolve, _reject) => {
setTimeout(() => { resolve("invalid input"); }, 1000);
});
},
@ -35,7 +35,7 @@ suite("inputValidation Tests", () => {
test("exception", async () => {
let value = await validOnTimeoutOrException(async () => {
return await new Promise<string | undefined>((resolve, reject) => {
return await new Promise<string | undefined>((_resolve, reject) => {
setTimeout(() => { reject(new Error("Oh, boy")); }, 1);
});
});

Просмотреть файл

@ -24,7 +24,7 @@ suite("timeout Tests", () => {
let executed = false;
await rejectOnTimeout(1, () => {
return new Promise((resolve, reject) => {
return new Promise((resolve, _reject) => {
executed = true;
resolve();
});
@ -37,7 +37,7 @@ suite("timeout Tests", () => {
let executed = false;
await rejectOnTimeout(1000, () => {
return new Promise((resolve, reject) => {
return new Promise((resolve, _reject) => {
setTimeout(() => {
executed = true;
resolve();
@ -52,7 +52,7 @@ suite("timeout Tests", () => {
try {
await rejectOnTimeout(1, async () => {
await new Promise((resolve, reject) => {
await new Promise((resolve, _reject) => {
setTimeout(() => {
executed = true;
resolve();
@ -73,7 +73,7 @@ suite("timeout Tests", () => {
try {
await rejectOnTimeout(1000, async () => {
await new Promise((resolve, reject) => {
await new Promise((_resolve, _reject) => {
throw new Error("I threw up");
});
})
@ -90,7 +90,7 @@ suite("timeout Tests", () => {
test("executed", async () => {
let value = await valueOnTimeout(1000, 123, async () => {
return await new Promise<number>((resolve, reject) => {
return await new Promise<number>((resolve, _reject) => {
setTimeout(() => { resolve(-123); }, 1);
});
});
@ -100,7 +100,7 @@ suite("timeout Tests", () => {
test("timed out", async () => {
let value = await valueOnTimeout(1, 123, async () => {
return await new Promise<number>((resolve, reject) => {
return await new Promise<number>((resolve, _reject) => {
setTimeout(() => { resolve(-123); }, 1000);
});
});
@ -112,7 +112,7 @@ suite("timeout Tests", () => {
let error;
try {
await valueOnTimeout(1000, 123, async () => {
return await new Promise<number>((resolve, reject) => {
return await new Promise<number>((_resolve, reject) => {
setTimeout(() => { reject(new Error("rejected")); }, 1);
});
});

Просмотреть файл

@ -11,6 +11,7 @@
"noImplicitThis": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"rootDir": ".",
"experimentalDecorators": true
},