提交 813d3aa3 编写于 作者: M Matt Bierner

Fixing some more restrictive tslint errors

上级 bd314b04
......@@ -12,10 +12,8 @@ import { isImplicitProjectConfigFile, openOrCreateConfigFile } from './utils/tsc
import { nulToken } from './utils/cancellation';
import { PluginConfigProvider } from './typescriptServiceClient';
const localize = nls.loadMessageBundle();
export class ReloadTypeScriptProjectsCommand implements Command {
public readonly id = 'typescript.reloadProjects';
......@@ -143,7 +141,7 @@ async function goToProjectConfig(
return;
}
let res: protocol.ProjectInfoResponse | undefined = undefined;
let res: protocol.ProjectInfoResponse | undefined;
try {
res = await client.execute('projectInfo', { file, needFileNameList: false }, nulToken);
} catch {
......@@ -164,7 +162,7 @@ async function goToProjectConfig(
enum ProjectConfigAction {
None,
CreateConfig,
LearnMore
LearnMore,
}
interface ProjectConfigMessageItem extends vscode.MessageItem {
......@@ -179,7 +177,7 @@ async function goToProjectConfig(
title: isTypeScriptProject
? localize('typescript.configureTsconfigQuickPick', 'Configure tsconfig.json')
: localize('typescript.configureJsconfigQuickPick', 'Configure jsconfig.json'),
id: ProjectConfigAction.CreateConfig
id: ProjectConfigAction.CreateConfig,
});
switch (selected && selected.id) {
......
......@@ -116,8 +116,6 @@ function createLazyClientHost(
const surveyor = new Surveyor(context.globalState);
context.subscriptions.push(clientHost.serviceClient.onSurveyReady(e => surveyor.surveyReady(e.surveyId)));
clientHost.serviceClient.onReady(() => {
context.subscriptions.push(
ProjectStatus.create(
......
......@@ -21,7 +21,6 @@ import FileConfigurationManager from './fileConfigurationManager';
const localize = nls.loadMessageBundle();
interface CommitCharactersSettings {
readonly isNewIdentifierLocation: boolean;
readonly isInValidCommitCharacterContext: boolean;
......@@ -223,7 +222,6 @@ class CompositeCommand implements Command {
}
}
class CompletionAcceptedCommand implements Command {
public static readonly ID = '_typescript.onCompletionAccepted';
public readonly id = CompletionAcceptedCommand.ID;
......@@ -359,7 +357,7 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider
...typeConverters.Position.toFileLocationRequestArgs(file, position),
includeExternalModuleExports: completionConfiguration.autoImportSuggestions,
includeInsertTextCompletions: true,
triggerCharacter: this.getTsTriggerCharacter(context)
triggerCharacter: this.getTsTriggerCharacter(context),
};
let isNewIdentifierLocation = true;
......
......@@ -37,11 +37,11 @@ export default class TypeScriptDefinitionProvider extends DefinitionProviderBase
return response.body.definitions
.map(location => {
const target = typeConverters.Location.fromTextSpan(this.client.toResource(location.file), location);
return <vscode.DefinitionLink>{
return {
originSelectionRange: span,
targetRange: target.range,
targetUri: target.uri,
};
} as vscode.DefinitionLink;
});
}
......
......@@ -10,7 +10,7 @@ import { DiagnosticLanguage, allDiagnosticLangauges } from '../utils/languageDes
export const enum DiagnosticKind {
Syntax,
Semantic,
Suggestion
Suggestion,
}
class FileDiagnostics {
......@@ -97,7 +97,7 @@ class DiagnosticSettings {
public setValidate(language: DiagnosticLanguage, value: boolean): boolean {
return this.update(language, settings => ({
validate: value,
enableSuggestions: settings.enableSuggestions
enableSuggestions: settings.enableSuggestions,
}));
}
......
......@@ -41,7 +41,7 @@ export default class FileConfigurationManager {
public constructor(
private readonly client: ITypeScriptServiceClient
) {
this.onDidCloseTextDocumentSub = vscode.workspace.onDidCloseTextDocument((textDocument) => {
this.onDidCloseTextDocumentSub = vscode.workspace.onDidCloseTextDocument(textDocument => {
// When a document gets closed delete the cached formatting options.
// This is necessary since the tsserver now closed a project when its
// last file in it closes which drops the stored formatting options
......
......@@ -23,25 +23,25 @@ const jsTsLanguageConfiguration: vscode.LanguageConfiguration = {
// e.g. /** | */
beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
afterText: /^\s*\*\/$/,
action: { indentAction: vscode.IndentAction.IndentOutdent, appendText: ' * ' }
action: { indentAction: vscode.IndentAction.IndentOutdent, appendText: ' * ' },
}, {
// e.g. /** ...|
beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
action: { indentAction: vscode.IndentAction.None, appendText: ' * ' }
action: { indentAction: vscode.IndentAction.None, appendText: ' * ' },
}, {
// e.g. * ...|
beforeText: /^(\t|[ ])*[ ]\*([ ]([^\*]|\*(?!\/))*)?$/,
oneLineAboveText: /^(\s*(\/\*\*|\*)).*/,
action: { indentAction: vscode.IndentAction.None, appendText: '* ' }
action: { indentAction: vscode.IndentAction.None, appendText: '* ' },
}, {
// e.g. */|
beforeText: /^(\t|[ ])*[ ]\*\/\s*$/,
action: { indentAction: vscode.IndentAction.None, removeText: 1 }
action: { indentAction: vscode.IndentAction.None, removeText: 1 },
},
{
// e.g. *-----*/|
beforeText: /^(\t|[ ])*[ ]\*[^/]*\*\/\s*$/,
action: { indentAction: vscode.IndentAction.None, removeText: 1 }
action: { indentAction: vscode.IndentAction.None, removeText: 1 },
}
]
};
......
......@@ -82,7 +82,7 @@ class ApplyFixAllCodeAction implements Command {
type: 'file',
args: { file }
},
fixId: tsAction.fixId
fixId: tsAction.fixId,
};
const response = await this.client.execute('getCombinedCodeFix', args, nulToken);
......
......@@ -40,13 +40,13 @@ class ApplyRefactoringCommand implements Command {
}
*/
this.telemetryReporter.logTelemetry('refactor.execute', {
action: action
action: action,
});
const args: Proto.GetEditsForRefactorRequestArgs = {
...typeConverters.Range.toFileRangeRequestArgs(file, range),
refactor,
action
action,
};
const response = await this.client.execute('getEditsForRefactor', args, nulToken);
if (response.type !== 'response' || !response.body || !response.body.edits.length) {
......@@ -94,7 +94,7 @@ class SelectRefactorCommand implements Command {
): Promise<boolean> {
const selected = await vscode.window.showQuickPick(info.actions.map((action): vscode.QuickPickItem => ({
label: action.name,
description: action.description
description: action.description,
})));
if (!selected) {
return false;
......@@ -119,7 +119,7 @@ class TypeScriptRefactorProvider implements vscode.CodeActionProvider {
}
public static readonly metadata: vscode.CodeActionProviderMetadata = {
providedCodeActionKinds: [vscode.CodeActionKind.Refactor]
providedCodeActionKinds: [vscode.CodeActionKind.Refactor],
};
public async provideCodeActions(
......
......@@ -296,14 +296,14 @@ class UpdateImportsOnFileRenameHandler {
start: change.start,
end: {
line: change.end.line,
offset: change.end.offset - match[1].length
}
offset: change.end.offset - match[1].length,
},
};
});
return {
fileName: edit.fileName,
textChanges
textChanges,
};
}
}
......
......@@ -75,4 +75,3 @@ suite('typescript.jsDocSnippet', () => {
].join('\n'));
});
});
......@@ -32,8 +32,7 @@ export class CallbackMap<R extends Proto.Response> {
public add(seq: number, callback: CallbackItem<ServerResponse<R> | undefined>, isAsync: boolean) {
if (isAsync) {
this._asyncCallbacks.set(seq, callback);
}
else {
} else {
this._callbacks.set(seq, callback);
}
}
......
......@@ -60,7 +60,7 @@ export class TypeScriptServerSpawner {
private getForkOptions() {
const debugPort = TypeScriptServerSpawner.getDebugPort();
const tsServerForkOptions: electron.IForkOptions = {
const tsServerForkOptions: electron.ForkOptions = {
execArgv: debugPort ? [`--inspect=${debugPort}`] : [],
};
return tsServerForkOptions;
......@@ -72,8 +72,8 @@ export class TypeScriptServerSpawner {
plugins: ReadonlyArray<TypeScriptServerPlugin>,
): { args: string[], cancellationPipeName: string | undefined, tsServerLogFile: string | undefined } {
const args: string[] = [];
let cancellationPipeName: string | undefined = undefined;
let tsServerLogFile: string | undefined = undefined;
let cancellationPipeName: string | undefined;
let tsServerLogFile: string | undefined;
const apiVersion = currentVersion.version || API.defaultVersion;
......@@ -298,7 +298,7 @@ export class TypeScriptServer extends Disposable {
public executeImpl(command: string, args: any, executeInfo: { isAsync: boolean, token?: vscode.CancellationToken, expectsResult: boolean, lowPriority?: boolean }): Promise<any> {
const request = this._requestQueue.createRequest(command, args);
const requestInfo: RequestItem = {
request: request,
request,
expectsResponse: executeInfo.expectsResult,
isAsync: executeInfo.isAsync,
queueingType: getQueueingType(command, executeInfo.lowPriority)
......
......@@ -12,7 +12,7 @@ import Logger from './utils/logger';
import { TypeScriptServerPlugin } from './utils/plugins';
export class CancelledResponse {
readonly type: 'cancelled' = 'cancelled';
public readonly type: 'cancelled' = 'cancelled';
constructor(
public readonly reason: string
......@@ -20,7 +20,7 @@ export class CancelledResponse {
}
export class NoContentResponse {
readonly type: 'noContent' = 'noContent';
public readonly type: 'noContent' = 'noContent';
}
export type ServerResponse<T extends Proto.Response> = T | CancelledResponse | NoContentResponse;
......@@ -57,7 +57,6 @@ interface TypeScriptRequestTypes {
'typeDefinition': [Proto.FileLocationRequestArgs, Proto.TypeDefinitionResponse];
}
export interface ITypeScriptServiceClient {
/**
* Convert a resource (VS Code) to a normalized path (TypeScript).
......
......@@ -420,7 +420,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
private serviceStarted(resendModels: boolean): void {
const configureOptions: Proto.ConfigureRequestArguments = {
hostInfo: 'vscode'
hostInfo: 'vscode',
};
this.executeWithoutWaitingForResponse('configure', configureOptions);
this.setCompilerOptionsForInferredProjects(this._configuration);
......@@ -485,7 +485,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
localize('serverDiedAfterStart', 'The TypeScript language service died 5 times right after it got started. The service will not be restarted.'),
{
title: localize('serverDiedReportIssue', 'Report Issue'),
id: MessageAction.reportIssue
id: MessageAction.reportIssue,
});
/* __GDPR__
"serviceExited" : {
......
......@@ -38,7 +38,7 @@ function generatePatchedEnv(env: any, modulePath: string): any {
return newEnv;
}
export interface IForkOptions {
export interface ForkOptions {
readonly cwd?: string;
readonly execArgv?: string[];
}
......@@ -46,7 +46,7 @@ export interface IForkOptions {
export function fork(
modulePath: string,
args: string[],
options: IForkOptions,
options: ForkOptions,
): cp.ChildProcess {
const newEnv = generatePatchedEnv(process.env, modulePath);
return cp.fork(modulePath, args, {
......
......@@ -4,8 +4,8 @@
*--------------------------------------------------------------------------------------------*/
export function memoize(_target: any, key: string, descriptor: any) {
let fnKey: string | undefined = undefined;
let fn: Function | undefined = undefined;
let fnKey: string | undefined;
let fn: Function | undefined;
if (typeof descriptor.value === 'function') {
fnKey = 'value';
......
......@@ -7,7 +7,7 @@ import * as vscode from 'vscode';
import VsCodeTelemetryReporter from 'vscode-extension-telemetry';
import { memoize } from './memoize';
interface IPackageInfo {
interface PackageInfo {
readonly name: string;
readonly version: string;
readonly aiKey: string;
......@@ -58,7 +58,7 @@ export default class TelemetryReporter {
}
@memoize
private get packageInfo(): IPackageInfo | null {
private get packageInfo(): PackageInfo | null {
const { packageJSON } = vscode.extensions.getExtension('vscode.typescript-language-features')!;
if (packageJSON) {
return {
......
......@@ -10,7 +10,7 @@ import Logger from './logger';
enum Trace {
Off,
Messages,
Verbose
Verbose,
}
namespace Trace {
......
......@@ -8,7 +8,6 @@ import * as vscode from 'vscode';
import * as Proto from '../protocol';
import { TypeScriptServiceConfiguration } from './configuration';
export function isImplicitProjectConfigFile(configFileName: string) {
return configFileName.indexOf('/dev/null/') === 0;
}
......
......@@ -41,7 +41,7 @@ export namespace Position {
export const toFileLocationRequestArgs = (file: string, position: vscode.Position): Proto.FileLocationRequestArgs => ({
file,
line: position.line + 1,
offset: position.character + 1
offset: position.character + 1,
});
}
......
......@@ -19,7 +19,7 @@ interface MyQuickPickItem extends vscode.QuickPickItem {
enum MessageAction {
useLocal,
useBundled,
learnMore
learnMore,
}
export class TypeScriptVersionPicker {
......@@ -61,7 +61,7 @@ export class TypeScriptVersionPicker {
: '') + localize('useVSCodeVersionOption', 'Use VS Code\'s Version'),
description: shippedVersion.versionString,
detail: shippedVersion.pathLabel,
id: MessageAction.useBundled
id: MessageAction.useBundled,
});
for (const version of this.versionProvider.localVersions) {
......@@ -72,7 +72,7 @@ export class TypeScriptVersionPicker {
description: version.versionString,
detail: version.pathLabel,
id: MessageAction.useLocal,
version: version
version
});
}
......@@ -86,7 +86,7 @@ export class TypeScriptVersionPicker {
placeHolder: localize(
'selectTsVersion',
'Select the TypeScript version used for JavaScript and TypeScript language features'),
ignoreFocusOut: firstRun
ignoreFocusOut: firstRun,
});
if (!selected) {
......@@ -112,7 +112,6 @@ export class TypeScriptVersionPicker {
this._currentVersion = shippedVersion;
return { oldVersion: previousVersion, newVersion: shippedVersion };
case MessageAction.learnMore:
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://go.microsoft.com/fwlink/?linkid=839919'));
return { oldVersion: this.currentVersion };
......
......@@ -87,7 +87,6 @@ export class TypeScriptVersion {
}
}
export class TypeScriptVersionProvider {
private readonly relativePathResolver: RelativeWorkspacePathResolver = new RelativeWorkspacePathResolver();
......
......@@ -18,7 +18,7 @@ export default class VersionStatus {
this._onChangeEditorSub = vscode.window.onDidChangeActiveTextEditor(this.showHideStatus, this);
}
dispose() {
public dispose() {
this._versionBarEntry.dispose();
this._onChangeEditorSub.dispose();
}
......
......@@ -7,29 +7,29 @@ import * as stream from 'stream';
import * as vscode from 'vscode';
import { Disposable } from './dispose';
const DefaultSize: number = 8192;
const ContentLength: string = 'Content-Length: ';
const ContentLengthSize: number = Buffer.byteLength(ContentLength, 'utf8');
const Blank: number = Buffer.from(' ', 'utf8')[0];
const BackslashR: number = Buffer.from('\r', 'utf8')[0];
const BackslashN: number = Buffer.from('\n', 'utf8')[0];
const defaultSize: number = 8192;
const contentLength: string = 'Content-Length: ';
const contentLengthSize: number = Buffer.byteLength(contentLength, 'utf8');
const blank: number = Buffer.from(' ', 'utf8')[0];
const backslashR: number = Buffer.from('\r', 'utf8')[0];
const backslashN: number = Buffer.from('\n', 'utf8')[0];
class ProtocolBuffer {
private index: number = 0;
private buffer: Buffer = Buffer.allocUnsafe(DefaultSize);
private buffer: Buffer = Buffer.allocUnsafe(defaultSize);
public append(data: string | Buffer): void {
let toAppend: Buffer | null = null;
if (Buffer.isBuffer(data)) {
toAppend = <Buffer>data;
toAppend = data;
} else {
toAppend = Buffer.from(<string>data, 'utf8');
toAppend = Buffer.from(data, 'utf8');
}
if (this.buffer.length - this.index >= toAppend.length) {
toAppend.copy(this.buffer, this.index, 0, toAppend.length);
} else {
let newSize = (Math.ceil((this.index + toAppend.length) / DefaultSize) + 1) * DefaultSize;
let newSize = (Math.ceil((this.index + toAppend.length) / defaultSize) + 1) * defaultSize;
if (this.index === 0) {
this.buffer = Buffer.allocUnsafe(newSize);
toAppend.copy(this.buffer, 0, 0, toAppend.length);
......@@ -44,18 +44,18 @@ class ProtocolBuffer {
let result = -1;
let current = 0;
// we are utf8 encoding...
while (current < this.index && (this.buffer[current] === Blank || this.buffer[current] === BackslashR || this.buffer[current] === BackslashN)) {
while (current < this.index && (this.buffer[current] === blank || this.buffer[current] === backslashR || this.buffer[current] === backslashN)) {
current++;
}
if (this.index < current + ContentLengthSize) {
if (this.index < current + contentLengthSize) {
return result;
}
current += ContentLengthSize;
current += contentLengthSize;
let start = current;
while (current < this.index && this.buffer[current] !== BackslashR) {
while (current < this.index && this.buffer[current] !== backslashR) {
current++;
}
if (current + 3 >= this.index || this.buffer[current + 1] !== BackslashN || this.buffer[current + 2] !== BackslashR || this.buffer[current + 3] !== BackslashN) {
if (current + 3 >= this.index || this.buffer[current + 1] !== backslashN || this.buffer[current + 2] !== backslashR || this.buffer[current + 3] !== backslashN) {
return result;
}
let data = this.buffer.toString('utf8', start, current);
......@@ -71,7 +71,7 @@ class ProtocolBuffer {
}
let result = this.buffer.toString('utf8', 0, length);
let sourceStart = length;
while (sourceStart < this.index && (this.buffer[sourceStart] === BackslashR || this.buffer[sourceStart] === BackslashN)) {
while (sourceStart < this.index && (this.buffer[sourceStart] === backslashR || this.buffer[sourceStart] === backslashN)) {
sourceStart++;
}
this.buffer.copy(this.buffer, 0, sourceStart);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册