Skip to content

Commit e6b8984

Browse files
committed
fixed more linting errors (3)
1 parent 9e8a456 commit e6b8984

File tree

17 files changed

+95
-90
lines changed

17 files changed

+95
-90
lines changed

src/fileSystem/externalFs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const externalFs = {
1212
},
1313

1414
async writeFile(filename, data) {
15-
return new Promise(async (resolve, reject) => {
15+
return new Promise((resolve, reject) => {
1616
sdcard.write(filename, data, resolve, reject);
1717
});
1818
},

src/fileSystem/ftp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ class FtpClient {
315315
get #cacheFile() {
316316
return Url.join(
317317
CACHE_STORAGE,
318-
"ftp" + Url.join(this.#origin, this.#path).hashCode(),
318+
`ftp${Url.join(this.#origin, this.#path).hashCode()}`,
319319
);
320320
}
321321

src/fileSystem/sftp.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class SftpClient {
3232
this.#hostname = hostname;
3333
this.#port = port;
3434
this.#username = username;
35-
this.#authenticationType = !!authentication.keyFile ? "key" : "password";
35+
this.#authenticationType = authentication.keyFile ? "key" : "password";
3636
this.#keyFile = authentication.keyFile;
3737
this.#passPhrase = authentication.passPhrase;
3838
this.#password = authentication.password;
@@ -78,13 +78,13 @@ class SftpClient {
7878
sftp.lsDir(
7979
path,
8080
(res) => {
81-
res.forEach((file) => {
81+
for (const file of res) {
8282
file.url = Url.join(this.#base, file.url);
8383
file.type = mimeType.lookup(filename);
8484
if (file.isLink) {
8585
file.linkTarget = Url.join(this.#base, file.linkTarget);
8686
}
87-
});
87+
}
8888
resolve(res);
8989
},
9090
(err) => {
@@ -357,8 +357,8 @@ class SftpClient {
357357
await this.#setStat();
358358
sftp.rm(
359359
this.#safeName(filename),
360-
this.#stat.isDirectory ? true : false,
361-
this.#stat.isDirectory ? true : false,
360+
this.#stat.isDirectory,
361+
this.#stat.isDirectory,
362362
(_res) => {
363363
resolve(fullFilename);
364364
},
@@ -565,7 +565,7 @@ class SftpClient {
565565
#getLocalname(filename) {
566566
return Url.join(
567567
CACHE_STORAGE,
568-
"sftp" + Url.join(this.#base, filename).hashCode(),
568+
`sftp${Url.join(this.#base, filename).hashCode()}`,
569569
);
570570
}
571571

src/handlers/keyboard.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ keyboardHandler.off = (eventName, callback) => {
154154
*/
155155
function emit(eventName) {
156156
if (!event[eventName]) return;
157-
event[eventName].forEach((cb) => cb());
157+
for (const cb of event[eventName]) {
158+
cb();
159+
}
158160
}
159161

160162
/**

src/handlers/quickTools.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export default function actions(action, value) {
120120
setInput();
121121
value = !state[action];
122122
state[action] = value;
123-
events[action].forEach((cb) => cb(value));
123+
for (const cb of events[action]) cb(value);
124124
if (Object.values(state).includes(true)) {
125125
$input.focus();
126126
} else if (input) {
@@ -351,9 +351,11 @@ function updateSearchState() {
351351
if (regex) {
352352
const value = editor.getValue();
353353
const offset = editor.session.doc.positionToIndex(editor.selection.anchor);
354-
let last = (regex.lastIndex = 0);
354+
regex.lastIndex = 0;
355+
let last = 0;
355356
let m;
356-
while ((m = regex.exec(value))) {
357+
m = regex.exec(value);
358+
while (m) {
357359
all++;
358360
last = m.index;
359361
if (last <= offset) before++;
@@ -362,6 +364,7 @@ function updateSearchState() {
362364
regex.lastIndex = last += 1;
363365
if (last >= value.length) break;
364366
}
367+
m = regex.exec(value);
365368
}
366369
}
367370
$searchTotal.textContent = all > MAX_COUNT ? "999+" : all;
@@ -402,13 +405,13 @@ function focusEditor() {
402405

403406
function resetKeys() {
404407
state.shift = false;
405-
events.shift.forEach((cb) => cb(false));
408+
for (const cb of events.shift) cb(false);
406409
state.alt = false;
407-
events.alt.forEach((cb) => cb(false));
410+
for (const cb of events.alt) cb(false);
408411
state.ctrl = false;
409-
events.ctrl.forEach((cb) => cb(false));
412+
for (const cb of events.ctrl) cb(false);
410413
state.meta = false;
411-
events.meta.forEach((cb) => cb(false));
414+
for (const cb of events.meta) cb(false);
412415
input.focus();
413416
}
414417

src/handlers/windowResize.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,7 @@ function onResize() {
7070
*/
7171
function emit(eventName) {
7272
if (!event[eventName]) return;
73-
event[eventName].forEach((cb) => cb());
73+
for (const cb of event[eventName]) {
74+
cb();
75+
}
7476
}

src/palettes/commandPalette/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default async function commandPalette() {
1515
function generateHints() {
1616
const hints = [];
1717

18-
commands.forEach(({ name, description, bindKey }) => {
18+
for (const { name, description, bindKey } of commands) {
1919
/**
2020
* @param {boolean} recentlyUsed Is the command recently used
2121
* @returns {{value: string, text: string}}
@@ -26,10 +26,10 @@ export default async function commandPalette() {
2626
});
2727
if (recentCommands.commands.includes(name)) {
2828
hints.unshift(item(true));
29-
return;
29+
continue;
3030
}
3131
hints.push(item());
32-
});
32+
}
3333

3434
return hints;
3535
}

src/palettes/findFile/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default async function findFile() {
2828
hintsModification = hints;
2929
const list = [];
3030

31-
editorManager.files.forEach((file) => {
31+
for (const file of editorManager.files) {
3232
const { uri, name } = file;
3333
let { location = "" } = file;
3434

@@ -37,7 +37,7 @@ export default async function findFile() {
3737
}
3838

3939
list.push(hintItem(name, location, uri));
40-
});
40+
}
4141

4242
list.push(...files(hintItem));
4343
return list;

src/settings/backupRestore.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import Url from "utils/Url";
1010
import helpers from "utils/helpers";
1111

1212
function backupRestore() {
13-
const title =
14-
strings.backup.capitalize() + "/" + strings.restore.capitalize();
13+
const title = `${strings.backup.capitalize()}/${strings.restore.capitalize()}`;
1514
const items = [
1615
{
1716
key: "backup",

src/settings/mainSettings.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default function mainSettings() {
6262
},
6363
{
6464
key: "backup-restore",
65-
text: strings.backup.capitalize() + "/" + strings.restore.capitalize(),
65+
text: `${strings.backup.capitalize()}/${strings.restore.capitalize()}`,
6666
icon: "cached",
6767
},
6868
{
@@ -72,7 +72,7 @@ export default function mainSettings() {
7272
},
7373
{
7474
key: "plugins",
75-
text: strings["plugins"],
75+
text: strings.plugins,
7676
icon: "extension",
7777
},
7878
{
@@ -89,12 +89,12 @@ export default function mainSettings() {
8989
},
9090
{
9191
key: "editSettings",
92-
text: `${strings["edit"]} settings.json`,
92+
text: `${strings.edit} settings.json`,
9393
icon: "edit",
9494
},
9595
{
9696
key: "changeLog",
97-
text: `${strings["changelog"]}`,
97+
text: `${strings.changelog}`,
9898
icon: "update",
9999
},
100100
];
@@ -151,7 +151,7 @@ export default function mainSettings() {
151151
break;
152152
}
153153

154-
case "reset":
154+
case "reset": {
155155
const confirmation = await confirm(
156156
strings.warning,
157157
strings["restore default settings"],
@@ -161,6 +161,7 @@ export default function mainSettings() {
161161
location.reload();
162162
}
163163
break;
164+
}
164165

165166
case "removeads":
166167
try {

0 commit comments

Comments
 (0)