From ddd1722f39a2338ab826199a24d8475ce67de7ca Mon Sep 17 00:00:00 2001 From: coderiaser Date: Mon, 20 Jan 2025 18:22:07 +0200 Subject: [PATCH] chore: lint --- bin/cloudcmd.mjs | 4 ++-- common/cloudfunc.js | 14 ++++++-------- css/supports.css | 2 +- server/config.js | 8 +++++--- server/rest/index.js | 9 +++------ server/terminal.js | 4 +--- static/user-menu.spec.js | 14 ++++++-------- 7 files changed, 24 insertions(+), 31 deletions(-) diff --git a/bin/cloudcmd.mjs b/bin/cloudcmd.mjs index 0a7ec042..e6b4c1a9 100755 --- a/bin/cloudcmd.mjs +++ b/bin/cloudcmd.mjs @@ -17,11 +17,11 @@ process.on('unhandledRejection', exit); const require = createRequire(import.meta.url); const Info = require('../package.json'); - +const isUndefined = (a) => typeof a === 'undefined'; const simport = createSimport(import.meta.url); const choose = (a, b) => { - if (a === undefined) + if (isUndefined(a)) return b; return a; diff --git a/common/cloudfunc.js b/common/cloudfunc.js index c9a24c42..c906b548 100644 --- a/common/cloudfunc.js +++ b/common/cloudfunc.js @@ -248,14 +248,12 @@ module.exports.buildFromJSON = (params) => { return fileTable; }; -function updateField(file) { - return { - ...file, - date: file.date || '--.--.----', - owner: file.owner || 'root', - size: getSize(file), - }; -} +const updateField = (file) => ({ + ...file, + date: file.date || '--.--.----', + owner: file.owner || 'root', + size: getSize(file), +}); function getAttribute(type) { if (type === 'directory') diff --git a/css/supports.css b/css/supports.css index bf470c2d..ea2084d2 100644 --- a/css/supports.css +++ b/css/supports.css @@ -1,6 +1,6 @@ @supports (overflow: overlay) { .files { - overflow-y: overlay; + overflow-y: auto; } .fm-header { diff --git a/server/config.js b/server/config.js index a79e7165..3b180f09 100644 --- a/server/config.js +++ b/server/config.js @@ -22,7 +22,7 @@ const criton = require('criton'); const exit = require(`${DIR_SERVER}exit`); const CloudFunc = require(`${DIR_COMMON}cloudfunc`); - +const isUndefined = (a) => typeof a === 'undefined'; const DIR = `${DIR_SERVER}../`; const HOME = homedir(); @@ -31,7 +31,9 @@ const formatMsg = currify((a, b) => CloudFunc.formatMsg(a, b)); const {apiURL} = CloudFunc; -const key = (a) => Object.keys(a).pop(); +const key = (a) => Object + .keys(a) + .pop(); const ConfigPath = path.join(DIR, 'json/config.json'); const ConfigHome = path.join(HOME, '.cloudcmd.json'); @@ -90,7 +92,7 @@ function createConfig({configPath} = {}) { if (key === '*') return config; - if (value === undefined) + if (isUndefined(value)) return config[key]; config[key] = value; diff --git a/server/rest/index.js b/server/rest/index.js index f4cae656..c133e2dc 100644 --- a/server/rest/index.js +++ b/server/rest/index.js @@ -21,7 +21,8 @@ const root = require(`../root`); const CloudFunc = require(`../../common/cloudfunc`); const markdown = require(`../markdown/index.js`); const info = require('./info'); - +const isUndefined = (a) => typeof a === 'undefined'; +const isRootAll = (root, names) => names.some(isRootWin32(root)); const isString = (a) => typeof a === 'string'; const isFn = (a) => typeof a === 'function'; const swap = wraptile((fn, a, b) => fn(b, a)); @@ -66,7 +67,7 @@ function rest({fs, config, moveFiles}, request, response) { if (options.name) params.name = options.name; - if (options.gzip !== undefined) + if (!isUndefined(options.gzip)) params.gzip = options.gzip; if (options.query) @@ -370,10 +371,6 @@ const isRootWin32 = currify((root, path) => { module.exports._isRootWin32 = isRootWin32; module.exports._isRootAll = isRootAll; -function isRootAll(root, names) { - return names.some(isRootWin32(root)); -} - module.exports._getWin32RootMsg = getWin32RootMsg; function getWin32RootMsg() { diff --git a/server/terminal.js b/server/terminal.js index d10cdc8b..67613f0a 100644 --- a/server/terminal.js +++ b/server/terminal.js @@ -8,9 +8,7 @@ const noop = (req, res, next) => { noop.listen = noop; -function _getModule(a) { - return require(a); -} +const _getModule = (a) => require(a); module.exports = (config, arg, overrides = {}) => { const { diff --git a/static/user-menu.spec.js b/static/user-menu.spec.js index b10b5b15..9c42302a 100644 --- a/static/user-menu.spec.js +++ b/static/user-menu.spec.js @@ -337,11 +337,9 @@ function getDOM() { }; } -function getCloudCmd() { - return { - refresh: stub(), - EditFile: { - show: stub(), - }, - }; -} +const getCloudCmd = () => ({ + refresh: stub(), + EditFile: { + show: stub(), + }, +});