diff --git a/_typos.toml b/_typos.toml index cffe90ed1..b9e248440 100644 --- a/_typos.toml +++ b/_typos.toml @@ -50,3 +50,4 @@ contaienr = "contaienr" formate = "formate" collapsable = "collapsable" styl = "styl" +Inferrable = "Inferrable" diff --git a/biome.json b/biome.json index 364cfc827..482b2c8d0 100644 --- a/biome.json +++ b/biome.json @@ -10,18 +10,80 @@ "noForEach": "warn", "noStaticOnlyClass": "error", "noUselessSwitchCase": "error", - "useFlatMap": "error" + "useFlatMap": "error", + "noExtraBooleanCast": "warn", + "noMultipleSpacesInRegularExpressionLiterals": "error", + "noThisInStatic": "warn", + "noUselessCatch": "error", + "noUselessConstructor": "error", + "noUselessFragments": "error", + "noUselessLabel": "error", + "noUselessLoneBlockStatements": "error", + "noUselessRename": "error", + "noUselessTernary": "warn", + "noUselessThisAlias": "error", + "noWith": "error", + "useArrowFunction": "warn", + "useOptionalChain": "warn", + "useSimpleNumberKeys": "error" + }, + "performance": { + "noAccumulatingSpread": "error", + "noDelete": "warn" }, "style": { "noNegationElse": "off", "useForOf": "error", "useNodejsImportProtocol": "error", - "useNumberNamespace": "error" + "useNumberNamespace": "error", + "noInferrableTypes": "error", + "noNonNullAssertion": "error", + "noParameterAssign": "off", + "noUnusedTemplateLiteral": "warn", + "noUselessElse": "warn", + "useConst": "warn", + "useExponentiationOperator": "warn", + "useNumericLiterals": "error", + "useWhile": "error" + }, + "security": { + "noDangerouslySetInnerHtml": "error", + "noDangerouslySetInnerHtmlWithChildren": "error", + "noGlobalEval": "warn" }, "suspicious": { "noDoubleEquals": "error", "noThenProperty": "error", - "useIsArray": "error" + "useIsArray": "error", + "noApproximativeNumericConstant": "error", + "noArrayIndexKey": "error", + "noAsyncPromiseExecutor": "warn", + "noCatchAssign": "error", + "noClassAssign": "error", + "noCommentText": "error", + "noCompareNegZero": "error", + "noConfusingLabels": "error", + "noControlCharactersInRegex": "error", + "noDuplicateClassMembers": "error", + "noDuplicateJsxProps": "error", + "noDuplicateObjectKeys": "error", + "noDuplicateParameters": "error", + "noEmptyBlockStatements": "warn", + "noGlobalAssign": "error", + "noGlobalIsFinite": "error", + "noGlobalIsNan": "warn", + "noMisrefactoredShorthandAssign": "error", + "noPrototypeBuiltins": "warn", + "noRedeclare": "error", + "noRedundantUseStrict": "error", + "noSelfCompare": "error", + "noShadowRestrictedNames": "error", + "noSparseArray": "error", + "noSuspiciousSemicolonInJsx": "error", + "noUnsafeNegation": "error", + "useDefaultSwitchClauseLast": "error", + "useGetterReturn": "error", + "useValidTypeof": "error" } } }, diff --git a/src/ace/commands.js b/src/ace/commands.js index 516253d19..a5a325a4d 100644 --- a/src/ace/commands.js +++ b/src/ace/commands.js @@ -200,9 +200,9 @@ const commands = [ name: "cut", description: "Cut", exec(editor) { - let cutLine = + const cutLine = editor.$copyWithEmptySelection && editor.selection.isEmpty(); - let range = cutLine + const range = cutLine ? editor.selection.getLineRange() : editor.selection.getRange(); editor._emit("cut", range); @@ -285,7 +285,7 @@ const commands = [ name: "increaseFontSize", description: "Increase font size", exec(editor) { - let size = Number.parseInt(editor.getFontSize(), 10) || 12; + const size = Number.parseInt(editor.getFontSize(), 10) || 12; editor.setFontSize(size + 1); settings.value.fontSize = size + 1 + "px"; settings.update(false); @@ -295,7 +295,7 @@ const commands = [ name: "decreaseFontSize", description: "Decrease font size", exec(editor) { - let size = Number.parseInt(editor.getFontSize(), 10) || 12; + const size = Number.parseInt(editor.getFontSize(), 10) || 12; editor.setFontSize(Math.max(size - 1 || 1)); settings.value.fontSize = Math.max(size - 1 || 1) + "px"; settings.update(false); diff --git a/src/ace/modelist.js b/src/ace/modelist.js index c6f70d8ca..6b1e95218 100644 --- a/src/ace/modelist.js +++ b/src/ace/modelist.js @@ -5,11 +5,11 @@ export function initModes() { ace.define( "ace/ext/modelist", ["require", "exports", "module"], - function (require, exports, module) { + (require, exports, module) => { module.exports = { getModeForPath(path) { let mode = modesByName.text; - let fileName = path.split(/[\/\\]/).pop(); + const fileName = path.split(/[\/\\]/).pop(); for (const iMode of modes) { if (iMode.supportsFile?.(fileName)) { mode = iMode; @@ -81,9 +81,8 @@ class Mode { if (/\^/.test(extensions)) { re = - extensions.replace(/\|(\^)?/g, function (a, b) { - return "$|" + (b ? "^" : "^.*\\."); - }) + "$"; + extensions.replace(/\|(\^)?/g, (a, b) => "$|" + (b ? "^" : "^.*\\.")) + + "$"; } else { re = "^.*\\.(" + extensions + ")$"; } diff --git a/src/ace/touchHandler.js b/src/ace/touchHandler.js index 6c9eed374..9f5bc47b8 100644 --- a/src/ace/touchHandler.js +++ b/src/ace/touchHandler.js @@ -548,9 +548,9 @@ export default function addTouchListeners(editor, minimal, onclick) { * @param {number} y */ function scroll(x, y) { - let direction = reverseScrolling ? 1 : -1; - let scrollX = direction * x; - let scrollY = direction * y; + const direction = reverseScrolling ? 1 : -1; + const scrollX = direction * x; + const scrollY = direction * y; renderer.scrollBy(scrollX, scrollY); } diff --git a/src/components/WebComponents/wcPage.js b/src/components/WebComponents/wcPage.js index 5a73a6618..86e89e296 100644 --- a/src/components/WebComponents/wcPage.js +++ b/src/components/WebComponents/wcPage.js @@ -61,7 +61,7 @@ export default class WCPage extends HTMLElement { } appendBody(...$els) { - let $main = this.body; + const $main = this.body; if (!$main) return; for (const $el of $els) { $main.append($el); @@ -262,7 +262,7 @@ class PageHandler { */ function handlePagesForSmoothExperience() { const $pages = [...tag.getAll("wc-page")]; - for (let $page of $pages.slice(0, -1)) { + for (const $page of $pages.slice(0, -1)) { $page.handler.replaceEl(); } } diff --git a/src/components/contextmenu/index.js b/src/components/contextmenu/index.js index 025977f2f..ce6474322 100644 --- a/src/components/contextmenu/index.js +++ b/src/components/contextmenu/index.js @@ -121,7 +121,7 @@ export default function Contextmenu(content, options) { function addTabindex() { /**@type {Array} */ const children = [...$el.children]; - for (let $el of children) $el.tabIndex = "0"; + for (const $el of children) $el.tabIndex = "0"; } function destroy() { diff --git a/src/components/page.js b/src/components/page.js index 9b3b13857..252486e94 100644 --- a/src/components/page.js +++ b/src/components/page.js @@ -9,7 +9,7 @@ import WCPage from "./WebComponents/wcPage"; * @returns {WCPage} */ function Page(title, options = {}) { - let page = ; + const page = ; page.append = page.appendBody; page.initializeIfNotAlreadyInitialized(); page.settitle(title); diff --git a/src/components/scrollbar/index.js b/src/components/scrollbar/index.js index 4f8ca598c..3dc1b61e7 100644 --- a/src/components/scrollbar/index.js +++ b/src/components/scrollbar/index.js @@ -57,7 +57,7 @@ export default function ScrollBar(options) { const isVertical = placement === "right" || placement === "left"; const observer = new MutationObserver(observerCallback); let scroll = 0; - let touchStartValue = { + const touchStartValue = { x: 0, y: 0, }; diff --git a/src/components/sidebar/index.js b/src/components/sidebar/index.js index a012db4d5..868960039 100644 --- a/src/components/sidebar/index.js +++ b/src/components/sidebar/index.js @@ -5,7 +5,7 @@ import constants from "lib/constants"; let $sidebar; /**@type {Array<(el:HTMLElement)=>boolean>} */ -let preventSlideTests = []; +const preventSlideTests = []; const events = { show: [], @@ -247,7 +247,7 @@ function create($container, $toggler) { touch.totalX = touch.endX - touch.startX; touch.totalY = touch.endY - touch.startY; - let width = $el.getWidth(); + const width = $el.getWidth(); if ( !$el.activated && @@ -347,7 +347,7 @@ function create($container, $toggler) { $el.hide = hide; $el.toggle = toggle; $el.onshow = () => {}; - $el.getWidth = function () { + $el.getWidth = () => { const width = innerWidth * 0.7; return mode === "phone" ? (width >= 350 ? 350 : width) : MIN_WIDTH; }; diff --git a/src/dialogs/alert.js b/src/dialogs/alert.js index 4c2d2a7a2..d7b497630 100644 --- a/src/dialogs/alert.js +++ b/src/dialogs/alert.js @@ -16,9 +16,7 @@ function alert(titleText, message, onhide) { const regex = /(https?:\/\/[^\s]+)/g; if (regex.test(message)) { - message = message.replace(regex, function (url) { - return `${url}`; - }); + message = message.replace(regex, (url) => `${url}`); } const titleSpan = tag("strong", { diff --git a/src/dialogs/box.js b/src/dialogs/box.js index 96ae860fa..71fab4537 100644 --- a/src/dialogs/box.js +++ b/src/dialogs/box.js @@ -31,7 +31,8 @@ function box(titleText, html, hideButtonText, cancelButtonText) { }; let cancelBtn; - let hideButton = typeof hideButtonText === "boolean" ? hideButtonText : false; + const hideButton = + typeof hideButtonText === "boolean" ? hideButtonText : false; if (cancelButtonText) { cancelBtn = tag("button", { @@ -117,7 +118,7 @@ function box(titleText, html, hideButtonText, cancelButtonText) { if (waitFor) return; const imgs = box.getAll("img"); if (imgs) { - for (let img of imgs) { + for (const img of imgs) { URL.revokeObjectURL(img.src); } } diff --git a/src/dialogs/color.js b/src/dialogs/color.js index 8369d4cc0..a908978b0 100644 --- a/src/dialogs/color.js +++ b/src/dialogs/color.js @@ -23,7 +23,7 @@ function color(defaultColor, onhide) { }); const okBtn = tag("button", { textContent: strings.ok, - onclick: function () { + onclick: () => { hide(); lastPicked = color; localStorage.__picker_last_picked = color; diff --git a/src/dialogs/confirm.js b/src/dialogs/confirm.js index 6c70aeba4..a376f34a7 100644 --- a/src/dialogs/confirm.js +++ b/src/dialogs/confirm.js @@ -27,14 +27,14 @@ function confirm(titleText, message, isHTML) { }); const okBtn = tag("button", { textContent: strings.ok, - onclick: function () { + onclick: () => { hide(); resolve(true); }, }); const cancelBtn = tag("button", { textContent: strings.cancel, - onclick: function () { + onclick: () => { hide(); resolve(false); }, diff --git a/src/dialogs/multiPrompt.js b/src/dialogs/multiPrompt.js index 0a8324748..ffedc2d7c 100644 --- a/src/dialogs/multiPrompt.js +++ b/src/dialogs/multiPrompt.js @@ -51,12 +51,12 @@ export default function multiPrompt(message, inputs, help) { const okBtn = tag("button", { type: "submit", textContent: strings.ok, - onclick: function (e) { + onclick: (e) => { e.preventDefault(); e.stopPropagation(); const inputAr = [...$body.getAll("input")]; - for (let $input of inputAr) { + for (const $input of inputAr) { if ($input.isRequired && !$input.value) { $errorMessage.textContent = strings.required.capitalize(); const $sibling = $input.nextElementSibling; @@ -73,7 +73,7 @@ export default function multiPrompt(message, inputs, help) { const cancelBtn = tag("button", { textContent: strings.cancel, type: "button", - onclick: function () { + onclick: () => { reject(); hide(); }, @@ -215,7 +215,7 @@ export default function multiPrompt(message, inputs, help) { } = input; const inputType = type === "textarea" ? "textarea" : "input"; - let _type = type === "filename" ? "text" : type || "text"; + const _type = type === "filename" ? "text" : type || "text"; let $input; diff --git a/src/dialogs/prompt.js b/src/dialogs/prompt.js index 19a96e5cc..f339c95cc 100644 --- a/src/dialogs/prompt.js +++ b/src/dialogs/prompt.js @@ -42,7 +42,7 @@ export default function prompt( type: "submit", textContent: strings.ok, disabled: !defaultValue, - onclick: function () { + onclick: () => { if (options.required && !input.value) { errorMessage.textContent = strings.required; return; @@ -56,7 +56,7 @@ export default function prompt( const cancelBtn = tag("button", { textContent: strings.cancel, type: "button", - onclick: function () { + onclick: () => { hide(); resolve(null); }, @@ -97,7 +97,7 @@ export default function prompt( } } - input.oninput = function () { + input.oninput = () => { const { match, test } = options; let isValid = true; diff --git a/src/dialogs/select.js b/src/dialogs/select.js index 35ce1ae6e..542ce017e 100644 --- a/src/dialogs/select.js +++ b/src/dialogs/select.js @@ -81,7 +81,7 @@ function select(title, options, opts = {}) { $item.tabIndex = "0"; - $item.onclick = function () { + $item.onclick = () => { if (value === undefined) return; if (opts.hideOnSelect) hide(); resolve(value); @@ -124,7 +124,7 @@ function select(title, options, opts = {}) { if (typeof opts.onHide === "function") opts.onHide(); actionStack.remove("select"); hideSelect(); - let listItems = [...$list.children]; + const listItems = [...$list.children]; listItems.map((item) => (item.onclick = null)); } }); diff --git a/src/fileSystem/internalFs.js b/src/fileSystem/internalFs.js index c53654cf7..ab026f2ae 100644 --- a/src/fileSystem/internalFs.js +++ b/src/fileSystem/internalFs.js @@ -334,7 +334,7 @@ const internalFs = { }; function setMessage(reject) { - return function (err) { + return (err) => { if (err.code) { const message = getErrorMessage(err.code); err.message = message; diff --git a/src/handlers/editorFileTab.js b/src/handlers/editorFileTab.js index 9c64df7cd..f7a59fa32 100644 --- a/src/handlers/editorFileTab.js +++ b/src/handlers/editorFileTab.js @@ -271,8 +271,8 @@ function getClientPos(e) { function updateFileList($parent) { const children = [...$parent.children]; const newFileList = []; - for (let el of children) { - for (let file of editorManager.files) { + for (const el of children) { + for (const file of editorManager.files) { if (file.tab === el) { newFileList.push(file); break; diff --git a/src/handlers/purchase.js b/src/handlers/purchase.js index 394ab9eb6..1b1c7fd86 100644 --- a/src/handlers/purchase.js +++ b/src/handlers/purchase.js @@ -35,7 +35,7 @@ export default function purchaseListener(onpurchase, onerror) { return; } - let message = + const message = error === iap.USER_CANCELED ? strings.failed : strings.canceled; if (typeof onerror === "function") onerror(message); diff --git a/src/handlers/quickTools.js b/src/handlers/quickTools.js index 5285090be..77addbf52 100644 --- a/src/handlers/quickTools.js +++ b/src/handlers/quickTools.js @@ -345,7 +345,7 @@ function updateSearchState() { const { editor } = editorManager; const { $searchPos, $searchTotal } = quickTools; - let regex = editor.$search.$options.re; + const regex = editor.$search.$options.re; let all = 0; let before = 0; if (regex) { diff --git a/src/lib/actionStack.js b/src/lib/actionStack.js index 03b92e2e8..c09efcea6 100644 --- a/src/lib/actionStack.js +++ b/src/lib/actionStack.js @@ -77,7 +77,7 @@ export default { } if (appSettings.value.confirmOnExit) { - let closeMessage = + const closeMessage = acode.exitAppMessage || strings["close app"].capitalize(0); confirmation = await confirm(strings.warning.toUpperCase(), closeMessage); } @@ -110,7 +110,7 @@ export default { */ remove(id) { for (let i = 0; i < stack.length; ++i) { - let action = stack[i]; + const action = stack[i]; if (action.id === id) { stack.splice(i, 1); return true; @@ -125,7 +125,7 @@ export default { * @returns {Boolean} */ has(id) { - for (let act of stack) if (act.id === id) return true; + for (const act of stack) if (act.id === id) return true; return false; }, /** diff --git a/src/lib/applySettings.js b/src/lib/applySettings.js index a70d85933..f0c667e19 100644 --- a/src/lib/applySettings.js +++ b/src/lib/applySettings.js @@ -15,7 +15,7 @@ export default { } //setup vibration - app.addEventListener("click", function (e) { + app.addEventListener("click", (e) => { const $target = e.target; if ($target.hasAttribute("vibrate") && appSettings.value.vibrateOnTap) { navigator.vibrate(constants.VIBRATION_TIME); diff --git a/src/lib/commands.js b/src/lib/commands.js index 305eb35fc..546a37679 100644 --- a/src/lib/commands.js +++ b/src/lib/commands.js @@ -304,7 +304,7 @@ export default { async "insert-color"() { const { editor } = editorManager; const range = getColorRange(); - let defaultColor = range ? editor.session.getTextRange(range) : ""; + const defaultColor = range ? editor.session.getTextRange(range) : ""; editor.blur(); const wasFocused = editorManager.activeFile.focused; @@ -415,7 +415,7 @@ export default { Promise.all([getWebviewInfo, getAppInfo]) .then(() => { - let info = `Device Information: + const info = `Device Information: WebView Info: Package Name: ${webviewInfo?.packageName || "N/A"} Version: ${webviewInfo?.versionName || "N/A"} diff --git a/src/lib/console.js b/src/lib/console.js index 4367463b4..8eca2fe6d 100644 --- a/src/lib/console.js +++ b/src/lib/console.js @@ -4,7 +4,7 @@ import * as esprima from "esprima"; import css from "styles/console.module.scss"; import loadPolyFill from "utils/polyfill"; -(function () { +(() => { loadPolyFill.apply(window); let consoleVisible = false; @@ -37,7 +37,7 @@ import loadPolyFill from "utils/polyfill"; passive: false, }); - document.ontouchend = function (e) { + document.ontouchend = (e) => { document.removeEventListener("touchmove", touchmove, { passive: "false", }); @@ -219,8 +219,8 @@ import loadPolyFill from "utils/polyfill"; isFocused = true; if (key === "Enter") { const regex = /[\[|{\(\)\}\]]/g; - let code = this.value.trim(); - let isOdd = (code.length - code.replace(regex, "").length) % 2; + const code = this.value.trim(); + const isOdd = (code.length - code.replace(regex, "").length) % 2; if (!code || isOdd) return; e.preventDefault(); @@ -242,7 +242,7 @@ import loadPolyFill from "utils/polyfill"; if (obj instanceof Promise && !("[[PromiseStatus]]" in obj)) obj = getPromiseStatus(obj); - let value = objValue(obj, ...keys); + const value = objValue(obj, ...keys); const $group = tag("c-group"); const $toggler = tag("c-type", { attr: { @@ -263,7 +263,7 @@ import loadPolyFill from "utils/polyfill"; const possibleKeys = []; - for (let key in value) { + for (const key in value) { possibleKeys.push(key); } @@ -345,7 +345,7 @@ import loadPolyFill from "utils/polyfill"; if (obj.info) return; let status = "pending"; let value; - let result = obj.then( + const result = obj.then( (val) => { status = "resolved"; value = val; @@ -401,7 +401,7 @@ import loadPolyFill from "utils/polyfill"; str = joinParams(expression.params); } } else { - let string = parsed.id.name + joinParams(parsed.params || []); + const string = parsed.id.name + joinParams(parsed.params || []); str = string; } @@ -429,7 +429,7 @@ import loadPolyFill from "utils/polyfill"; * @param {...any} args */ function log(mode, options, ...args) { - let location = options.location || "console"; + const location = options.location || "console"; const $messages = tag("c-message", { attr: { "log-level": mode, @@ -533,7 +533,7 @@ import loadPolyFill from "utils/polyfill"; break; case "%o": case "%O": - let id = new Date().getMilliseconds() + ""; + const id = new Date().getMilliseconds() + ""; window.__objs[id] = value; value = `Object`; break; @@ -595,7 +595,7 @@ import loadPolyFill from "utils/polyfill"; if (error === null) { error = new Error(); } - let stack = error.stack.split("\n"); + const stack = error.stack.split("\n"); if (!skip) stack.splice(1, 1); let regExecRes = /<(.*)>:(\d+):(\d+)/.exec(stack[1]) || []; if (!regExecRes.length) { diff --git a/src/lib/editorManager.js b/src/lib/editorManager.js index efed71da0..553c0aca6 100644 --- a/src/lib/editorManager.js +++ b/src/lib/editorManager.js @@ -28,7 +28,7 @@ async function EditorManager($header, $body) { * @type {Collapsible & HTMLElement} */ let $openFileList; - let TIMEOUT_VALUE = 500; + const TIMEOUT_VALUE = 500; let preventScrollbarV = false; let preventScrollbarH = false; let scrollBarVisibilityCount = 0; @@ -119,7 +119,7 @@ async function EditorManager($header, $body) { }, emit(event, ...args) { let detailedEvent; - let detailedEventArgs = args.slice(1); + const detailedEventArgs = args.slice(1); if (event === "update") { const subEvent = args[0]; if (subEvent) { @@ -144,79 +144,79 @@ async function EditorManager($header, $body) { ); $hScrollbar.onhide = $vScrollbar.onhide = updateFloatingButton.bind({}, true); - appSettings.on("update:textWrap", function (value) { + appSettings.on("update:textWrap", (value) => { updateMargin(); - for (let file of manager.files) { + for (const file of manager.files) { file.session.setUseWrapMode(value); if (!value) file.session.on("changeScrollLeft", onscrollleft); else file.session.off("changeScrollLeft", onscrollleft); } }); - appSettings.on("update:tabSize", function (value) { + appSettings.on("update:tabSize", (value) => { manager.files.forEach((file) => file.session.setTabSize(value)); }); - appSettings.on("update:softTab", function (value) { + appSettings.on("update:softTab", (value) => { manager.files.forEach((file) => file.session.setUseSoftTabs(value)); }); - appSettings.on("update:showSpaces", function (value) { + appSettings.on("update:showSpaces", (value) => { editor.setOption("showInvisibles", value); }); - appSettings.on("update:fontSize", function (value) { + appSettings.on("update:fontSize", (value) => { editor.setFontSize(value); }); - appSettings.on("update:openFileListPos", function (value) { + appSettings.on("update:openFileListPos", (value) => { initFileTabContainer(); $vScrollbar.resize(); }); - appSettings.on("update:showPrintMargin", function (value) { + appSettings.on("update:showPrintMargin", (value) => { editorManager.editor.setOption("showPrintMargin", value); }); - appSettings.on("update:scrollbarSize", function (value) { + appSettings.on("update:scrollbarSize", (value) => { $vScrollbar.size = value; $hScrollbar.size = value; }); - appSettings.on("update:liveAutoCompletion", function (value) { + appSettings.on("update:liveAutoCompletion", (value) => { editor.setOption("enableLiveAutocompletion", value); }); - appSettings.on("update:linenumbers", function (value) { + appSettings.on("update:linenumbers", (value) => { updateMargin(true); editor.resize(true); }); - appSettings.on("update:lineHeight", function (value) { + appSettings.on("update:lineHeight", (value) => { editor.container.style.lineHeight = value; }); - appSettings.on("update:relativeLineNumbers", function (value) { + appSettings.on("update:relativeLineNumbers", (value) => { editor.setOption("relativeLineNumbers", value); }); - appSettings.on("update:elasticTabstops", function (value) { + appSettings.on("update:elasticTabstops", (value) => { editor.setOption("useElasticTabstops", value); }); - appSettings.on("update:rtlText", function (value) { + appSettings.on("update:rtlText", (value) => { editor.setOption("rtlText", value); }); - appSettings.on("update:hardWrap", function (value) { + appSettings.on("update:hardWrap", (value) => { editor.setOption("hardWrap", value); }); - appSettings.on("update:printMargin", function (value) { + appSettings.on("update:printMargin", (value) => { editor.setOption("printMarginColumn", value); }); - appSettings.on("update:colorPreview", function (value) { + appSettings.on("update:colorPreview", (value) => { if (value) { return initColorView(editor, true); } @@ -224,16 +224,16 @@ async function EditorManager($header, $body) { deactivateColorView(); }); - appSettings.on("update:showSideButtons", function () { + appSettings.on("update:showSideButtons", () => { updateMargin(); updateSideButtonContainer(); }); - appSettings.on("update:showAnnotations", function () { + appSettings.on("update:showAnnotations", () => { updateMargin(true); }); - appSettings.on("update:fadeFoldWidgets", function (value) { + appSettings.on("update:fadeFoldWidgets", (value) => { editor.setOption("fadeFoldWidgets", value); }); diff --git a/src/lib/fileList.js b/src/lib/fileList.js index 79a04c5dc..1e04a5986 100644 --- a/src/lib/fileList.js +++ b/src/lib/fileList.js @@ -124,7 +124,7 @@ export default function files(dir) { * @param {FileListEvent} event - Event name * @param {(tree:Tree)=>void} callback - Callback function */ -files.on = function (event, callback) { +files.on = (event, callback) => { if (!events[event]) events[event] = []; events[event].push(callback); }; @@ -134,7 +134,7 @@ files.on = function (event, callback) { * @param {FileListEvent} event - Event name * @param {(tree:Tree)=>void} callback - Callback function */ -files.off = function (event, callback) { +files.off = (event, callback) => { if (!events[event]) return; events[event] = events[event].filter((cb) => cb !== callback); }; @@ -168,7 +168,7 @@ function getTree(treeList, dir) { */ function getFile(path, tree) { const { children } = tree; - let { url } = tree; + const { url } = tree; if (url === path) return tree; if (!children) return null; const len = children.length; diff --git a/src/lib/installPlugin.js b/src/lib/installPlugin.js index cddbe3614..c9a828cda 100644 --- a/src/lib/installPlugin.js +++ b/src/lib/installPlugin.js @@ -376,7 +376,7 @@ async function listFileRecursive(dir, files) { */ async function deleteRedundantFiles(pluginDir, state) { /** @type {string[]} */ - let files = []; + const files = []; await listFileRecursive(pluginDir, files); for (const file of files) { diff --git a/src/lib/loadPlugin.js b/src/lib/loadPlugin.js index dd968758d..93a23dd9c 100644 --- a/src/lib/loadPlugin.js +++ b/src/lib/loadPlugin.js @@ -30,7 +30,7 @@ export default async function loadPlugin(pluginId, justInstalled = false) { app.append($page); }; - $page.onhide = function () { + $page.onhide = () => { actionStack.remove(pluginId); }; diff --git a/src/lib/logger.js b/src/lib/logger.js index 60bdeea0d..e3d10942a 100644 --- a/src/lib/logger.js +++ b/src/lib/logger.js @@ -83,7 +83,7 @@ class Logger { logContent, ); } else { - let existingData = await fsOperation(logFilePath).readFile("utf8"); + const existingData = await fsOperation(logFilePath).readFile("utf8"); let newData = existingData + "\n" + logContent; // Check if the new data exceeds the maximum file size if (new Blob([newData]).size > this.#maxFileSize) { diff --git a/src/lib/openFile.js b/src/lib/openFile.js index 76102f7ce..672bae9e4 100644 --- a/src/lib/openFile.js +++ b/src/lib/openFile.js @@ -29,7 +29,7 @@ import appSettings from "./settings"; export default async function openFile(file, options = {}) { try { - let uri = typeof file === "string" ? file : file.uri; + const uri = typeof file === "string" ? file : file.uri; if (!uri) return; /**@type {EditorFile} */ diff --git a/src/lib/openFolder.js b/src/lib/openFolder.js index cbde5fa28..ac3eb72c6 100644 --- a/src/lib/openFolder.js +++ b/src/lib/openFolder.js @@ -475,7 +475,7 @@ function execOperation(type, action, url, $target, name) { if (helpers.isFile(type)) { $target.querySelector(":scope>span").className = helpers.getIconForFile(newName); - let file = editorManager.getFile(url, "uri"); + const file = editorManager.getFile(url, "uri"); if (file) { file.uri = newUrl; file.filename = newName; diff --git a/src/lib/polyfill.js b/src/lib/polyfill.js index 9a853d5bc..4df14bb9b 100644 --- a/src/lib/polyfill.js +++ b/src/lib/polyfill.js @@ -1,7 +1,7 @@ // polyfill for prepend -(function (arr) { - arr.forEach(function (item) { +((arr) => { + arr.forEach((item) => { if (item.hasOwnProperty("prepend")) { return; } @@ -13,7 +13,7 @@ var argArr = Array.prototype.slice.call(arguments), docFrag = document.createDocumentFragment(); - argArr.forEach(function (argItem) { + argArr.forEach((argItem) => { var node = argItem instanceof Node ? argItem @@ -29,8 +29,8 @@ // polyfill for closest -(function (arr) { - arr.forEach(function (item) { +((arr) => { + arr.forEach((item) => { if (item.hasOwnProperty("closest")) { return; } @@ -54,8 +54,8 @@ // polyfill for replaceWith -(function (arr) { - arr.forEach(function (item) { +((arr) => { + arr.forEach((item) => { if (item.hasOwnProperty("replaceWith")) { return; } @@ -93,8 +93,8 @@ // polyfill for toggleAttribute -(function (arr) { - arr.forEach(function (item) { +((arr) => { + arr.forEach((item) => { if (item.hasOwnProperty("toggleAttribute")) { return; } @@ -116,17 +116,17 @@ // polyfill for performance.now -(function () { +(() => { if ("performance" in window === false) { window.performance = {}; } Date.now = Date.now || - function () { + (() => { // thanks IE8 return new Date().getTime(); - }; + }); if ("now" in window.performance === false) { var nowOffset = Date.now(); diff --git a/src/lib/recents.js b/src/lib/recents.js index 9d99526c7..82d551871 100644 --- a/src/lib/recents.js +++ b/src/lib/recents.js @@ -87,8 +87,8 @@ const recents = { }; if (type === "dir" || type === "all") { - let dirs = this.folders; - for (let dir of dirs) { + const dirs = this.folders; + for (const dir of dirs) { const { url } = dir; all.push([ @@ -103,8 +103,8 @@ const recents = { } if (type === "file" || type === "all") { - let files = this.files; - for (let file of files) { + const files = this.files; + for (const file of files) { if (!file) continue; const name = shortName(Url.parse(file).url); all.push([ diff --git a/src/lib/remoteStorage.js b/src/lib/remoteStorage.js index 1050eaf80..6d95b858c 100644 --- a/src/lib/remoteStorage.js +++ b/src/lib/remoteStorage.js @@ -214,7 +214,7 @@ export default { if (exists) { await fs.writeFile(text); } else { - let fs = fsOperation(DATA_STORAGE); + const fs = fsOperation(DATA_STORAGE); await fs.createFile(filename, text); } } diff --git a/src/lib/settings.js b/src/lib/settings.js index 090bf94ab..de72097af 100644 --- a/src/lib/settings.js +++ b/src/lib/settings.js @@ -396,7 +396,7 @@ function areEqual(obj1, obj2) { if (obj1 == null || obj2 == null) return false; if (obj1.constructor !== obj2.constructor) return false; - for (let key in obj1) { + for (const key in obj1) { if (!obj2.hasOwnProperty(key)) return false; if (obj1[key] === obj2[key]) continue; if (typeof obj1[key] !== "object") return false; diff --git a/src/pages/about/about.js b/src/pages/about/about.js index 0d7019ee5..a3f673357 100644 --- a/src/pages/about/about.js +++ b/src/pages/about/about.js @@ -18,7 +18,7 @@ export default function AboutInclude() { action: $page.hide, }); - $page.onhide = function () { + $page.onhide = () => { actionStack.remove("about"); helpers.hideAd(); }; diff --git a/src/pages/changelog/changelog.js b/src/pages/changelog/changelog.js index fb5a21b85..f724083eb 100644 --- a/src/pages/changelog/changelog.js +++ b/src/pages/changelog/changelog.js @@ -31,7 +31,7 @@ export default async function Changelog() { $content.innerHTML = '
Failed to load changelog
'; } - $page.onhide = function () { + $page.onhide = () => { actionStack.remove("changelog"); }; diff --git a/src/pages/donate/donate.js b/src/pages/donate/donate.js index d44fd543e..c8aba6176 100644 --- a/src/pages/donate/donate.js +++ b/src/pages/donate/donate.js @@ -23,7 +23,7 @@ export default function DonateInclude() { action: $page.hide, }); - $page.onhide = function () { + $page.onhide = () => { actionStack.remove("donate page"); if (adShown) helpers.hideAd(); }; @@ -33,9 +33,9 @@ export default function DonateInclude() { iap.setPurchaseUpdatedListener( (purchases) => { if (Array.isArray(purchases)) { - (async function () { + (async () => { const promises = []; - for (let purchase of purchases) { + for (const purchase of purchases) { promises.push( new Promise((resolve, reject) => { iap.consume( @@ -85,7 +85,7 @@ export default function DonateInclude() { }, ); - app.onclick = function (e) { + app.onclick = (e) => { const $target = e.target; if (!($target instanceof HTMLElement)) return; const action = $target.getAttribute("action"); diff --git a/src/pages/fileBrowser/fileBrowser.js b/src/pages/fileBrowser/fileBrowser.js index 0e75e0c2b..33337d0a8 100644 --- a/src/pages/fileBrowser/fileBrowser.js +++ b/src/pages/fileBrowser/fileBrowser.js @@ -65,7 +65,7 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) { let storageList = JSON.parse(localStorage.storageList || "[]"); let isSelectionMode = false; - let selectedItems = new Set(); + const selectedItems = new Set(); if (!info) { if (mode !== "both") { @@ -149,7 +149,7 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) { $selectionMenuToggler.style.display = "none"; const progress = {}; - let cachedDir = {}; + const cachedDir = {}; let currentDir = { url: null, name: null, @@ -208,12 +208,12 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) { action: close, }); - $selectionModeToggler.onclick = function () { + $selectionModeToggler.onclick = () => { isSelectionMode = !isSelectionMode; toggleSelectionMode(isSelectionMode); }; - $fbMenu.onclick = function (e) { + $fbMenu.onclick = (e) => { $fbMenu.hide(); const action = e.target.getAttribute("action"); if (action === "settings") { @@ -271,7 +271,7 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) { } case "import-project-zip": { - let zipFile = await new Promise((resolve, reject) => { + const zipFile = await new Promise((resolve, reject) => { sdcard.openDocumentFile( (res) => { resolve(res.uri); @@ -361,7 +361,7 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) { } const zip = new JSZip(); - let loadingLoader = loader.create( + const loadingLoader = loader.create( strings["loading"], "Compressing files", { @@ -507,12 +507,12 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) { } }; - $search.onclick = function () { + $search.onclick = () => { const $list = $content.get("#list"); if ($list) searchBar($list, (hide) => (hideSearchBar = hide)); }; - $page.onhide = function () { + $page.onhide = () => { hideSearchBar(); helpers.hideAd(); actionStack.clearFromMark(); @@ -728,7 +728,7 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) { const { url: parsedUrl, query } = Url.parse(url); let path = ""; - for (let dir of dirs) { + for (const dir of dirs) { path = Url.join(path, dir); navigationArray.push({ url: `${Url.join(parsedUrl, path, "")}${query}`, @@ -824,7 +824,7 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) { case "open_with": try { - let mimeType = mimeTypes.lookup(name || "text/plain"); + const mimeType = mimeTypes.lookup(name || "text/plain"); const fs = fsOperation(url); if (/^s?ftp:/.test(url)) return fs.localName; @@ -1049,7 +1049,7 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) { } catch (err) {} storageList.forEach((storage) => { - let url = storage.url || /**@deprecated */ storage["uri"]; + const url = storage.url || /**@deprecated */ storage["uri"]; util.pushFolder(allStorages, storage.name, url, { storageType: storage.storageType, diff --git a/src/pages/plugin/plugin.js b/src/pages/plugin/plugin.js index 716f86bba..02947904c 100644 --- a/src/pages/plugin/plugin.js +++ b/src/pages/plugin/plugin.js @@ -58,7 +58,7 @@ export default async function PluginInclude( action: $page.hide, }); - $page.onhide = function () { + $page.onhide = () => { helpers.hideAd(); actionStack.remove("plugin"); loader.removeTitleLoader(); diff --git a/src/pages/plugin/plugin.view.js b/src/pages/plugin/plugin.view.js index c51592f5a..2192391b4 100644 --- a/src/pages/plugin/plugin.view.js +++ b/src/pages/plugin/plugin.view.js @@ -143,7 +143,7 @@ export default (props) => { >
{(() => { - let contributorsList = contributors?.length + const contributorsList = contributors?.length ? [ { name: author, role: "Developer", github: authorGithub }, ...contributors, @@ -421,8 +421,8 @@ function Review({ author_reply: authorReply, }) { let dp = Url.join(constants.API_BASE, `../user.png`); - let voteImage = new Ref(); - let review = new Ref(); + const voteImage = new Ref(); + const review = new Ref(); if (github) { dp = `https://avatars.githubusercontent.com/${github}`; diff --git a/src/pages/problems/problems.js b/src/pages/problems/problems.js index df7156ffa..f9aadcd79 100644 --- a/src/pages/problems/problems.js +++ b/src/pages/problems/problems.js @@ -63,7 +63,7 @@ export default function Problems() { app.append($page); helpers.showAd(); - $page.onhide = function () { + $page.onhide = () => { helpers.hideAd(); actionStack.remove("problems"); }; diff --git a/src/settings/backupRestore.js b/src/settings/backupRestore.js index 1e28f466c..7557d1432 100644 --- a/src/settings/backupRestore.js +++ b/src/settings/backupRestore.js @@ -102,9 +102,9 @@ function backupRestore() { } } -backupRestore.restore = async function (url) { +backupRestore.restore = async (url) => { try { - let fs = fsOperation(url); + const fs = fsOperation(url); let backup = await fs.readFile("utf8"); try { diff --git a/src/sidebarApps/searchInFiles/index.js b/src/sidebarApps/searchInFiles/index.js index 8ab82a162..3925a646e 100644 --- a/src/sidebarApps/searchInFiles/index.js +++ b/src/sidebarApps/searchInFiles/index.js @@ -688,7 +688,7 @@ function Textarea({ name, placeholder, ref }) { function toRegex(search, options) { const { caseSensitive = false, wholeWord = false, regExp = false } = options; - let flags = caseSensitive ? "gm" : "gim"; + const flags = caseSensitive ? "gm" : "gim"; let regexString = regExp ? search : escapeStringRegexp(search); if (wholeWord) { diff --git a/src/sidebarApps/searchInFiles/searchResultMode.js b/src/sidebarApps/searchInFiles/searchResultMode.js index 2260c502f..1e06316a3 100644 --- a/src/sidebarApps/searchInFiles/searchResultMode.js +++ b/src/sidebarApps/searchInFiles/searchResultMode.js @@ -10,7 +10,7 @@ ace.define( "ace/lib/oop", "ace/mode/text_highlight_rules", ], - function (require, exports, module) { + (require, exports, module) => { const oop = require("../lib/oop"); const { TextHighlightRules } = require("./text_highlight_rules"); @@ -120,7 +120,7 @@ define("ace/mode/folding/search_result_fold", [ "ace/lib/oop", "ace/mode/folding/fold_mode", "ace/range", -], function (require, exports, module) { +], (require, exports, module) => { const oop = require("ace/lib/oop"); const { FoldMode: BaseFoldMode } = require("./fold_mode"); const { Range } = require("ace/range"); @@ -153,7 +153,7 @@ define("ace/mode/folding/search_result_fold", [ return new Range(startRow, startColumn, endRow, endColumn); } }; - this.getFoldWidget = function (session, foldStyle, row) { + this.getFoldWidget = (session, foldStyle, row) => { var line = session.getLine(row); var indent = line.search(/\S/); var next = session.getLine(row + 1); @@ -206,7 +206,7 @@ ace.define( "ace/mode/folding/search_result_fold", "ace/search_result_highlight_rules", ], - function (require, exports, module) { + (require, exports, module) => { const oop = require("ace/lib/oop"); const { Mode: TextMode } = require("./text"); const { SearchHighlightRules } = require("./search_result_highlight_rules"); diff --git a/src/sidebarApps/searchInFiles/worker.js b/src/sidebarApps/searchInFiles/worker.js index 3798715fc..fec2200f7 100644 --- a/src/sidebarApps/searchInFiles/worker.js +++ b/src/sidebarApps/searchInFiles/worker.js @@ -139,11 +139,11 @@ function getSurrounding(content, word, start, end) { word = word.slice(-max); result = [`...${word}`, word]; } else { - let left = Math.floor(remaining / 2); - let right = left; + const left = Math.floor(remaining / 2); + const right = left; - let leftText = content.substring(start - left, start); - let rightText = content.substring(end, end + right); + const leftText = content.substring(start - left, start); + const rightText = content.substring(end, end + right); result = [`${leftText}${word}${rightText}`, word]; } diff --git a/src/utils/Path.js b/src/utils/Path.js index dd5d9f126..9b2370db4 100644 --- a/src/utils/Path.js +++ b/src/utils/Path.js @@ -83,7 +83,7 @@ export default { * @param {...string} paths */ join(...paths) { - let res = paths.join("/"); + const res = paths.join("/"); return this.normalize(res); }, @@ -170,7 +170,7 @@ resolvePath('path/to/some/dir/', '../../dir') //returns 'path/to/dir' const p2len = path2.length; let flag = false; - let path = []; + const path = []; path1.forEach((dir, i) => { if (dir === path2[i] && !flag) return; diff --git a/src/utils/Uri.js b/src/utils/Uri.js index 195ab1762..5aca061cc 100644 --- a/src/utils/Uri.js +++ b/src/utils/Uri.js @@ -84,7 +84,7 @@ export default { const storageList = JSON.parse(localStorage.storageList || "[]"); const matches = []; - for (let storage of storageList) { + for (const storage of storageList) { const regex = new RegExp( "^" + escapeStringRegexp(storage.uri ?? storage.url), ); diff --git a/src/utils/Url.js b/src/utils/Url.js index 34bca3043..c8bbaf0b6 100644 --- a/src/utils/Url.js +++ b/src/utils/Url.js @@ -105,7 +105,7 @@ export default { * @returns {string} */ safe(url) { - let { url: uri, query } = this.parse(url); + const { url: uri, query } = this.parse(url); url = uri; const protocol = (this.PROTOCOL_PATTERN.exec(url) || [])[0] || ""; if (protocol) url = url.replace(new RegExp("^" + protocol), ""); @@ -116,9 +116,10 @@ export default { return protocol + parts.join("/") + query; function fixedEncodeURIComponent(str) { - return encodeURIComponent(str).replace(/[!'()*]/g, function (c) { - return "%" + c.charCodeAt(0).toString(16); - }); + return encodeURIComponent(str).replace( + /[!'()*]/g, + (c) => "%" + c.charCodeAt(0).toString(16), + ); } }, /** @@ -232,7 +233,7 @@ export default { if (query && typeof query === "object") { string += "?"; - for (let key in query) string += `${enc(key)}=${enc(query[key])}&`; + for (const key in query) string += `${enc(key)}=${enc(query[key])}&`; string = string.slice(0, -1); } @@ -294,7 +295,7 @@ export default { port = Number.parseInt(port); } - let { keyFile, passPhrase } = query; + const { keyFile, passPhrase } = query; if (keyFile) { query.keyFile = decodeURIComponent(keyFile); diff --git a/src/utils/color/hsl.js b/src/utils/color/hsl.js index ddb7769bd..90c20ba3e 100644 --- a/src/utils/color/hsl.js +++ b/src/utils/color/hsl.js @@ -111,9 +111,9 @@ export default class Hsl { } // now convert hsl value to rgb - let c = (1 - Math.abs(2 * this.l - 1)) * this.s; - let x = c * (1 - Math.abs(((this.h * 6) % 2) - 1)); - let m = this.l - c / 2; + const c = (1 - Math.abs(2 * this.l - 1)) * this.s; + const x = c * (1 - Math.abs(((this.h * 6) % 2) - 1)); + const m = this.l - c / 2; let r = 0; let g = 0; let b = 0; diff --git a/src/utils/encodings.js b/src/utils/encodings.js index fbe122df6..84d061b77 100644 --- a/src/utils/encodings.js +++ b/src/utils/encodings.js @@ -1,7 +1,7 @@ import alert from "dialogs/alert"; import settings from "lib/settings"; -let encodings = {}; +const encodings = {}; /** * @typedef {Object} Encoding diff --git a/src/utils/helpers.js b/src/utils/helpers.js index f70fdf776..65bb83fe6 100644 --- a/src/utils/helpers.js +++ b/src/utils/helpers.js @@ -265,7 +265,7 @@ export default { const files = editorManager.files; const { url } = Url.parse(oldUrl); - for (let file of files) { + for (const file of files) { if (!file.uri) continue; const fileUrl = Url.parse(file.uri).url; if (new RegExp("^" + escapeStringRegexp(url)).test(fileUrl)) { diff --git a/src/utils/keyboardEvent.js b/src/utils/keyboardEvent.js index 3eabdd098..6c5c49776 100644 --- a/src/utils/keyboardEvent.js +++ b/src/utils/keyboardEvent.js @@ -37,7 +37,7 @@ const keys = { 46: "Delete", }; -const initKeyboardEventType = (function (event) { +const initKeyboardEventType = ((event) => { try { event.initKeyboardEvent( "keyup", // in DOMString typeArg @@ -98,11 +98,11 @@ const own = Function.prototype.call.bind(Object.prototype.hasOwnProperty); const ObjectDefineProperty = Object.defineProperty || - function (obj, prop, val) { + ((obj, prop, val) => { if ("value" in val) { obj[prop] = val["value"]; } - }; + }); /** * Creates a keyboard event @@ -120,7 +120,7 @@ export default function KeyboardEvent(type, dict) { } let propName; - let localDict = {}; + const localDict = {}; if (!dict.key && (dict.keyCode || dict.which)) { let key = keys[dict.keyCode || dict.which]; diff --git a/src/utils/polyfill.js b/src/utils/polyfill.js index 695c56ce2..1d4707df5 100644 --- a/src/utils/polyfill.js +++ b/src/utils/polyfill.js @@ -39,7 +39,7 @@ export default function loadPolyFill() { if (!HTMLElement.prototype.getParent) { HTMLElement.prototype.getParent = function (queryString) { const $$ = [...document.querySelectorAll(queryString)]; - for (let $ of $$) if ($.contains(this)) return $; + for (const $ of $$) if ($.contains(this)) return $; return null; }; } diff --git a/utils/config.js b/utils/config.js index 93448eb87..187047100 100755 --- a/utils/config.js +++ b/utils/config.js @@ -35,7 +35,7 @@ const exec = promisify(require("node:child_process").exec); let babelrcText = fs.readFileSync(babelrcpath, "utf-8"); let config = fs.readFileSync(configpath, "utf-8"); let html = fs.readFileSync(htmlpath, "utf-8"); - let platforms = fs + const platforms = fs .readdirSync(platformsDir) .filter((file) => !file.startsWith(".")); let logo, id, currentId; @@ -70,7 +70,7 @@ const exec = promisify(require("node:child_process").exec); fs.writeFileSync(logopath, logo, "utf8"); fs.writeFileSync(configpath, config, "utf8"); - for (let platform of platforms) { + for (const platform of platforms) { if (!platform) continue; promises.push( @@ -80,23 +80,23 @@ const exec = promisify(require("node:child_process").exec); ); if (id === ID_FREE) { - console.log(`|--- Installing Admob ---|`); + console.log("|--- Installing Admob ---|"); await exec( - `cordova plugin add cordova-plugin-consent@2.4.0 --save`, + "cordova plugin add cordova-plugin-consent@2.4.0 --save", ); await exec( `cordova plugin add admob-plus-cordova@1.28.0 --save --variable APP_ID_ANDROID="${AD_APP_ID}" --variable PLAY_SERVICES_VERSION="21.5.0"`, ); console.log("DONE! Installing admob-plus-cordova"); } else { - console.log(`|--- Removing Admob ---|`); - await exec(`cordova plugin remove cordova-plugin-consent --save`); - await exec(`cordova plugin remove admob-plus-cordova --save`); + console.log("|--- Removing Admob ---|"); + await exec("cordova plugin remove cordova-plugin-consent --save"); + await exec("cordova plugin remove admob-plus-cordova --save"); console.log("DONE! Removing admob-plus-cordova"); } - console.log(`|--- Reinstalling platform ---|`); - const { stderr } = await exec(`yarn clean`); + console.log("|--- Reinstalling platform ---|"); + const { stderr } = await exec("yarn clean"); if (stderr) console.error(stderr); else console.log("DONE! Reinstalling platform"); })(), diff --git a/utils/lang.js b/utils/lang.js index b6af02506..38928ba2f 100755 --- a/utils/lang.js +++ b/utils/lang.js @@ -68,7 +68,7 @@ async function update() { if (file === "en-us.json") return; let flagError = false; - let langFile = path.join(dir, file); + const langFile = path.join(dir, file); const exit = (i, len) => { if (i + 1 === len) { if (!error) { @@ -85,7 +85,7 @@ async function update() { return; } - let langError = () => { + const langError = () => { if (!flagError) { error = true; flagError = true; @@ -95,7 +95,7 @@ async function update() { const langData = JSON.parse(data); flagError = false; - for (let enKey in enLangData) { + for (const enKey in enLangData) { const key = Object.keys(langData).find((k) => { try { if (new RegExp(`^${escapeRegExp(k)}$`, "i").test(enKey)) { diff --git a/utils/loadStyles.js b/utils/loadStyles.js index cfe038dab..f40af0e50 100644 --- a/utils/loadStyles.js +++ b/utils/loadStyles.js @@ -9,7 +9,7 @@ const cssFiles = fs.readdirSync(CSS).filter((file) => file.endsWith(".css")); const htmlFiles = fs.readdirSync(WWW).filter((file) => file.endsWith(".html")); try { - for (let htmlFile of htmlFiles) { + for (const htmlFile of htmlFiles) { loadStyles(path.resolve(WWW, htmlFile)); } } catch (error) { @@ -27,7 +27,7 @@ process.exit(0); function loadStyles(htmlFile) { let styles = ""; - for (let cssFile of cssFiles) { + for (const cssFile of cssFiles) { styles += `\n`; }