Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Update deps #288

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
40 changes: 40 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/ban-types": [
"error",
{
"types": {
"object": false
}
}
],
"@typescript-eslint/explicit-module-boundary-types": [
"error",
{
"allowArgumentsExplicitlyTypedAsAny": true
}
],
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}
],
"no-console": "error"
}
}
4 changes: 2 additions & 2 deletions lib/adapters/apply-edit-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
/** Public: Adapts workspace/applyEdit commands to editors. */
export default class ApplyEditAdapter {
/** Public: Attach to a {LanguageClientConnection} to receive edit events. */
public static attach(connection: LanguageClientConnection) {
public static attach(connection: LanguageClientConnection): void {
connection.onApplyEdit((m) => ApplyEditAdapter.onApplyEdit(m));
}

Expand Down Expand Up @@ -49,7 +49,7 @@ export default class ApplyEditAdapter {
if (params.edit.documentChanges) {
changes = {};
params.edit.documentChanges.forEach((change) => {
if (change && change.textDocument) {
if (change && "textDocument" in change && change.textDocument) {
changes[change.textDocument.uri] = change.edits;
}
});
Expand Down
6 changes: 3 additions & 3 deletions lib/adapters/autocomplete-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export default class AutocompleteAdapter {
suggestion: ac.AnySuggestion,
request: ac.SuggestionsRequestedEvent,
onDidConvertCompletionItem?: CompletionItemAdjuster,
) {
): void {
// only the `documentation` and `detail` properties may change when resolving
AutocompleteAdapter.applyDetailsToSuggestion(resolvedCompletionItem, suggestion);
if (onDidConvertCompletionItem != null) {
Expand Down Expand Up @@ -392,7 +392,7 @@ export default class AutocompleteAdapter {
public static applyCompletionItemToSuggestion(
item: CompletionItem,
suggestion: TextSuggestion,
) {
): void {
suggestion.text = item.insertText || item.label;
suggestion.filterText = item.filterText || item.label;
suggestion.displayText = item.label;
Expand All @@ -403,7 +403,7 @@ export default class AutocompleteAdapter {
public static applyDetailsToSuggestion(
item: CompletionItem,
suggestion: Suggestion,
) {
): void {
suggestion.rightLabel = item.detail;

// Older format, can't know what it is so assign to both and hope for best
Expand Down
1 change: 0 additions & 1 deletion lib/adapters/code-action-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ export default class CodeActionAdapter {
getTitle(): Promise<string> {
return Promise.resolve(action.title);
},
// tslint:disable-next-line:no-empty
dispose(): void { },
};
}
Expand Down
7 changes: 5 additions & 2 deletions lib/adapters/notifications-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import {
NotificationOptions,
NotificationExt,
} from 'atom';
import {
NotificationButton,
} from 'atom-ide'

/** Public: Adapts Atom's user notifications to those of the language server protocol. */
export default class NotificationsAdapter {
Expand All @@ -21,7 +24,7 @@ export default class NotificationsAdapter {
connection: LanguageClientConnection,
name: string,
projectPath: string,
) {
): void {
connection.onShowMessage((m) => NotificationsAdapter.onShowMessage(m, name, projectPath));
connection.onShowMessageRequest((m) => NotificationsAdapter.onShowMessageRequest(m, name, projectPath));
}
Expand Down Expand Up @@ -99,7 +102,7 @@ export default class NotificationsAdapter {
*/
public static actionItemToNotificationButton(
actionItem: MessageActionItem,
) {
): NotificationButton {
return {
text: actionItem.title,
};
Expand Down
2 changes: 1 addition & 1 deletion lib/adapters/rename-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default class RenameAdapter {
}

if (edit.documentChanges) {
return RenameAdapter.convertDocumentChanges(edit.documentChanges);
return RenameAdapter.convertDocumentChanges(<TextDocumentEdit[]>edit.documentChanges);
} else if (edit.changes) {
return RenameAdapter.convertChanges(edit.changes);
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/adapters/signature-help-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class SignatureHelpAdapter {
return serverCapabilities.signatureHelpProvider != null;
}

public dispose() {
public dispose(): void {
this._disposables.dispose();
}

Expand Down
18 changes: 13 additions & 5 deletions lib/auto-languageclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
TextEditor,
} from 'atom';
import * as ac from 'atom/autocomplete-plus';
import { TextEdit, CodeAction } from 'atom-ide';

export { ActiveServer, LanguageClientConnection, LanguageServerProcess };
export type ConnectionType = 'stdio' | 'socket' | 'ipc';
Expand Down Expand Up @@ -243,7 +244,7 @@ export default class AutoLanguageClient {
}

/** Restart all active language servers for this language client in the workspace */
protected async restartAllServers() {
protected async restartAllServers(): Promise<void> {
await this._serverManager.restartAllServers();
}

Expand Down Expand Up @@ -331,7 +332,6 @@ export default class AutoLanguageClient {
} else {
this.logger.warn(`Language server has exceeded auto-restart limit for project '${newServer.projectPath}'`);
atom.notifications.addError(
// tslint:disable-next-line:max-line-length
`The ${this.name} language server has exited and exceeded the restart limit for project '${newServer.projectPath}'`);
}
}
Expand Down Expand Up @@ -741,7 +741,11 @@ export default class AutoLanguageClient {
};
}

protected async getCodeActions(editor: TextEditor, range: Range, diagnostics: atomIde.Diagnostic[]) {
protected async getCodeActions(
editor: TextEditor,
range: Range,
diagnostics: atomIde.Diagnostic[]
): Promise<CodeAction[] | null> {
const server = await this._serverManager.getServer(editor);
if (server == null || !CodeActionAdapter.canAdapt(server.capabilities)) {
return null;
Expand All @@ -765,7 +769,11 @@ export default class AutoLanguageClient {
};
}

protected async getRename(editor: TextEditor, position: Point, newName: string) {
protected async getRename(
editor: TextEditor,
position: Point,
newName: string
): Promise<Map<string, TextEdit[]> | null> {
const server = await this._serverManager.getServer(editor);
if (server == null || !RenameAdapter.canAdapt(server.capabilities)) {
return null;
Expand Down Expand Up @@ -810,7 +818,7 @@ export default class AutoLanguageClient {
* Called on language server stderr output.
* @param stderr A chunk of stderr from a language server instance
*/
protected handleServerStderr(stderr: string, _projectPath: string) {
protected handleServerStderr(stderr: string, _projectPath: string): void {
stderr.split('\n').filter((l) => l).forEach((line) => this.logger.warn(`stderr ${line}`));
}

Expand Down
2 changes: 1 addition & 1 deletion lib/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default class Convert {
*/
public static uriToPath(uri: string): string {
const url = URL.parse(uri);
if (url.protocol !== 'file:' || url.path === undefined) {
if (url.protocol !== 'file:' || url.path === undefined || url.path === null) {
return uri;
}

Expand Down
1 change: 1 addition & 0 deletions lib/download-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ async function streamWithProgress(
): Promise<void> {
let bytesDone = 0;

// eslint-disable-next-line no-constant-condition
while (true) {
const result = await reader.read();
if (result.done) {
Expand Down
6 changes: 3 additions & 3 deletions lib/logger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// tslint:disable:no-console
/* eslint-disable no-console */

export interface Logger {
warn(...args: any[]): void;
Expand Down Expand Up @@ -63,8 +63,8 @@ export class FilteredLogger {
private _logger: Logger;
private _predicate: (level: string, args: any[]) => boolean;

public static UserLevelFilter = (level: string, _args: any[]) => level === 'warn' || level === 'error';
public static DeveloperLevelFilter = (_level: string, _args: any[]) => true;
public static UserLevelFilter = (level: string, _args: any[]): boolean => level === 'warn' || level === 'error';
public static DeveloperLevelFilter = (_level: string, _args: any[]): true => true;

constructor(logger: Logger, predicate?: (level: string, args: any[]) => boolean) {
this._logger = logger;
Expand Down
4 changes: 2 additions & 2 deletions lib/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// tslint:disable:no-reference
/* eslint-disable @typescript-eslint/triple-slash-reference */
/// <reference path="../typings/atom/index.d.ts"/>
/// <reference path="../typings/atom-ide/index.d.ts"/>
// tslint:enable:no-reference
/* eslint-enable @typescript-eslint/triple-slash-reference */

import AutoLanguageClient from './auto-languageclient';
import Convert from './convert';
Expand Down
2 changes: 1 addition & 1 deletion lib/server-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export class ServerManager {
this.startListening();
}

public hasServerReachedRestartLimit(server: ActiveServer) {
public hasServerReachedRestartLimit(server: ActiveServer): boolean {
let restartCounter = this._restartCounterPerProject.get(server.projectPath);

if (!restartCounter) {
Expand Down
Loading