chore(cloudcmd) lint: indexOf -> includes

This commit is contained in:
coderaiser 2020-06-06 19:20:17 +03:00
parent c30bc69f5d
commit 8bb746aa0e
8 changed files with 14 additions and 26 deletions

View file

@ -1,9 +1,8 @@
/* global CloudCmd */
'use strict';
/* global CloudCmd */
const itype = require('itype');
const currify = require('currify');
const {promisify} = require('es6-promisify');
const load = require('./load');
@ -18,10 +17,7 @@ const DIR_HTML_FS = DIR_HTML + 'fs/';
const DIR_JSON = '/json/';
const timeout = getTimeoutOnce(2000);
const get = currify(getFile);
const unaryMap = (array, fn) => array.map((a) => fn(a));
module.exports.get = get;
module.exports.get = getFile;
async function getFile(name) {
const type = itype(name);
@ -31,7 +27,7 @@ async function getFile(name) {
return await getModule(name);
if (type === 'array')
return Promise.all(unaryMap(name, get));
return Promise.all(name.map(getFile));
}
function check(name) {

View file

@ -20,7 +20,7 @@ function getIdBySrc(src) {
if (!isStr)
return;
if (~src.indexOf(':'))
if (src.includes(':'))
src += '-join';
const num = src.lastIndexOf('/') + 1;
@ -81,7 +81,7 @@ module.exports.ajax = (params) => {
return exec(p.error, xhr);
const notText = p.dataType !== 'text';
const isContain = ~type.indexOf(TYPE_JSON);
const isContain = type.includes(TYPE_JSON);
let data = xhr.response;

View file

@ -71,7 +71,7 @@ function KeyProto() {
const isNumpad = /Numpad/.test(event.code);
let char = getChar(event);
let isSymbol = ~['.', '_', '-', '+', '='].indexOf(char);
let isSymbol = ['.', '_', '-', '+', '='].includes(char);
if (!isSymbol) {
isSymbol = getSymbol(shift, keyCode);

View file

@ -170,9 +170,7 @@ function getMenuData() {
'Select All Ctrl+A' : () => {
editor.selectAll();
},
'Close Esc' : () => {
hide();
},
'Close Esc' : hide,
};
}

View file

@ -195,9 +195,7 @@ function setMenu(event) {
'Select All Ctrl+A' : () => {
editor.selectAll();
},
'Close Esc' : () => {
hide();
},
'Close Esc' : hide,
};
const element = CloudCmd.Edit.getElement();

View file

@ -225,13 +225,9 @@ Operation.move = processFiles({
type: 'move',
});
Operation.delete = () => {
promptDelete();
};
Operation.delete = promptDelete;
Operation.deleteSilent = () => {
deleteSilent();
};
Operation.deleteSilent = deleteSilent;
Operation.pack = () => {
const isZip = config('packer') === 'zip';

View file

@ -355,8 +355,8 @@ function setCurrentByPosition(position) {
filesPassive,
} = Info;
const isFiles = ~files.indexOf(element);
const isFilesPassive = ~filesPassive.indexOf(element);
const isFiles = files.includes(element);
const isFilesPassive = filesPassive.includes(element);
if (!isFiles && !isFilesPassive)
return;

View file

@ -215,7 +215,7 @@ test('cloudcmd: route: not found', async (t) => {
options,
});
t.ok(~body.indexOf('ENOENT: no such file or directory'), 'should return error');
t.ok(body.includes('ENOENT: no such file or directory'), 'should return error');
t.end();
});