mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Enable stricter compile options on extensions (#5044)
* enable stricter compile settings in extensions * more strict compile * formatting * formatting * revert some changes * formtting * formatting
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
// This code is originally from https://github.com/DonJayamanne/bowerVSCode
|
||||
// License: https://github.com/DonJayamanne/bowerVSCode/blob/master/LICENSE
|
||||
|
||||
import { window, OutputChannel } from 'vscode';
|
||||
import * as Constants from '../common/constants';
|
||||
import * as nodeUtil from 'util';
|
||||
import { window } from 'vscode';
|
||||
import PromptFactory from './factory';
|
||||
import EscapeException from './escapeException';
|
||||
import { IQuestion, IPrompter, IPromptCallback } from './question';
|
||||
@@ -13,95 +9,12 @@ import { IQuestion, IPrompter, IPromptCallback } from './question';
|
||||
// Supports simple pattern for prompting for user input and acting on this
|
||||
export default class CodeAdapter implements IPrompter {
|
||||
|
||||
private outChannel: OutputChannel;
|
||||
private outBuffer: string = '';
|
||||
private messageLevelFormatters = {};
|
||||
constructor() {
|
||||
// TODO Decide whether output channel logging should be saved here?
|
||||
this.outChannel = window.createOutputChannel(Constants.outputChannelName);
|
||||
// this.outChannel.clear();
|
||||
}
|
||||
|
||||
public logError(message: any): void {
|
||||
let line = `error: ${message.message}\n Code - ${message.code}`;
|
||||
|
||||
this.outBuffer += `${line}\n`;
|
||||
this.outChannel.appendLine(line);
|
||||
}
|
||||
|
||||
// private formatInfo(message: any) {
|
||||
// const prefix = `${message.level}: (${message.id}) `;
|
||||
// if (message.id === "json") {
|
||||
// let jsonString = JSON.stringify(message.data, undefined, 4);
|
||||
// return `${prefix}${message.message}\n${jsonString}`;
|
||||
// }
|
||||
// else {
|
||||
// return `${prefix}${message.message}`;
|
||||
// }
|
||||
// }
|
||||
|
||||
// private formatAction(message: any) {
|
||||
// const prefix = `info: ${message.level}: (${message.id}) `;
|
||||
// return `${prefix}${message.message}`;
|
||||
// }
|
||||
|
||||
private formatMessage(message: any): string {
|
||||
const prefix = `${message.level}: (${message.id}) `;
|
||||
return `${prefix}${message.message}`;
|
||||
}
|
||||
|
||||
// private formatConflict(message: any) {
|
||||
// var msg = message.message + ':\n';
|
||||
// var picks = (<any[]>message.data.picks);
|
||||
// var pickCount = 1;
|
||||
// picks.forEach((pick) => {
|
||||
// let pickMessage = (pickCount++).toString() + "). " + pick.endpoint.name + "#" + pick.endpoint.target;
|
||||
// if (pick.pkgMeta._resolution && pick.pkgMeta._resolution.tag) {
|
||||
// pickMessage += " which resolved to " + pick.pkgMeta._resolution.tag
|
||||
// }
|
||||
// if (Array.isArray(pick.dependants) && pick.dependants.length > 0) {
|
||||
// pickMessage += " and is required by ";
|
||||
// pick.dependants.forEach((dep) => {
|
||||
// pickMessage += " " + dep.endpoint.name + "#" + dep.endpoint.target;
|
||||
// });
|
||||
// }
|
||||
// msg += " " + pickMessage + "\n";
|
||||
// });
|
||||
|
||||
// var prefix = (message.id === "solved"? "info" : "warn") + `: ${message.level}: (${message.id}) `;
|
||||
// return prefix + msg;
|
||||
// }
|
||||
|
||||
public log(message: any): void {
|
||||
let line: string = '';
|
||||
if (message && typeof (message.level) === 'string') {
|
||||
let formatter: (a: any) => string = this.formatMessage;
|
||||
if (this.messageLevelFormatters[message.level]) {
|
||||
formatter = this.messageLevelFormatters[message.level];
|
||||
}
|
||||
line = formatter(message);
|
||||
} else {
|
||||
line = nodeUtil.format(arguments);
|
||||
}
|
||||
|
||||
this.outBuffer += `${line}\n`;
|
||||
this.outChannel.appendLine(line);
|
||||
}
|
||||
|
||||
public clearLog(): void {
|
||||
this.outChannel.clear();
|
||||
}
|
||||
|
||||
public showLog(): void {
|
||||
this.outChannel.show();
|
||||
}
|
||||
|
||||
// TODO define question interface
|
||||
private fixQuestion(question: any): any {
|
||||
if (question.type === 'checkbox' && Array.isArray(question.choices)) {
|
||||
// For some reason when there's a choice of checkboxes, they aren't formatted properly
|
||||
// Not sure where the issue is
|
||||
question.choices = question.choices.map(item => {
|
||||
question.choices = question.choices.map((item: any) => {
|
||||
if (typeof (item) === 'string') {
|
||||
return { checked: false, name: item, value: item };
|
||||
} else {
|
||||
@@ -118,6 +31,7 @@ export default class CodeAdapter implements IPrompter {
|
||||
let response: T = answers[question.name];
|
||||
return response || undefined;
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -139,7 +53,7 @@ export default class CodeAdapter implements IPrompter {
|
||||
// }
|
||||
|
||||
if (!question.shouldPrompt || question.shouldPrompt(answers) === true) {
|
||||
return prompt.render().then(result => {
|
||||
return prompt.render().then((result: any) => {
|
||||
answers[question.name] = result;
|
||||
|
||||
if (question.onAnswered) {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
// This code is originally from https://github.com/DonJayamanne/bowerVSCode
|
||||
// License: https://github.com/DonJayamanne/bowerVSCode/blob/master/LICENSE
|
||||
|
||||
@@ -16,7 +14,7 @@ export default class CheckboxPrompt extends Prompt {
|
||||
}
|
||||
|
||||
public render(): any {
|
||||
let choices = this._question.choices.reduce((result, choice) => {
|
||||
let choices = this._question.choices.reduce((result: any, choice: any) => {
|
||||
let choiceName = choice.name || choice;
|
||||
result[`${choice.checked === true ? figures.radioOn : figures.radioOff} ${choiceName}`] = choice;
|
||||
return result;
|
||||
@@ -40,7 +38,7 @@ export default class CheckboxPrompt extends Prompt {
|
||||
return this.render();
|
||||
}
|
||||
|
||||
return this._question.choices.reduce((result2, choice) => {
|
||||
return this._question.choices.reduce((result2: any, choice: any) => {
|
||||
if (choice.checked === true) {
|
||||
result2.push(choice.value);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
// This code is originally from https://github.com/DonJayamanne/bowerVSCode
|
||||
// License: https://github.com/DonJayamanne/bowerVSCode/blob/master/LICENSE
|
||||
|
||||
@@ -39,7 +37,7 @@ export default class ExpandPrompt extends Prompt {
|
||||
});
|
||||
}
|
||||
private renderNameValueChoice(choices: INameValueChoice[]): any {
|
||||
const choiceMap = this._question.choices.reduce((result, choice) => {
|
||||
const choiceMap = this._question.choices.reduce((result: any, choice: any) => {
|
||||
result[choice.name] = choice.value;
|
||||
return result;
|
||||
}, {});
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
// This code is originally from https://github.com/DonJayamanne/bowerVSCode
|
||||
// License: https://github.com/DonJayamanne/bowerVSCode/blob/master/LICENSE
|
||||
|
||||
@@ -14,7 +12,7 @@ export default class ListPrompt extends Prompt {
|
||||
}
|
||||
|
||||
public render(): any {
|
||||
const choices = this._question.choices.reduce((result, choice) => {
|
||||
const choices = this._question.choices.reduce((result: any, choice: any) => {
|
||||
result[choice.name] = choice.value;
|
||||
return result;
|
||||
}, {});
|
||||
|
||||
Reference in New Issue
Block a user