Skip to content

Commit d8da792

Browse files
committed
chore: client: lint
1 parent 2fc503f commit d8da792

File tree

12 files changed

+71
-101
lines changed

12 files changed

+71
-101
lines changed

client/dom/current-file.spec.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,10 @@ test('current-file: isCurrentIsDir: file', (t) => {
261261
t.end();
262262
});
263263

264-
function getCloudCmd({emit} = {}) {
265-
return {
266-
prefix: '',
267-
emit: emit || stub(),
268-
};
269-
}
264+
const getCloudCmd = ({emit} = {}) => ({
265+
prefix: '',
266+
emit: emit || stub(),
267+
});
270268

271269
test('current-file: parseNameAttribute', (t) => {
272270
const result = currentFile._parseNameAttribute('js-file-aGVsbG8mbmJzcDt3b3JsZA==');

client/dom/directory.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,8 @@ module.exports = (items) => {
6363
uploader.on('end', CloudCmd.refresh);
6464
};
6565

66-
function percent(i, n, per = 100) {
67-
return Math.round(i * per / n);
68-
}
66+
const percent = (i, n, per = 100) => Math.round(i * per / n);
6967

70-
function uploadFile(url, data) {
71-
return DOM.load.put(url, data);
72-
}
68+
const uploadFile = (url, data) => DOM.load.put(url, data);
7369

74-
function uploadDir(url) {
75-
return DOM.load.put(`${url}?dir`);
76-
}
70+
const uploadDir = (url) => DOM.load.put(`${url}?dir`);

client/dom/images.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ const LOADING = 'loading';
1010
const HIDDEN = 'hidden';
1111
const ERROR = 'error';
1212

13-
function getLoadingType() {
14-
return isSVG() ? '-svg' : '-gif';
15-
}
13+
const getLoadingType = () => isSVG() ? '-svg' : '-gif';
1614

1715
module.exports.get = getElement;
1816
/**

client/dom/load-remote.js

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,40 @@ module.exports = (name, options, callback = options) => {
1717
if (o.name && window[o.name])
1818
return callback();
1919

20-
Files
21-
.get('modules')
22-
.then(async (modules) => {
23-
const online = config('online') && navigator.onLine;
24-
const module = findObjByNameInArr(modules.remote, name);
25-
26-
const isArray = itype.array(module.local);
27-
const {version} = module;
28-
29-
let remoteTmpls;
30-
let local;
31-
32-
if (isArray) {
33-
remoteTmpls = module.remote;
34-
local = module.local;
35-
} else {
36-
remoteTmpls = [module.remote];
37-
local = [module.local];
38-
}
39-
40-
const localURL = local.map((url) => prefix + url);
41-
42-
const remoteURL = remoteTmpls.map((tmpl) => {
43-
return rendy(tmpl, {
44-
version,
45-
});
20+
Files.get('modules').then(async (modules) => {
21+
const online = config('online') && navigator.onLine;
22+
const module = findObjByNameInArr(modules.remote, name);
23+
24+
const isArray = itype.array(module.local);
25+
const {version} = module;
26+
27+
let remoteTmpls;
28+
let local;
29+
30+
if (isArray) {
31+
remoteTmpls = module.remote;
32+
local = module.local;
33+
} else {
34+
remoteTmpls = [module.remote];
35+
local = [module.local];
36+
}
37+
38+
const localURL = local.map((url) => prefix + url);
39+
40+
const remoteURL = remoteTmpls.map((tmpl) => {
41+
return rendy(tmpl, {
42+
version,
4643
});
47-
48-
if (online) {
49-
const [e] = await tryToCatch(load.parallel, remoteURL);
50-
51-
if (!e)
52-
return callback();
53-
}
54-
55-
const [e] = await tryToCatch(load.parallel, localURL);
56-
callback(e);
5744
});
45+
46+
if (online) {
47+
const [e] = await tryToCatch(load.parallel, remoteURL);
48+
49+
if (!e)
50+
return callback();
51+
}
52+
53+
const [e] = await tryToCatch(load.parallel, localURL);
54+
callback(e);
55+
});
5856
};

client/modules/edit.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const load = require('load.js');
1111
const {MAX_FILE_SIZE: maxSize} = require('../../common/cloudfunc');
1212

1313
const {time, timeEnd} = require('../../common/util');
14+
const getEditor = () => editor;
1415
const isFn = (a) => typeof a === 'function';
1516
const loadJS = load.js;
1617

@@ -91,10 +92,6 @@ module.exports.show = (options) => {
9192

9293
module.exports.getEditor = getEditor;
9394

94-
function getEditor() {
95-
return editor;
96-
}
97-
9895
module.exports.getElement = () => Element;
9996

10097
module.exports.hide = () => {

client/modules/konsole.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,18 @@ module.exports.clear = () => {
4646
konsole.clear();
4747
};
4848

49-
function getPrefix() {
50-
return CloudCmd.prefix + '/console';
51-
}
49+
const getPrefix = () => CloudCmd.prefix + '/console';
5250

5351
function getPrefixSocket() {
5452
return CloudCmd.prefixSocket + '/console';
5553
}
5654

57-
function getEnv() {
58-
return {
59-
ACTIVE_DIR: DOM.getCurrentDirPath.bind(DOM),
60-
PASSIVE_DIR: DOM.getNotCurrentDirPath.bind(DOM),
61-
CURRENT_NAME: DOM.getCurrentName.bind(DOM),
62-
CURRENT_PATH: () => Info.path,
63-
};
64-
}
55+
const getEnv = () => ({
56+
ACTIVE_DIR: DOM.getCurrentDirPath.bind(DOM),
57+
PASSIVE_DIR: DOM.getNotCurrentDirPath.bind(DOM),
58+
CURRENT_NAME: DOM.getCurrentName.bind(DOM),
59+
CURRENT_PATH: () => Info.path,
60+
});
6561

6662
async function onPath(path) {
6763
if (Info.dirPath === path)

client/modules/menu.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,7 @@ function beforeShow(callback, params) {
226226
return isShow;
227227
}
228228

229-
function beforeClick(name) {
230-
return MenuShowedName !== name;
231-
}
229+
const beforeClick = (name) => MenuShowedName !== name;
232230

233231
async function _uploadTo(nameModule) {
234232
const [error, data] = await Info.getData();

client/modules/terminal-run.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,18 @@ function hide() {
7575
CloudCmd.View.hide();
7676
}
7777

78-
function getPrefix() {
79-
return CloudCmd.prefix + '/gritty';
80-
}
78+
const getPrefix = () => CloudCmd.prefix + '/gritty';
8179

8280
function getPrefixSocket() {
8381
return CloudCmd.prefixSocket + '/gritty';
8482
}
8583

86-
function getEnv() {
87-
return {
88-
ACTIVE_DIR: DOM.getCurrentDirPath,
89-
PASSIVE_DIR: DOM.getNotCurrentDirPath,
90-
CURRENT_NAME: DOM.getCurrentName,
91-
CURRENT_PATH: DOM.getCurrentPath,
92-
};
93-
}
84+
const getEnv = () => ({
85+
ACTIVE_DIR: DOM.getCurrentDirPath,
86+
PASSIVE_DIR: DOM.getNotCurrentDirPath,
87+
CURRENT_NAME: DOM.getCurrentName,
88+
CURRENT_PATH: DOM.getCurrentPath,
89+
});
9490

9591
function create(createOptions) {
9692
const {

client/modules/terminal.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,18 @@ function hide() {
5757
CloudCmd.View.hide();
5858
}
5959

60-
function getPrefix() {
61-
return CloudCmd.prefix + '/gritty';
62-
}
60+
const getPrefix = () => CloudCmd.prefix + '/gritty';
6361

6462
function getPrefixSocket() {
6563
return CloudCmd.prefixSocket + '/gritty';
6664
}
6765

68-
function getEnv() {
69-
return {
70-
ACTIVE_DIR: DOM.getCurrentDirPath,
71-
PASSIVE_DIR: DOM.getNotCurrentDirPath,
72-
CURRENT_NAME: DOM.getCurrentName,
73-
CURRENT_PATH: DOM.getCurrentPath,
74-
};
75-
}
66+
const getEnv = () => ({
67+
ACTIVE_DIR: DOM.getCurrentDirPath,
68+
PASSIVE_DIR: DOM.getNotCurrentDirPath,
69+
CURRENT_NAME: DOM.getCurrentName,
70+
CURRENT_PATH: DOM.getCurrentPath,
71+
});
7672

7773
function create() {
7874
const options = {

client/modules/view/get-type.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ function isMedia(name) {
4545
return isAudio(name) || isVideo(name);
4646
}
4747

48-
function isAudio(name) {
49-
return /\.(mp3|ogg|m4a)$/i.test(name);
50-
}
48+
const isAudio = (name) => /\.(mp3|ogg|m4a)$/i.test(name);
5149

5250
function isVideo(name) {
5351
return /\.(mp4|avi|webm)$/i.test(name);

0 commit comments

Comments
 (0)