From 7ce85aa536810f685d096a1b0f22a403d17d26dd Mon Sep 17 00:00:00 2001 From: ZenZ Date: Thu, 18 Feb 2021 13:52:28 -0800 Subject: [PATCH] fix app-dev lint warnings (#1827) --- packages/xarc-app-dev/.eslintrc.js | 11 ++++++++++- packages/xarc-app-dev/package.json | 2 +- .../src/config/karma/karma.conf.coverage.ts | 2 +- packages/xarc-app-dev/src/config/karma/karma.conf.ts | 2 +- .../xarc-app-dev/src/config/karma/karma.conf.watch.ts | 2 +- .../xarc-app-dev/src/config/opt2/babel-options.ts | 4 ++-- .../xarc-app-dev/src/config/opt2/webpack-options.ts | 2 +- packages/xarc-app-dev/src/config/opt2/xarc-options.ts | 6 +++--- packages/xarc-app-dev/src/lib/babel-run.ts | 4 ++-- packages/xarc-app-dev/src/lib/dev-admin/console-io.ts | 5 +++-- packages/xarc-app-dev/src/lib/dev-admin/log-view.js | 10 ++++------ packages/xarc-app-dev/src/lib/dev-admin/middleware.ts | 7 ++++--- .../xarc-app-dev/src/lib/dev-admin/redbird-proxy.ts | 8 ++++---- .../xarc-app-dev/src/lib/dev-admin/redbird-spawn.ts | 2 +- .../src/lib/dev-admin/webpack-dev-relay.ts | 2 +- packages/xarc-app-dev/src/lib/dev-tasks.ts | 2 +- packages/xarc-app-dev/src/lib/stats-utils.ts | 2 +- packages/xarc-app-dev/src/lib/tasks/package-json.ts | 2 +- 18 files changed, 42 insertions(+), 33 deletions(-) diff --git a/packages/xarc-app-dev/.eslintrc.js b/packages/xarc-app-dev/.eslintrc.js index bbb4f0e07..f75d944e7 100644 --- a/packages/xarc-app-dev/.eslintrc.js +++ b/packages/xarc-app-dev/.eslintrc.js @@ -1,4 +1,13 @@ const { eslintRcNodeTypeScript } = require("@xarc/module-dev"); module.exports = { - extends: eslintRcNodeTypeScript + extends: eslintRcNodeTypeScript, + plugins: ["jsdoc"], + rules: { + // disable the rule for all files + "@typescript-eslint/explicit-module-boundary-types": "off", + "jsdoc/require-param-type": "off", + "no-magic-numbers": "off", + "global-require": "off", + "jsdoc/require-returns-type": "off" + } }; diff --git a/packages/xarc-app-dev/package.json b/packages/xarc-app-dev/package.json index 67578898a..33d8360d7 100644 --- a/packages/xarc-app-dev/package.json +++ b/packages/xarc-app-dev/package.json @@ -117,7 +117,7 @@ "eslint": "^7.16.0", "eslint-config-walmart": "^2.2.1", "eslint-plugin-filenames": "^1.1.0", - "eslint-plugin-jsdoc": "^30.7.9", + "eslint-plugin-jsdoc": "^32.0.2", "mocha": "^8.2.1", "mock-require": "^3.0.3", "nyc": "^15.1.0", diff --git a/packages/xarc-app-dev/src/config/karma/karma.conf.coverage.ts b/packages/xarc-app-dev/src/config/karma/karma.conf.coverage.ts index 2a2b58e9b..c0192ff15 100644 --- a/packages/xarc-app-dev/src/config/karma/karma.conf.coverage.ts +++ b/packages/xarc-app-dev/src/config/karma/karma.conf.coverage.ts @@ -21,7 +21,7 @@ const webpackCovCfg = require(customCheck.getWebpackStartConfig( * Get Karma config for coverage * * @param config base config - * @returns karma config + * @returns {void} void */ export = function(config): any { const xarcOptions = loadXarcOptions(); diff --git a/packages/xarc-app-dev/src/config/karma/karma.conf.ts b/packages/xarc-app-dev/src/config/karma/karma.conf.ts index bfd126b86..5b465b1b6 100644 --- a/packages/xarc-app-dev/src/config/karma/karma.conf.ts +++ b/packages/xarc-app-dev/src/config/karma/karma.conf.ts @@ -97,7 +97,7 @@ function loadWebpackConfig() { * get karma config * * @param config - * @returns karma config + * @returns {void} karma config */ export = function getKarmaConfig(config): any { let plugins = getXarcOptPlugins() || getArchetypeOptPlugins(); diff --git a/packages/xarc-app-dev/src/config/karma/karma.conf.watch.ts b/packages/xarc-app-dev/src/config/karma/karma.conf.watch.ts index c5d9f33f9..5cb321118 100644 --- a/packages/xarc-app-dev/src/config/karma/karma.conf.watch.ts +++ b/packages/xarc-app-dev/src/config/karma/karma.conf.watch.ts @@ -12,7 +12,7 @@ import { loadUserConfig } from "./util/load-user-config"; * Karma config for watching mode * * @param config - * @returns karma config + * @returns {void} karma config */ export = function(config) { dev(config); diff --git a/packages/xarc-app-dev/src/config/opt2/babel-options.ts b/packages/xarc-app-dev/src/config/opt2/babel-options.ts index ab5c4933d..941542f9d 100644 --- a/packages/xarc-app-dev/src/config/opt2/babel-options.ts +++ b/packages/xarc-app-dev/src/config/opt2/babel-options.ts @@ -7,7 +7,7 @@ export type BabelOptions = { /** * enable support for typescript types using `@babel/preset-typescript` * - * @remarks + * "@remarks" * transpile only, no type checking * * - **Default: true** @@ -18,7 +18,7 @@ export type BabelOptions = { /** * Enable support for stripping flow.js types using `@babel/plugin-transform-flow-strip-types` * - * @remarks + * "@remarks" * transpile only, no type checking * * - **Default: `false`** diff --git a/packages/xarc-app-dev/src/config/opt2/webpack-options.ts b/packages/xarc-app-dev/src/config/opt2/webpack-options.ts index da1b149e1..a5c34e071 100644 --- a/packages/xarc-app-dev/src/config/opt2/webpack-options.ts +++ b/packages/xarc-app-dev/src/config/opt2/webpack-options.ts @@ -81,7 +81,7 @@ export type WebpackOptions = { * - **Default: `false`** * - If not set, then check env `ENABLE_NODESOURCE_PLUGIN` * - * @remarks + * "@remarks" * This will bundle 100K+ of JavaScript to simulate node.js env */ enableNodeSourcePlugin?: boolean; diff --git a/packages/xarc-app-dev/src/config/opt2/xarc-options.ts b/packages/xarc-app-dev/src/config/opt2/xarc-options.ts index 1f95213cd..d8cb904b3 100644 --- a/packages/xarc-app-dev/src/config/opt2/xarc-options.ts +++ b/packages/xarc-app-dev/src/config/opt2/xarc-options.ts @@ -18,7 +18,7 @@ export type XarcOptions = { /** * port to listen on for serving your application * - * @remarks + * "@remarks" * In development, this is what the dev proxy listens on. Your app server * listens on `appServerPort` that the proxy forwards to. * @@ -31,7 +31,7 @@ export type XarcOptions = { * - Set it to `-1` to disable `http` and use `httpsPort` to listen on `https` only. * - If not set, then check env `PORT` * - * @remarks Regarding `HTTPS`: + * "@remarks" Regarding `HTTPS`: * - If you want full control of `https` and `http` ports, set `httpsPort` and `port`. * - If you set `port` to `443` or `8443`, then dev proxy do `https` on that port, and * listens on something that doesn't conflict with `appServerPort`, which is @@ -50,7 +50,7 @@ export type XarcOptions = { * - Set it to `0` and the proxy will pick a random port for `https`. * - Set to `-1` to force disable `https` * - * @remarks + * "@remarks" * If this is set, it cannot be the same as `port`, which then will be * forced to be `http` only. * diff --git a/packages/xarc-app-dev/src/lib/babel-run.ts b/packages/xarc-app-dev/src/lib/babel-run.ts index 7170302bd..4a0b32a55 100644 --- a/packages/xarc-app-dev/src/lib/babel-run.ts +++ b/packages/xarc-app-dev/src/lib/babel-run.ts @@ -32,8 +32,8 @@ try { require("@babel/register")({ only: [ x => { - x = Path.normalize(x); - return x.startsWith(cwd) && !x.startsWith(cwdNM); + const y = Path.normalize(x); + return y.startsWith(cwd) && !y.startsWith(cwdNM); } ], extensions: [".js", ".jsx"] diff --git a/packages/xarc-app-dev/src/lib/dev-admin/console-io.ts b/packages/xarc-app-dev/src/lib/dev-admin/console-io.ts index 8dbc8c337..7e3d7214e 100644 --- a/packages/xarc-app-dev/src/lib/dev-admin/console-io.ts +++ b/packages/xarc-app-dev/src/lib/dev-admin/console-io.ts @@ -20,10 +20,11 @@ export class ConsoleIO extends VisualLogger { async getUserInput() { return new Promise(resolve => { process.stdin.once("keypress", (str, key) => { + let strVal = str; if (key.ctrl && key.name === "c") { - str = "^c"; + strVal = "^c"; } - resolve({ str: str && str.toLowerCase(), key }); + resolve({ str: strVal && strVal.toLowerCase(), key }); }); }); } diff --git a/packages/xarc-app-dev/src/lib/dev-admin/log-view.js b/packages/xarc-app-dev/src/lib/dev-admin/log-view.js index 7b7e8623f..91209524e 100644 --- a/packages/xarc-app-dev/src/lib/dev-admin/log-view.js +++ b/packages/xarc-app-dev/src/lib/dev-admin/log-view.js @@ -1,5 +1,3 @@ - - /* eslint-disable no-magic-numbers, no-use-before-define, no-unused-vars */ /* eslint-disable no-console, max-statements, no-param-reassign, complexity */ /* global window, document, EventSource, fetch */ @@ -32,11 +30,11 @@ function startLogStream() { const data = JSON.parse(e.data); updateLogs(data); }); - logStream.addEventListener("open", e => { + logStream.addEventListener("open", _e => { console.log("log stream opened"); logStreamReconnectDelay = 5000; }); - logStream.addEventListener("error", (e, a) => { + logStream.addEventListener("error", (e, _a) => { console.log("log stream connect error", e); close(); logStreamReconnectTimer = setTimeout(() => { @@ -200,7 +198,7 @@ function levelChangeHandler() { * @param levelSelections * @param scrollToEnd */ -function refreshLogs(levelSelections, scrollToEnd = true) { +function refreshLogs(levelSelections, _scrollToEnd = true) { levelSelections = levelSelections || getLevelSelections(); for (let line = logDisplayElement.firstChild; line !== null; line = line.nextSibling) { @@ -385,7 +383,7 @@ window.addEventListener( false ); -window.addEventListener("keypress", (event) => { +window.addEventListener("keypress", event => { if (event.ctrlKey && event.code === "KeyK") { wipeLogs(); } diff --git a/packages/xarc-app-dev/src/lib/dev-admin/middleware.ts b/packages/xarc-app-dev/src/lib/dev-admin/middleware.ts index 254169fb3..9319b8a1b 100644 --- a/packages/xarc-app-dev/src/lib/dev-admin/middleware.ts +++ b/packages/xarc-app-dev/src/lib/dev-admin/middleware.ts @@ -193,7 +193,7 @@ export class Middleware { this.returnReporter = undefined; - defaultReporter = (middlewareOptions, reporterOptions) => { + defaultReporter = (_middlewareOptions, reporterOptions) => { if (!reporterOptions.state) { process.send({ name: "webpack-report", @@ -242,8 +242,9 @@ export class Middleware { if (m.startsWith("multi ")) return; // webpack4 output like "./routes.jsx + 9 modules" const plusIx = m.indexOf(" + "); - if (plusIx > 0) m = m.substring(0, plusIx); - refreshModules.push(m.replace(cwd, "")); + let n = m; + if (plusIx > 0) n = m.substring(0, plusIx); + refreshModules.push(n.replace(cwd, "")); }); }); } diff --git a/packages/xarc-app-dev/src/lib/dev-admin/redbird-proxy.ts b/packages/xarc-app-dev/src/lib/dev-admin/redbird-proxy.ts index 2ed73b295..f7e4f9d55 100644 --- a/packages/xarc-app-dev/src/lib/dev-admin/redbird-proxy.ts +++ b/packages/xarc-app-dev/src/lib/dev-admin/redbird-proxy.ts @@ -59,7 +59,7 @@ const getNotFoundPage = data => { }; // eslint-disable-next-line max-params -const getLineForTree = (protocol, host) => (tree, [envVarName, port], idx, arr) => { +const getLineForTree = (_rotocol, host) => (tree, [envVarName, port], idx, arr) => { const boxChar = idx === arr.length - 1 ? "└" : "├"; const portText = envVarName.replace(/port/gi, ""); return ck`${tree} ${boxChar}─${formUrl({ @@ -78,7 +78,7 @@ const buildProxyTree = (options, ports) => { return ck`${formUrl({ protocol, host, port })} (proxy) \n${portTree}`; }; -const onExitRequest = (req, res) => { +const onExitRequest = (_req, res) => { res.statusCode = 200; res.write(` @@ -92,7 +92,7 @@ const onExitRequest = (req, res) => { return false; }; -const onStatusRequest = (req, res) => { +const onStatusRequest = (_req, res) => { res.statusCode = 200; res.write(` @@ -186,7 +186,7 @@ const registerElectrodeDevRules = ({ ssl, src: formUrl({ protocol, host, path: controlPaths.restart }), target: `http://localhost:29999/skip`, - onRequest: (req, res) => { + onRequest: (_req, res) => { res.statusCode = 200; res.write(`restarted`); res.end(); diff --git a/packages/xarc-app-dev/src/lib/dev-admin/redbird-spawn.ts b/packages/xarc-app-dev/src/lib/dev-admin/redbird-spawn.ts index c49b3b473..a24feb18c 100644 --- a/packages/xarc-app-dev/src/lib/dev-admin/redbird-spawn.ts +++ b/packages/xarc-app-dev/src/lib/dev-admin/redbird-spawn.ts @@ -52,7 +52,7 @@ const handleRestart = type => { ...httpDevServer, path: controlPaths.restart }); - request(restartUrl, (err, res, body) => { + request(restartUrl, (err, _res, body) => { if (!err) { console.log(body); } else { diff --git a/packages/xarc-app-dev/src/lib/dev-admin/webpack-dev-relay.ts b/packages/xarc-app-dev/src/lib/dev-admin/webpack-dev-relay.ts index 330f5beb7..e1ea413fd 100644 --- a/packages/xarc-app-dev/src/lib/dev-admin/webpack-dev-relay.ts +++ b/packages/xarc-app-dev/src/lib/dev-admin/webpack-dev-relay.ts @@ -55,7 +55,7 @@ export class WebpackDevRelay { } } - receiveAppServerMessage(data) {} + receiveAppServerMessage(_data) {} _setServer(name, child, handlers = undefined) { const info = this._servers[name]; diff --git a/packages/xarc-app-dev/src/lib/dev-tasks.ts b/packages/xarc-app-dev/src/lib/dev-tasks.ts index 4e612dedb..3acaf7832 100644 --- a/packages/xarc-app-dev/src/lib/dev-tasks.ts +++ b/packages/xarc-app-dev/src/lib/dev-tasks.ts @@ -397,7 +397,7 @@ ie >= 11 }); }; - const makeBabelConfig = (destDir, rcFile, resultFile = "babel.config.js") => { + const makeBabelConfig = (destDir, _rcFile, resultFile = "babel.config.js") => { destDir = Path.resolve(xarcCwd, destDir); const files = [".babelrc.js", resultFile]; diff --git a/packages/xarc-app-dev/src/lib/stats-utils.ts b/packages/xarc-app-dev/src/lib/stats-utils.ts index f9f30680a..78c513085 100644 --- a/packages/xarc-app-dev/src/lib/stats-utils.ts +++ b/packages/xarc-app-dev/src/lib/stats-utils.ts @@ -11,7 +11,7 @@ export function escapeHtml(html) { "<": "<", ">": ">" }; - return html.replace(/([<>])/g, (m, a) => htmlMap[a]); + return html.replace(/([<>])/g, (_m, a) => htmlMap[a]); } /** diff --git a/packages/xarc-app-dev/src/lib/tasks/package-json.ts b/packages/xarc-app-dev/src/lib/tasks/package-json.ts index ea1d9d7e9..5f0a65a51 100644 --- a/packages/xarc-app-dev/src/lib/tasks/package-json.ts +++ b/packages/xarc-app-dev/src/lib/tasks/package-json.ts @@ -66,7 +66,7 @@ import { logger } from "../logger"; * Update app's dependencies * * @param xarcCwd - CWD for app - * @returns nothing + * @returns {void} nothing */ export const updateAppDep = (xarcCwd: string) => { const appPkg = loadPkgJson(xarcCwd);