mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-22 18:29:26 +00:00
chore: lint
This commit is contained in:
parent
43edba8cb8
commit
cc889bda4f
48 changed files with 64 additions and 62 deletions
1
.github/workflows/nodejs.yml
vendored
1
.github/workflows/nodejs.yml
vendored
|
|
@ -9,7 +9,6 @@ jobs:
|
|||
strategy:
|
||||
matrix:
|
||||
node-version:
|
||||
- 20.x
|
||||
- 22.x
|
||||
- 24.x
|
||||
- 25.x
|
||||
|
|
|
|||
|
|
@ -46,6 +46,9 @@
|
|||
},
|
||||
"vim.js": {
|
||||
"merge-duplicate-functions": "off"
|
||||
},
|
||||
"common": {
|
||||
"nodejs/declare": "off"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ const devtool = isDev ? 'eval' : 'source-map';
|
|||
const notEmpty = (a) => a;
|
||||
const clean = (array) => array.filter(notEmpty);
|
||||
|
||||
const noParse = (a) => /\.spec\.js$/.test(a);
|
||||
const noParse = (a) => a.endsWith('.spec.js');
|
||||
const options = {
|
||||
babelrc: true,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
import process from 'node:process';
|
||||
import {createRequire} from 'node:module';
|
||||
import {promisify} from 'node:util';
|
||||
import tryToCatch from 'try-to-catch';
|
||||
import {tryToCatch} from 'try-to-catch';
|
||||
import {createSimport} from 'simport';
|
||||
import parse from 'yargs-parser';
|
||||
import exit from '../server/exit.js';
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import {promisify} from 'node:util';
|
||||
import process from 'node:process';
|
||||
import tryToCatch from 'try-to-catch';
|
||||
import {tryToCatch} from 'try-to-catch';
|
||||
import {createSimport} from 'simport';
|
||||
import minor from 'minor';
|
||||
import _place from 'place';
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ const Emitify = require('emitify');
|
|||
const inherits = require('inherits');
|
||||
const rendy = require('rendy');
|
||||
const load = require('load.js');
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const {tryToCatch} = require('try-to-catch');
|
||||
const {addSlashToEnd} = require('format-io');
|
||||
const pascalCase = require('just-pascal-case');
|
||||
const currify = require('currify');
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ module.exports.isCurrentIsDir = (currentFile) => {
|
|||
const path = DOM.getCurrentPath(current);
|
||||
const fileType = DOM.getCurrentType(current);
|
||||
|
||||
const isZip = /\.zip$/.test(path);
|
||||
const isZip = path.endsWith('.zip');
|
||||
const isDir = /^directory(-link)?/.test(fileType);
|
||||
|
||||
return isDir || isZip;
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ function getDOM(overrides = {}) {
|
|||
getByDataName = stub(),
|
||||
isContainClass = stub(),
|
||||
getCurrentType = stub(),
|
||||
getCurrentPath = stub(),
|
||||
getCurrentPath = stub().returns(''),
|
||||
} = overrides;
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const {tryToCatch} = require('try-to-catch');
|
||||
|
||||
const {
|
||||
alert,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
const test = require('supertape');
|
||||
const {create} = require('auto-globals');
|
||||
const tryCatch = require('try-catch');
|
||||
const {tryCatch} = require('try-catch');
|
||||
|
||||
const {isContainClass} = require('./dom-tree');
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
const rendy = require('rendy');
|
||||
const itype = require('itype');
|
||||
const load = require('load.js');
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const {tryToCatch} = require('try-to-catch');
|
||||
|
||||
const {findObjByNameInArr} = require('../../common/util');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const {tryToCatch} = require('try-to-catch');
|
||||
|
||||
const {encode} = require('../../common/entity');
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
const exec = require('execon');
|
||||
const itype = require('itype');
|
||||
const currify = require('currify');
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const {tryToCatch} = require('try-to-catch');
|
||||
const clipboard = require('@cloudcmd/clipboard');
|
||||
|
||||
const getRange = require('./get-range');
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
/* global CloudCmd */
|
||||
const exec = require('execon');
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const {tryToCatch} = require('try-to-catch');
|
||||
const loadJS = require('load.js').js;
|
||||
|
||||
const pascalCase = require('just-pascal-case');
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ const currify = require('currify');
|
|||
const wraptile = require('wraptile');
|
||||
const squad = require('squad');
|
||||
const {promisify} = require('es6-promisify');
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const {tryToCatch} = require('try-to-catch');
|
||||
const load = require('load.js');
|
||||
const createElement = require('@cloudcmd/create-element');
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
const montag = require('montag');
|
||||
|
||||
const {promisify} = require('es6-promisify');
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const {tryToCatch} = require('try-to-catch');
|
||||
const createElement = require('@cloudcmd/create-element');
|
||||
const load = require('load.js');
|
||||
const {MAX_FILE_SIZE: maxSize} = require('../../common/cloudfunc');
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ CloudCmd.Konsole = exports;
|
|||
|
||||
const exec = require('execon');
|
||||
const currify = require('currify');
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const {tryToCatch} = require('try-to-catch');
|
||||
const loadJS = require('load.js').js;
|
||||
const createElement = require('@cloudcmd/create-element');
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ const wraptile = require('wraptile');
|
|||
const {promisify} = require('es6-promisify');
|
||||
const exec = require('execon');
|
||||
const load = require('load.js');
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const {tryToCatch} = require('try-to-catch');
|
||||
|
||||
const {encode} = require('../../../common/entity');
|
||||
const removeExtension = require('./remove-extension');
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ module.exports = (name) => {
|
|||
};
|
||||
|
||||
function getExtension(name) {
|
||||
if (/\.tar\.gz$/.test(name))
|
||||
if (name.endsWith('.tar.gz'))
|
||||
return '.tar.gz';
|
||||
|
||||
if (/\.tar\.bz2$/.test(name))
|
||||
if (name.endsWith('.tar.bz2'))
|
||||
return '.tar.bz2';
|
||||
|
||||
return getExt(name);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
/* global CloudCmd, gritty */
|
||||
const {promisify} = require('es6-promisify');
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const {tryToCatch} = require('try-to-catch');
|
||||
const fullstore = require('fullstore');
|
||||
|
||||
require('../../css/terminal.css');
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
/* global CloudCmd */
|
||||
/* global gritty */
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const {tryToCatch} = require('try-to-catch');
|
||||
|
||||
require('../../css/terminal.css');
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ const wraptile = require('wraptile');
|
|||
const fullstore = require('fullstore');
|
||||
const load = require('load.js');
|
||||
const createElement = require('@cloudcmd/create-element');
|
||||
const tryCatch = require('try-catch');
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const {tryCatch} = require('try-catch');
|
||||
const {tryToCatch} = require('try-to-catch');
|
||||
const {codeFrameColumns} = require('@babel/code-frame');
|
||||
|
||||
const Images = require('../../dom/images');
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ const testRegExp = currify((name, reg) => reg.test(name));
|
|||
const getRegExp = (ext) => RegExp(`\\.${ext}$`, 'i');
|
||||
|
||||
const isPDF = (a) => /\.pdf$/i.test(a);
|
||||
const isHTML = (a) => /\.html$/.test(a);
|
||||
const isHTML = (a) => a.endsWith('.html');
|
||||
const isMarkdown = (a) => /.\.md$/.test(a);
|
||||
|
||||
module.exports = (name) => {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ require('../../../css/view.css');
|
|||
const rendy = require('rendy');
|
||||
const currify = require('currify');
|
||||
const wraptile = require('wraptile');
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const {tryToCatch} = require('try-to-catch');
|
||||
const load = require('load.js');
|
||||
|
||||
const modal = require('@cloudcmd/modal');
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ const testRegExp = currify((name, reg) => reg.test(name));
|
|||
const getRegExp = (ext) => RegExp(`\\.${ext}$`, 'i');
|
||||
|
||||
const isPDF = (a) => /\.pdf$/i.test(a);
|
||||
const isHTML = (a) => /\.html$/.test(a);
|
||||
const isHTML = (a) => a.endsWith('.html');
|
||||
const isMarkdown = (a) => /.\.md$/.test(a);
|
||||
|
||||
module.exports.getType = async (path) => {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const {tryToCatch} = require('try-to-catch');
|
||||
|
||||
module.exports.registerSW = registerSW;
|
||||
module.exports.unregisterSW = unregisterSW;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ const tape = require('supertape');
|
|||
|
||||
const stub = require('@cloudcmd/stub');
|
||||
|
||||
const tryCatch = require('try-catch');
|
||||
const {tryCatch} = require('try-catch');
|
||||
const {reRequire} = require('mock-require');
|
||||
const test = autoGlobals(tape);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
const process = require('node:process');
|
||||
const codegen = require('codegen.macro');
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const {tryToCatch} = require('try-to-catch');
|
||||
const currify = require('currify');
|
||||
|
||||
const isDev = process.env.NODE_ENV === 'development';
|
||||
|
|
|
|||
|
|
@ -1,20 +1,19 @@
|
|||
'use strict';
|
||||
|
||||
const {test, stub} = require('supertape');
|
||||
|
||||
const {btoa, atob} = require('./base64');
|
||||
|
||||
test('btoa: browser', (t) => {
|
||||
const btoaOriginal = global.btoa;
|
||||
const btoaOriginal = globalThis.btoa;
|
||||
const btoaStub = stub();
|
||||
const str = 'hello';
|
||||
|
||||
global.btoa = btoaStub;
|
||||
globalThis.btoa = btoaStub;
|
||||
|
||||
btoa(str);
|
||||
global.btoa = btoaOriginal;
|
||||
globalThis.btoa = btoaOriginal;
|
||||
|
||||
t.calledWith(btoaStub, [str], 'should call global.btoa');
|
||||
t.calledWith(btoaStub, [str], 'should call globalThis.btoa');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
@ -29,18 +28,18 @@ test('btoa: node', (t) => {
|
|||
});
|
||||
|
||||
test('atob: browser', (t) => {
|
||||
const atobOriginal = global.atob;
|
||||
const atobOriginal = globalThis.atob;
|
||||
const atobStub = stub();
|
||||
|
||||
const str = 'hello';
|
||||
|
||||
global.atob = atobStub;
|
||||
globalThis.atob = atobStub;
|
||||
|
||||
atob(str);
|
||||
|
||||
global.atob = atobOriginal;
|
||||
globalThis.atob = atobOriginal;
|
||||
|
||||
t.calledWith(atobStub, [str], 'should call global.btoa');
|
||||
t.calledWith(atobStub, [str], 'should call globalThis.btoa');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const {promisify} = require('node:util');
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const {tryToCatch} = require('try-to-catch');
|
||||
|
||||
const {test, stub} = require('supertape');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const test = require('supertape');
|
||||
const tryCatch = require('try-catch');
|
||||
const {tryCatch} = require('try-catch');
|
||||
|
||||
const datetime = require('./datetime');
|
||||
|
||||
|
|
@ -16,11 +16,11 @@ test('common: datetime', (t) => {
|
|||
});
|
||||
|
||||
test('common: datetime: no arg', (t) => {
|
||||
const {Date} = global;
|
||||
const {Date} = globalThis;
|
||||
|
||||
let called = false;
|
||||
|
||||
global.Date = class extends Date {
|
||||
globalThis.Date = class extends Date {
|
||||
constructor() {
|
||||
super();
|
||||
called = true;
|
||||
|
|
@ -29,7 +29,7 @@ test('common: datetime: no arg', (t) => {
|
|||
|
||||
datetime();
|
||||
|
||||
global.Date = Date;
|
||||
globalThis.Date = Date;
|
||||
|
||||
t.ok(called, 'should call new Date');
|
||||
t.end();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const {tryToCatch} = require('try-to-catch');
|
||||
const all = Promise.all.bind(Promise);
|
||||
|
||||
module.exports = async (a) => {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
const test = require('supertape');
|
||||
const {reRequire} = require('mock-require');
|
||||
const tryCatch = require('try-catch');
|
||||
const {tryCatch} = require('try-catch');
|
||||
const Util = require('./util');
|
||||
|
||||
const {
|
||||
|
|
@ -119,13 +119,13 @@ test('util: escapeRegExp', (t) => {
|
|||
});
|
||||
|
||||
test('util: scope', (t) => {
|
||||
global.window = {};
|
||||
globalThis.window = {};
|
||||
|
||||
reRequire('./util');
|
||||
|
||||
t.pass('should set window in scope');
|
||||
|
||||
delete global.window;
|
||||
delete globalThis.window;
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@ const {homedir} = require('node:os');
|
|||
const currify = require('currify');
|
||||
|
||||
const wraptile = require('wraptile');
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const {tryToCatch} = require('try-to-catch');
|
||||
const pullout = require('pullout');
|
||||
const ponse = require('ponse');
|
||||
const jonny = require('jonny');
|
||||
const jju = require('jju');
|
||||
const writejson = require('writejson');
|
||||
const tryCatch = require('try-catch');
|
||||
const {tryCatch} = require('try-catch');
|
||||
const criton = require('criton');
|
||||
const exit = require(`${DIR_SERVER}exit`);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import process from 'node:process';
|
||||
import {promisify} from 'node:util';
|
||||
import test from 'supertape';
|
||||
import tryToCatch from 'try-to-catch';
|
||||
import {tryToCatch} from 'try-to-catch';
|
||||
import {connect} from '../../test/before.mjs';
|
||||
import {createConfigManager} from '../cloudcmd.mjs';
|
||||
import {distributeImport} from './import.mjs';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import fs from 'node:fs';
|
||||
import {join} from 'node:path';
|
||||
import {promisify} from 'node:util';
|
||||
import tryToCatch from 'try-to-catch';
|
||||
import {tryToCatch} from 'try-to-catch';
|
||||
import test from 'supertape';
|
||||
import serveOnce from 'serve-once';
|
||||
import markdown from './index.js';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const test = require('supertape');
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const {tryToCatch} = require('try-to-catch');
|
||||
|
||||
const {
|
||||
_formatMsg,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import rendy from 'rendy';
|
|||
import format from 'format-io';
|
||||
import currify from 'currify';
|
||||
import wraptile from 'wraptile';
|
||||
import tryToCatch from 'try-to-catch';
|
||||
import {tryToCatch} from 'try-to-catch';
|
||||
import once from 'once';
|
||||
import pipe from 'pipe-io';
|
||||
import {contentType} from 'mime-types';
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import path, {dirname} from 'node:path';
|
|||
import {fileURLToPath} from 'node:url';
|
||||
import {Readable} from 'node:stream';
|
||||
import fs from 'node:fs';
|
||||
import tryToCatch from 'try-to-catch';
|
||||
import {tryToCatch} from 'try-to-catch';
|
||||
import {test, stub} from 'supertape';
|
||||
import serveOnce from 'serve-once';
|
||||
import cloudcmd from './cloudcmd.mjs';
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import {promisify} from 'node:util';
|
|||
import process from 'node:process';
|
||||
import currify from 'currify';
|
||||
import squad from 'squad';
|
||||
import tryToCatch from 'try-to-catch';
|
||||
import {tryToCatch} from 'try-to-catch';
|
||||
import opn from 'open';
|
||||
import express from 'express';
|
||||
import {Server} from 'socket.io';
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const tryCatch = require('try-catch');
|
||||
const {tryCatch} = require('try-catch');
|
||||
|
||||
const noop = (req, res, next) => {
|
||||
next && next();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import {homedir} from 'node:os';
|
|||
import {readFile as _readFile} from 'node:fs/promises';
|
||||
import {join} from 'node:path';
|
||||
import montag from 'montag';
|
||||
import tryToCatch from 'try-to-catch';
|
||||
import {tryToCatch} from 'try-to-catch';
|
||||
import currify from 'currify';
|
||||
import {putout, codeframe} from 'putout';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import {statSync as _statSync} from 'node:fs';
|
||||
import tryCatch from 'try-catch';
|
||||
import {tryCatch} from 'try-catch';
|
||||
import _exit from './exit.js';
|
||||
import {getColumns as _getColumns} from './columns.mjs';
|
||||
import {getThemes as _getThemes} from './theme.mjs';
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import {test, stub} from 'supertape';
|
||||
import tryCatch from 'try-catch';
|
||||
import {tryCatch} from 'try-catch';
|
||||
import * as validate from './validate.mjs';
|
||||
import cloudcmd from './cloudcmd.mjs';
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
const autoGlobals = require('auto-globals');
|
||||
const stub = require('@cloudcmd/stub');
|
||||
const tryToCatch = require('try-to-catch');
|
||||
const {tryToCatch} = require('try-to-catch');
|
||||
const wraptile = require('wraptile');
|
||||
const defaultMenu = require('./user-menu');
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
const fs = require('node:fs');
|
||||
|
||||
const tryCatch = require('try-catch');
|
||||
const {tryCatch} = require('try-catch');
|
||||
const test = require('supertape');
|
||||
const readFilesSync = require('@cloudcmd/read-files-sync');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const test = require('supertape');
|
||||
const tryCatch = require('try-catch');
|
||||
const {tryCatch} = require('try-catch');
|
||||
|
||||
const showConfig = require('../../server/show-config');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import {Buffer} from 'node:buffer';
|
||||
import serveOnce from 'serve-once';
|
||||
import test from 'supertape';
|
||||
import criton from 'criton';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue