Skip to content

Commit

Permalink
fix app-dev lint warnings (#1827)
Browse files Browse the repository at this point in the history
  • Loading branch information
zenz34 authored Feb 18, 2021
1 parent a822107 commit 7ce85aa
Show file tree
Hide file tree
Showing 18 changed files with 42 additions and 33 deletions.
11 changes: 10 additions & 1 deletion packages/xarc-app-dev/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -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"
}
};
2 changes: 1 addition & 1 deletion packages/xarc-app-dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion packages/xarc-app-dev/src/config/karma/karma.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion packages/xarc-app-dev/src/config/karma/karma.conf.watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions packages/xarc-app-dev/src/config/opt2/babel-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand All @@ -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`**
Expand Down
2 changes: 1 addition & 1 deletion packages/xarc-app-dev/src/config/opt2/webpack-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions packages/xarc-app-dev/src/config/opt2/xarc-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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
Expand All @@ -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.
*
Expand Down
4 changes: 2 additions & 2 deletions packages/xarc-app-dev/src/lib/babel-run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
5 changes: 3 additions & 2 deletions packages/xarc-app-dev/src/lib/dev-admin/console-io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
});
});
}
Expand Down
10 changes: 4 additions & 6 deletions packages/xarc-app-dev/src/lib/dev-admin/log-view.js
Original file line number Diff line number Diff line change
@@ -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 */
Expand Down Expand Up @@ -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(() => {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -385,7 +383,7 @@ window.addEventListener(
false
);

window.addEventListener("keypress", (event) => {
window.addEventListener("keypress", event => {
if (event.ctrlKey && event.code === "KeyK") {
wipeLogs();
}
Expand Down
7 changes: 4 additions & 3 deletions packages/xarc-app-dev/src/lib/dev-admin/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export class Middleware {

this.returnReporter = undefined;

defaultReporter = (middlewareOptions, reporterOptions) => {
defaultReporter = (_middlewareOptions, reporterOptions) => {
if (!reporterOptions.state) {
process.send({
name: "webpack-report",
Expand Down Expand Up @@ -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, ""));
});
});
}
Expand Down
8 changes: 4 additions & 4 deletions packages/xarc-app-dev/src/lib/dev-admin/redbird-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}─<green>${formUrl({
Expand All @@ -78,7 +78,7 @@ const buildProxyTree = (options, ports) => {
return ck`<orange>${formUrl({ protocol, host, port })}</> (proxy) \n${portTree}`;
};

const onExitRequest = (req, res) => {
const onExitRequest = (_req, res) => {
res.statusCode = 200;
res.write(`<!DOCTYPE html>
<html><head></head><body>
Expand All @@ -92,7 +92,7 @@ const onExitRequest = (req, res) => {
return false;
};

const onStatusRequest = (req, res) => {
const onStatusRequest = (_req, res) => {
res.statusCode = 200;
res.write(`<!DOCTYPE html>
<html><head></head><body>
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion packages/xarc-app-dev/src/lib/dev-admin/redbird-spawn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class WebpackDevRelay {
}
}

receiveAppServerMessage(data) {}
receiveAppServerMessage(_data) {}

_setServer(name, child, handlers = undefined) {
const info = this._servers[name];
Expand Down
2 changes: 1 addition & 1 deletion packages/xarc-app-dev/src/lib/dev-tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion packages/xarc-app-dev/src/lib/stats-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function escapeHtml(html) {
"<": "&lt;",
">": "&gt;"
};
return html.replace(/([<>])/g, (m, a) => htmlMap[a]);
return html.replace(/([<>])/g, (_m, a) => htmlMap[a]);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/xarc-app-dev/src/lib/tasks/package-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7ce85aa

Please sign in to comment.