diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 95e1fd6e..d543312b 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -39,6 +39,7 @@ jobs: run: typos --write-changes - name: Commit fixes uses: EndBug/add-and-commit@v9 + continue-on-error: true with: message: "chore: ${{ env.NAME }}: actions: lint ☘️" - name: Build @@ -49,5 +50,6 @@ jobs: run: redrun coverage coverage:report - name: Coveralls uses: coverallsapp/github-action@v2 + continue-on-error: true with: github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/bin/cloudcmd.mjs b/bin/cloudcmd.mjs index d55c41d3..9d55723b 100755 --- a/bin/cloudcmd.mjs +++ b/bin/cloudcmd.mjs @@ -24,7 +24,7 @@ const simport = createSimport(import.meta.url); const choose = (a, b) => { if (a === undefined) return b; - + return a; }; @@ -37,7 +37,7 @@ const DIR_SERVER = '../server/'; const maybeRoot = (a) => { if (a === '.') return process.cwd(); - + return a; }; diff --git a/bin/release.mjs b/bin/release.mjs index 08254685..ebc74ea4 100755 --- a/bin/release.mjs +++ b/bin/release.mjs @@ -68,6 +68,6 @@ async function cl() { function getVersionNew(last, match) { if (match) return minor(match, Info.version); - + return last.substr(3); } diff --git a/client/dom/index.js b/client/dom/index.js index acefb5b9..c9b50e44 100644 --- a/client/dom/index.js +++ b/client/dom/index.js @@ -1,6 +1,5 @@ 'use strict'; -const isString = (a) => typeof a === 'string'; /* global CloudCmd */ const Util = require('../../common/util'); @@ -38,8 +37,9 @@ DOM.Events = require('./events'); const loadRemote = require('./load-remote'); const selectByPattern = require('./select-by-pattern'); - +const isString = (a) => typeof a === 'string'; const SELECTED_FILE = 'selected-file'; + const TabPanel = { 'js-left': null, 'js-right': null, diff --git a/client/modules/edit.js b/client/modules/edit.js index 44392dcb..a62535b7 100644 --- a/client/modules/edit.js +++ b/client/modules/edit.js @@ -2,7 +2,6 @@ 'use strict'; -const isFn = (a) => typeof a === 'function'; const montag = require('montag'); const {promisify} = require('es6-promisify'); @@ -12,6 +11,7 @@ const load = require('load.js'); const {MAX_FILE_SIZE: maxSize} = require('../../common/cloudfunc'); const {time, timeEnd} = require('../../common/util'); +const isFn = (a) => typeof a === 'function'; const loadJS = load.js; const Name = 'Edit'; diff --git a/client/modules/view/index.js b/client/modules/view/index.js index 893e9df1..0e79ab4e 100644 --- a/client/modules/view/index.js +++ b/client/modules/view/index.js @@ -2,7 +2,6 @@ 'use strict'; -const isString = (a) => typeof a === 'string'; require('../../../css/view.css'); const rendy = require('rendy'); @@ -28,7 +27,7 @@ const Events = require('../../dom/events'); const Images = require('../../dom/images'); const {encode} = require('../../../common/entity'); - +const isString = (a) => typeof a === 'string'; const {assign} = Object; const {isArray} = Array; diff --git a/common/base64.js b/common/base64.js index 6cd8efcd..c1a82c17 100644 --- a/common/base64.js +++ b/common/base64.js @@ -3,7 +3,7 @@ module.exports.btoa = (str) => { if (typeof btoa === 'function') return btoa(str); - + return Buffer .from(str) .toString('base64'); @@ -12,7 +12,7 @@ module.exports.btoa = (str) => { module.exports.atob = (str) => { if (typeof atob === 'function') return atob(str); - + return Buffer .from(str, 'base64') .toString('binary'); diff --git a/common/cloudfunc.js b/common/cloudfunc.js index 1f96e6b9..5d61258e 100644 --- a/common/cloudfunc.js +++ b/common/cloudfunc.js @@ -249,7 +249,7 @@ function updateField(file) { function getAttribute(type) { if (type === 'directory') return ''; - + return 'target="_blank" '; } diff --git a/common/datetime.js b/common/datetime.js index 39549bef..131c27fb 100644 --- a/common/datetime.js +++ b/common/datetime.js @@ -15,7 +15,7 @@ module.exports = (date) => { const addZero = (a) => { if (a > 9) return a; - + return `0${a}`; }; diff --git a/common/util.js b/common/util.js index eb7dee7b..2e6b330a 100644 --- a/common/util.js +++ b/common/util.js @@ -1,9 +1,10 @@ 'use strict'; const exec = require('execon'); +const isString = (a) => typeof a === 'string'; module.exports.escapeRegExp = (str) => { - const isStr = typeof str === 'string'; + const isStr = isString(str); if (isStr) str = str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); @@ -33,7 +34,7 @@ module.exports.exec = exec; * @return ext */ module.exports.getExt = (name) => { - const isStr = typeof name === 'string'; + const isStr = isString(name); if (!isStr) return ''; @@ -58,7 +59,7 @@ module.exports.findObjByNameInArr = (array, name) => { if (!Array.isArray(array)) throw Error('array should be array!'); - if (typeof name !== 'string') + if (!isString(name)) throw Error('name should be string!'); array.some((item) => { diff --git a/server/cloudcmd.js b/server/cloudcmd.js index 467785e9..365d5917 100644 --- a/server/cloudcmd.js +++ b/server/cloudcmd.js @@ -109,7 +109,7 @@ module.exports._getPrefix = getPrefix; function getPrefix(prefix) { if (isFn(prefix)) return prefix() || ''; - + return prefix || ''; } @@ -258,7 +258,7 @@ module.exports._replaceDist = replaceDist; function replaceDist(url) { if (!isDev) return url; - + return url.replace(/^\/dist\//, '/dist-dev/'); } diff --git a/server/config.js b/server/config.js index 2d4d5e78..af0a514b 100644 --- a/server/config.js +++ b/server/config.js @@ -76,7 +76,7 @@ const manageListen = currify((manage, socket, auth) => { function initWrite(filename, configManager) { if (filename) return write.bind(null, filename, configManager); - + return resolve; } diff --git a/server/markdown/index.js b/server/markdown/index.js index a1f45412..856cb677 100644 --- a/server/markdown/index.js +++ b/server/markdown/index.js @@ -1,6 +1,5 @@ 'use strict'; -const isString = (a) => typeof a === 'string'; const {join} = require('path'); const {callbackify} = require('util'); @@ -10,7 +9,7 @@ const threadIt = require('thread-it'); const {read} = require('redzip'); const root = require('../root'); - +const isString = (a) => typeof a === 'string'; const parse = threadIt(join(__dirname, 'worker')); threadIt.init(); diff --git a/server/rest/index.js b/server/rest/index.js index ead6db24..84089ac6 100644 --- a/server/rest/index.js +++ b/server/rest/index.js @@ -1,7 +1,5 @@ 'use strict'; -const isFn = (a) => typeof a === 'function'; -const isString = (a) => typeof a === 'string'; const DIR = '../'; const DIR_COMMON = `${DIR}../common/`; @@ -24,7 +22,8 @@ const ponse = require('ponse'); const copymitter = require('copymitter'); const moveFiles = require('@cloudcmd/move-files'); - +const isString = (a) => typeof a === 'string'; +const isFn = (a) => typeof a === 'function'; const swap = wraptile((fn, a, b) => fn(b, a)); const isWin32 = process.platform === 'win32'; const {apiURL} = CloudFunc; diff --git a/server/validate.js b/server/validate.js index 8cb3283c..e74eaa04 100644 --- a/server/validate.js +++ b/server/validate.js @@ -1,10 +1,10 @@ 'use strict'; -const isString = (a) => typeof a === 'string'; const tryCatch = require('try-catch'); const exit = require('./exit'); const columns = require('./columns'); +const isString = (a) => typeof a === 'string'; module.exports.root = (dir, config) => { if (!isString(dir)) diff --git a/static/user-menu.js b/static/user-menu.js index fb75540c..c8645d51 100644 --- a/static/user-menu.js +++ b/static/user-menu.js @@ -131,9 +131,8 @@ async function createDefaultMenu({path, data, DOM, CloudCmd}) { async function readDefaultMenu({prefix}) { const res = await fetch(`${prefix}/api/v1/user-menu/default`); - const data = await res.text(); - return data; + return await res.text(); } module.exports._selectNames = selectNames;