From c3339d8ea207a00a762ad544bea992390b1fd0d2 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 28 Dec 2020 23:00:04 +0200 Subject: [PATCH] fix(cloudcmd) drop support of node < 14 --- .putout.json | 3 +++ client/dom/index.js | 4 ++-- client/listeners/index.js | 4 ++-- client/sw/register.js | 4 ++-- package.json | 2 +- server/exit.js | 2 +- server/rest/index.js | 2 +- 7 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.putout.json b/.putout.json index 31c37e2f..5d6c3f53 100644 --- a/.putout.json +++ b/.putout.json @@ -1,4 +1,7 @@ { + "rules": { + "apply-optional-chaining": "on" + }, "ignore": [ "fixture*", "dist*", diff --git a/client/dom/index.js b/client/dom/index.js index d3f0141d..044217b1 100644 --- a/client/dom/index.js +++ b/client/dom/index.js @@ -638,7 +638,7 @@ function CmdProto() { if (!current) DOM.getCurrentFile(); - const parent = current && current.parentElement; + const parent = current?.parentElement; const name = DOM.getCurrentName(current); if (current && name !== '..') { @@ -685,7 +685,7 @@ function CmdProto() { /* scroll on one page */ this.scrollByPages = (element, pPages) => { - const ret = element && element.scrollByPages && pPages; + const ret = element?.scrollByPages && pPages; if (ret) element.scrollByPages(pPages); diff --git a/client/listeners/index.js b/client/listeners/index.js index 3e4be322..3eac5b59 100644 --- a/client/listeners/index.js +++ b/client/listeners/index.js @@ -103,7 +103,7 @@ function getPath(el, path = []) { async function config() { const [, config] = await tryToCatch(DOM.Files.get, 'config'); - const type = config && config.packer; + const type = config?.packer; EXT = DOM.getPackerExt(type); } @@ -461,7 +461,7 @@ function dragndrop() { function unload() { DOM.Events.add(['unload', 'beforeunload'], (event) => { const {Key} = CloudCmd; - const isBind = Key && Key.isBind(); + const isBind = Key?.isBind(); if (isBind) return; diff --git a/client/sw/register.js b/client/sw/register.js index f1af5d14..518bceff 100644 --- a/client/sw/register.js +++ b/client/sw/register.js @@ -4,7 +4,7 @@ module.exports.registerSW = registerSW; module.exports.unregisterSW = unregisterSW; module.exports.listenSW = (sw, ...args) => { - sw && sw.addEventListener(...args); + sw?.addEventListener(...args); }; async function registerSW(prefix) { @@ -21,6 +21,6 @@ async function registerSW(prefix) { } async function unregisterSW(prefix) { const reg = await registerSW(prefix); - reg && reg.unregister(prefix); + reg?.unregister(prefix); } diff --git a/package.json b/package.json index 29ce423e..d384ee88 100644 --- a/package.json +++ b/package.json @@ -220,7 +220,7 @@ "yaspeller": "^7.0.0" }, "engines": { - "node": ">=12" + "node": ">=14" }, "license": "MIT", "main": "server/cloudcmd.js", diff --git a/server/exit.js b/server/exit.js index f01cd130..edc6b409 100644 --- a/server/exit.js +++ b/server/exit.js @@ -1,6 +1,6 @@ 'use strict'; -const getMessage = (a) => a && a.message || a; +const getMessage = (a) => a?.message || a; module.exports = (...args) => { const messages = args.map(getMessage); diff --git a/server/rest/index.js b/server/rest/index.js index 996f3120..cbd65d44 100644 --- a/server/rest/index.js +++ b/server/rest/index.js @@ -70,7 +70,7 @@ function rest(config, request, response) { if (options.query) params.query = options.query; - if (error && error.code) + if (error?.code) return ponse.sendError(error, params); if (error)