Skip to content

Commit 5fce87a

Browse files
committed
style fixes
1 parent b473e99 commit 5fce87a

35 files changed

+348
-371
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ jobs:
4949
node-version: 12.x
5050
- run: npm install
5151
- run: npm run compile
52+
- name: lint
53+
if: runner.os == 'Linux'
54+
run: npm run lint
5255
- name: npm test
5356
uses: GabrielBB/[email protected]
5457
with:

src/api/index.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ export class AtelierAPI {
7272

7373
public updateCookies(newCookies: string[]): Promise<any> {
7474
const cookies = this.cache.get("cookies", []);
75-
newCookies.forEach(cookie => {
75+
newCookies.forEach((cookie) => {
7676
const [cookieName] = cookie.split("=");
77-
const index = cookies.findIndex(el => el.startsWith(cookieName));
77+
const index = cookies.findIndex((el) => el.startsWith(cookieName));
7878
if (index >= 0) {
7979
cookies[index] = cookie;
8080
} else {
@@ -123,7 +123,7 @@ export class AtelierAPI {
123123
return "";
124124
}
125125
const result = [];
126-
Object.keys(params).forEach(key => {
126+
Object.keys(params).forEach((key) => {
127127
const value = params[key];
128128
if (typeof value === "boolean") {
129129
result.push(`${key}=${value ? "1" : "0"}`);
@@ -156,7 +156,7 @@ export class AtelierAPI {
156156
auth = this.request(0, "HEAD");
157157
}
158158
const connInfo = `${host}:${port}[${this.ns}]`;
159-
return auth.then(cookie => {
159+
return auth.then((cookie) => {
160160
return (
161161
request({
162162
agent,
@@ -173,8 +173,8 @@ export class AtelierAPI {
173173
uri: `${proto}://${host}:${port}${path}`,
174174
})
175175
// .catch(error => error.error)
176-
.then(response => this.updateCookies(response.headers["set-cookie"]).then(() => response))
177-
.then(response => {
176+
.then((response) => this.updateCookies(response.headers["set-cookie"]).then(() => response))
177+
.then((response) => {
178178
panel.text = `${connInfo} - Connected`;
179179
// console.log(`APIResponse: ${method} ${proto}://${host}:${port}${path}`)
180180
if (method === "HEAD") {
@@ -188,18 +188,19 @@ export class AtelierAPI {
188188
}
189189
if (data.console) {
190190
// Let studio actions handle their console output
191-
const isStudioAction = data.result.content != undefined
192-
&& data.result.content.length !== 0
193-
&& data.result.content[0] != undefined
194-
&& data.result.content[0].action != undefined;
195-
if(!isStudioAction) {
191+
const isStudioAction =
192+
data.result.content != undefined &&
193+
data.result.content.length !== 0 &&
194+
data.result.content[0] != undefined &&
195+
data.result.content[0].action != undefined;
196+
if (!isStudioAction) {
196197
outputConsole(data.console);
197198
}
198199
}
199200
if (data.result.status && data.result.status !== "") {
200201
const status: string = data.result.status;
201202
outputChannel.appendLine(status);
202-
if(status.endsWith("is marked as read only by source control hooks.")) {
203+
if (status.endsWith("is marked as read only by source control hooks.")) {
203204
vscode.window.showWarningMessage(status, { modal: true });
204205
}
205206
throw new Error(data.result.status);
@@ -212,7 +213,7 @@ export class AtelierAPI {
212213
return data;
213214
}
214215
})
215-
.catch(error => {
216+
.catch((error) => {
216217
if (error.error && error.error.code === "ECONNREFUSED") {
217218
setTimeout(checkConnection, 1000);
218219
}
@@ -224,7 +225,7 @@ export class AtelierAPI {
224225
}
225226

226227
public serverInfo(): Promise<any> {
227-
return this.request(0, "GET").then(info => {
228+
return this.request(0, "GET").then((info) => {
228229
if (info && info.result && info.result.content && info.result.content.api > 0) {
229230
const data = info.result.content;
230231
const apiVersion = data.api;

src/commands/compile.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async function importFile(file: CurrentFile): Promise<any> {
3232
}
3333

3434
function updateOthers(others: string[]) {
35-
others.forEach(item => {
35+
others.forEach((item) => {
3636
const uri = DocumentContentProvider.getUri(item);
3737
documentContentProvider.update(uri);
3838
});
@@ -44,10 +44,10 @@ export async function loadChanges(files: CurrentFile[]): Promise<any> {
4444
}
4545
const api = new AtelierAPI(files[0].uri);
4646
return Promise.all(
47-
files.map(file =>
47+
files.map((file) =>
4848
api
4949
.getDoc(file.name)
50-
.then(data => {
50+
.then((data) => {
5151
const content = (data.result.content || []).join("\n");
5252
if (file.uri.scheme === "file") {
5353
fs.writeFileSync(file.fileName, content);
@@ -59,7 +59,7 @@ export async function loadChanges(files: CurrentFile[]): Promise<any> {
5959
}
6060
})
6161
.then(() => api.actionIndex([file.name]))
62-
.then(data => data.result.content[0].others)
62+
.then((data) => data.result.content[0].others)
6363
.then(updateOthers)
6464
)
6565
);
@@ -73,15 +73,15 @@ async function compile(docs: CurrentFile[], flags?: string): Promise<any> {
7373
{
7474
cancellable: false,
7575
location: vscode.ProgressLocation.Notification,
76-
title: `Compiling: ${docs.length === 1 ? docs.map(el => el.name).join(", ") : docs.length + " files"}`,
76+
title: `Compiling: ${docs.length === 1 ? docs.map((el) => el.name).join(", ") : docs.length + " files"}`,
7777
},
7878
() =>
7979
api
8080
.actionCompile(
81-
docs.map(el => el.name),
81+
docs.map((el) => el.name),
8282
flags
8383
)
84-
.then(data => {
84+
.then((data) => {
8585
const info = docs.length > 1 ? "" : `${docs[0].name}: `;
8686
if (data.status && data.status.errors && data.status.errors.length) {
8787
throw new Error(`${info}Compile error`);
@@ -94,7 +94,7 @@ async function compile(docs: CurrentFile[], flags?: string): Promise<any> {
9494
outputChannel.appendLine(error.message);
9595
outputChannel.show(true);
9696
if (!config("suppressCompileErrorMessages")) {
97-
vscode.window.showErrorMessage(error.message, "Show details").then(data => {
97+
vscode.window.showErrorMessage(error.message, "Show details").then((data) => {
9898
outputChannel.show(true);
9999
});
100100
}
@@ -116,7 +116,7 @@ export async function importAndCompile(askFLags = false, document?: vscode.TextD
116116
const defaultFlags = config().compileFlags;
117117
const flags = askFLags ? await compileFlags() : defaultFlags;
118118
return importFile(file)
119-
.catch(error => {
119+
.catch((error) => {
120120
// console.error(error);
121121
throw error;
122122
})
@@ -158,12 +158,12 @@ export async function namespaceCompile(askFLags = false): Promise<any> {
158158

159159
function importFiles(files) {
160160
return Promise.all<CurrentFile>(
161-
files.map(file =>
161+
files.map((file) =>
162162
vscode.workspace
163163
.openTextDocument(file)
164164
.then(currentFile)
165-
.then(curFile =>
166-
importFile(curFile).then(data => {
165+
.then((curFile) =>
166+
importFile(curFile).then((data) => {
167167
outputChannel.appendLine("Imported file: " + curFile.fileName);
168168
return curFile;
169169
})
@@ -184,7 +184,7 @@ export async function importFolder(uri: vscode.Uri): Promise<any> {
184184
matchBase: true,
185185
nocase: true,
186186
},
187-
(error, files) => importFiles(files.map(name => path.join(folder, name)))
187+
(error, files) => importFiles(files.map((name) => path.join(folder, name)))
188188
);
189189
}
190190

src/commands/delete.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ function deleteList(items: string[], workspaceFolder: string): Promise<any> {
1515

1616
const api = new AtelierAPI();
1717
api.setConnection(workspaceFolder);
18-
return Promise.all(items.map(item => api.deleteDoc(item))).then(files => {
19-
outputChannel.appendLine(`Deleted items: ${files.filter(el => el.result).length}`);
20-
const failed = files.filter(el => !el.result).map(el => `${el.file} - ${el.error}`);
21-
if (files.find(el => !el.result)) {
18+
return Promise.all(items.map((item) => api.deleteDoc(item))).then((files) => {
19+
outputChannel.appendLine(`Deleted items: ${files.filter((el) => el.result).length}`);
20+
const failed = files.filter((el) => !el.result).map((el) => `${el.file} - ${el.error}`);
21+
if (files.find((el) => !el.result)) {
2222
outputChannel.appendLine(`Items failed to delete: \n${failed.join("\n")}`);
2323
}
2424
});
@@ -28,13 +28,13 @@ export async function deleteItem(node: RootNode | PackageNode | ClassNode | Rout
2828
const workspaceFolder = node.workspaceFolder;
2929
const nodesList = node instanceof RootNode ? node.getChildren(node) : Promise.resolve([node]);
3030
return nodesList
31-
.then(nodes =>
31+
.then((nodes) =>
3232
nodes.reduce(
3333
(list, subNode) => list.concat(subNode instanceof PackageNode ? subNode.getClasses() : [subNode.fullName]),
3434
[]
3535
)
3636
)
37-
.then(items => {
37+
.then((items) => {
3838
deleteList(items, workspaceFolder);
3939
explorerProvider.refresh();
4040
});

src/commands/export.ts

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@ const filesFilter = (file: any) => {
1313
return true;
1414
};
1515

16-
const getCategory = (fileName: string, addCategory: {} | boolean): string => {
17-
const fileExt = fileName
18-
.split(".")
19-
.pop()
20-
.toLowerCase();
16+
const getCategory = (fileName: string, addCategory: any | boolean): string => {
17+
const fileExt = fileName.split(".").pop().toLowerCase();
2118
if (typeof addCategory === "object") {
2219
for (const pattern of Object.keys(addCategory)) {
2320
if (new RegExp(`^${pattern}$`).test(fileName)) {
@@ -61,11 +58,11 @@ export async function exportFile(
6158
}
6259
const api = new AtelierAPI(workspaceFolder);
6360
api.setNamespace(namespace);
64-
const log = status => outputChannel.appendLine(`export "${name}" as "${fileName}" - ${status}`);
61+
const log = (status) => outputChannel.appendLine(`export "${name}" as "${fileName}" - ${status}`);
6562
const folders = path.dirname(fileName);
6663
return mkdirSyncRecursive(folders)
6764
.then(() => {
68-
return api.getDoc(name).then(data => {
65+
return api.getDoc(name).then((data) => {
6966
if (!data || !data.result) {
7067
throw new Error("Something wrong happened");
7168
}
@@ -75,7 +72,7 @@ export async function exportFile(
7572
const promise = new Promise((resolve, reject) => {
7673
if (noStorage) {
7774
// get only the storage xml for the doc.
78-
api.getDoc(name + "?storageOnly=1").then(storageData => {
75+
api.getDoc(name + "?storageOnly=1").then((storageData) => {
7976
if (!storageData || !storageData.result) {
8077
reject(new Error("Something wrong happened fetching the storage data"));
8178
}
@@ -122,12 +119,12 @@ export async function exportFile(
122119

123120
log(`Success ${isSkipped}`);
124121
})
125-
.catch(error => {
122+
.catch((error) => {
126123
throw error;
127124
});
128125
});
129126
})
130-
.catch(error => {
127+
.catch((error) => {
131128
log("ERROR: " + error);
132129
throw error;
133130
});
@@ -140,12 +137,14 @@ export async function exportList(files: string[], workspaceFolder: string, names
140137
const { atelier, folder, addCategory } = config("export", workspaceFolder);
141138

142139
const root = [workspaceFolderUri(workspaceFolder).fsPath, folder].join(path.sep);
143-
const run = async fileList => {
140+
const run = async (fileList) => {
144141
const errors = [];
145142
for (const file of fileList) {
146-
await exportFile(workspaceFolder, namespace, file, getFileName(root, file, atelier, addCategory)).catch(error => {
147-
errors.push(`${file} - ${error}`);
148-
});
143+
await exportFile(workspaceFolder, namespace, file, getFileName(root, file, atelier, addCategory)).catch(
144+
(error) => {
145+
errors.push(`${file} - ${error}`);
146+
}
147+
);
149148
}
150149
outputChannel.appendLine(`Exported items: ${fileList.length - errors.length}`);
151150
if (errors.length) {
@@ -166,10 +165,10 @@ export async function exportList(files: string[], workspaceFolder: string, names
166165
export async function exportAll(workspaceFolder?: string): Promise<any> {
167166
if (!workspaceFolder) {
168167
const list = vscode.workspace.workspaceFolders
169-
.filter(folder => config("conn", folder.name).active)
170-
.map(el => el.name);
168+
.filter((folder) => config("conn", folder.name).active)
169+
.map((el) => el.name);
171170
if (list.length > 1) {
172-
return vscode.window.showQuickPick(list).then(folder => (folder ? exportAll : null));
171+
return vscode.window.showQuickPick(list).then((folder) => (folder ? exportAll : null));
173172
} else {
174173
workspaceFolder = list.pop();
175174
}
@@ -180,8 +179,8 @@ export async function exportAll(workspaceFolder?: string): Promise<any> {
180179
const api = new AtelierAPI(workspaceFolder);
181180
outputChannel.show(true);
182181
const { category, generated, filter, ns } = config("export", workspaceFolder);
183-
const files = data => data.result.content.filter(filesFilter).map(file => file.name);
184-
return api.getDocNames({ category, generated, filter }).then(data => {
182+
const files = (data) => data.result.content.filter(filesFilter).map((file) => file.name);
183+
return api.getDocNames({ category, generated, filter }).then((data) => {
185184
return exportList(files(data), workspaceFolder, ns);
186185
});
187186
}
@@ -204,7 +203,7 @@ Would you like to continue?`,
204203
}
205204
}
206205
const { workspaceFolder, namespace } = node;
207-
return Promise.all(nodes.map(node => node.getItems4Export())).then(items => {
206+
return Promise.all(nodes.map((node) => node.getItems4Export())).then((items) => {
208207
return exportList(items.flat(), workspaceFolder, namespace);
209208
});
210209
}

src/commands/serverActions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export async function serverActions(): Promise<void> {
7575
placeHolder: `Select action for server: ${connInfo}`,
7676
}
7777
)
78-
.then(action => {
78+
.then((action) => {
7979
if (!action) {
8080
return;
8181
}

0 commit comments

Comments
 (0)