Skip to content

Commit e2b8176

Browse files
Frédéric Collonvaljtpio
authored andcommitted
Correct lint errors
1 parent 3132ddd commit e2b8176

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

src/index.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import {
22
JupyterFrontEnd,
33
JupyterFrontEndPlugin
4-
} from "@jupyterlab/application";
4+
} from '@jupyterlab/application';
55

6-
import { PathExt } from "@jupyterlab/coreutils";
6+
import { PathExt } from '@jupyterlab/coreutils';
77

8-
import { IMainMenu } from "@jupyterlab/mainmenu";
8+
import { IMainMenu } from '@jupyterlab/mainmenu';
99

10-
import { INotebookTracker, NotebookActions } from "@jupyterlab/notebook";
10+
import { INotebookTracker, NotebookActions } from '@jupyterlab/notebook';
1111

1212
import { CommandRegistry } from '@lumino/commands';
1313

@@ -16,16 +16,16 @@ import {
1616
pythonIcon,
1717
terminalIcon,
1818
textEditorIcon,
19-
folderIcon,
19+
folderIcon
2020
} from '@jupyterlab/ui-components';
2121

22-
import { listSnippets, Snippet, fetchSnippet } from "./snippets";
22+
import { listSnippets, Snippet, fetchSnippet } from './snippets';
2323

2424
/**
2525
* The command IDs used by the snippets plugin.
2626
*/
2727
namespace CommandIDs {
28-
export const open = "snippets:open";
28+
export const open = 'snippets:open';
2929
}
3030

3131
/**
@@ -46,7 +46,7 @@ function toTree(snippets: Snippet[]) {
4646
node.set(part, new Map<string, Tree>());
4747
}
4848
node = node.get(part);
49-
})
49+
});
5050
});
5151
return tree;
5252
}
@@ -57,7 +57,11 @@ function toTree(snippets: Snippet[]) {
5757
* @param tree The tree of snippets.
5858
* @param path The current path in the tree.
5959
*/
60-
function createMenu(commands: CommandRegistry , tree: Tree, path: string[] = []) {
60+
function createMenu(
61+
commands: CommandRegistry,
62+
tree: Tree,
63+
path: string[] = []
64+
) {
6165
const menu = new MenuSvg({ commands });
6266
for (const [name, map] of tree.entries()) {
6367
const fullpath = path.concat(name);
@@ -70,7 +74,7 @@ function createMenu(commands: CommandRegistry , tree: Tree, path: string[] = [])
7074
const submenu = createMenu(commands, map, path.concat(name));
7175
submenu.title.label = name;
7276
submenu.title.icon = folderIcon;
73-
menu.addItem({type: 'submenu', submenu});
77+
menu.addItem({ type: 'submenu', submenu });
7478
}
7579
}
7680
return menu;
@@ -80,7 +84,7 @@ function createMenu(commands: CommandRegistry , tree: Tree, path: string[] = [])
8084
* Initialization data for the jupyterlab-snippets extension.
8185
*/
8286
const extension: JupyterFrontEndPlugin<void> = {
83-
id: "jupyterlab-snippets",
87+
id: 'jupyterlab-snippets',
8488
autoStart: true,
8589
optional: [IMainMenu, INotebookTracker],
8690
activate: async (
@@ -95,7 +99,7 @@ const extension: JupyterFrontEndPlugin<void> = {
9599
notebookTracker?.currentWidget !== null &&
96100
notebookTracker?.currentWidget === app.shell.currentWidget
97101
);
98-
}
102+
};
99103

100104
commands.addCommand(CommandIDs.open, {
101105
label: args => args['label'] as string,

src/snippets.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { URLExt } from "@jupyterlab/coreutils";
1+
import { URLExt } from '@jupyterlab/coreutils';
22

3-
import { ServerConnection } from "@jupyterlab/services";
3+
import { ServerConnection } from '@jupyterlab/services';
44

55
/**
66
* The type for a Snippet.
@@ -10,27 +10,27 @@ export type Snippet = string[];
1010
/**
1111
* The Snippet Content interface
1212
*/
13-
export interface SnippetContent {
13+
export interface ISnippetContent {
1414
content: string;
1515
}
1616

1717
/**
1818
* List the available snippets.
1919
*/
20-
export async function listSnippets() {
21-
return requestAPI<Snippet[]>("list");
20+
export async function listSnippets(): Promise<Snippet[]> {
21+
return requestAPI<Snippet[]>('list');
2222
}
2323

2424
/**
2525
* Fetch a snippet given its path.
2626
* @param snippet The path of the snippet to fetch.
2727
*/
28-
export async function fetchSnippet(snippet: Snippet) {
29-
let request: RequestInit = {
28+
export async function fetchSnippet(snippet: Snippet): Promise<ISnippetContent> {
29+
const request: RequestInit = {
3030
method: 'POST',
3131
body: JSON.stringify({ snippet })
3232
};
33-
return requestAPI<SnippetContent>("get", request);
33+
return requestAPI<ISnippetContent>('get', request);
3434
}
3535

3636
/**
@@ -41,15 +41,11 @@ export async function fetchSnippet(snippet: Snippet) {
4141
* @returns The response body interpreted as JSON
4242
*/
4343
async function requestAPI<T>(
44-
endPoint: string = "",
44+
endPoint = '',
4545
init: RequestInit = {}
4646
): Promise<T> {
4747
const settings = ServerConnection.makeSettings();
48-
const requestUrl = URLExt.join(
49-
settings.baseUrl,
50-
"snippets",
51-
endPoint
52-
);
48+
const requestUrl = URLExt.join(settings.baseUrl, 'snippets', endPoint);
5349

5450
let response: Response;
5551
try {

0 commit comments

Comments
 (0)