Skip to content

Commit

Permalink
Update packages. Update eslint rules.
Browse files Browse the repository at this point in the history
  • Loading branch information
TychoTheTaco committed Aug 5, 2022
1 parent b442b5f commit fe42515
Show file tree
Hide file tree
Showing 16 changed files with 626 additions and 683 deletions.
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

4 changes: 3 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ module.exports = {
"eslint-plugin-jest"
],
"rules": {
"unused-imports/no-unused-imports": "error"
"unused-imports/no-unused-imports": "error",
"semi": ["error", "always"],
"quotes": ["error", "double"]
}
}
4 changes: 2 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ PATH=$PATH:node_modules/.bin
# Check for unused dependencies
node tools/check-unused-dependencies.js

# Check of linter errors
if ! eslint . --ext js,ts,jsx,tsx; then
# Check for linter errors
if ! eslint "src/*" "test/" --ext js,ts,jsx,tsx; then
exit 1
fi

Expand Down
625 changes: 286 additions & 339 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"pidtree": "^0.6.0",
"pidusage": "^3.0.0",
"prompt": "^1.2.2",
"puppeteer": "^15.5.0",
"puppeteer": "^16.0.0",
"puppeteer-extra": "^3.3.4",
"puppeteer-extra-plugin-stealth": "^2.10.4",
"react": "^17.0.2",
Expand All @@ -60,11 +60,11 @@
"@types/prompt": "^1.1.2",
"@types/react": "^17.0.41",
"@types/uuid": "^8.3.4",
"@typescript-eslint/eslint-plugin": "^5.30.7",
"@typescript-eslint/parser": "^5.30.4",
"@typescript-eslint/eslint-plugin": "^5.32.0",
"@typescript-eslint/parser": "^5.32.0",
"depcheck": "^1.4.3",
"eslint": "^8.19.0",
"eslint-plugin-jest": "^26.1.5",
"eslint": "^8.21.0",
"eslint-plugin-jest": "^26.7.0",
"eslint-plugin-react": "^7.29.4",
"eslint-plugin-unused-imports": "^2.0.0",
"husky": "^8.0.1",
Expand Down
36 changes: 18 additions & 18 deletions src/configuration_parser.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';
"use strict";

import fs from 'fs';
import fs from "fs";

import {ArgumentParser} from 'argparse';
import {ArgumentParser} from "argparse";

import logger from './logger.js';
import logger from "./logger.js";
import {Option, StringListOption} from "./options.js";

export class ConfigurationParser {
Expand All @@ -24,7 +24,7 @@ export class ConfigurationParser {

// Parse arguments
const parser = new ArgumentParser();
parser.add_argument('--config', '-c', {default: 'config.json'});
parser.add_argument("--config", "-c", {default: "config.json"});
for (const option of this.#options) {
if (option.alias) {
parser.add_argument(option.name, option.alias, option.argparseOptions);
Expand All @@ -35,8 +35,8 @@ export class ConfigurationParser {
const args = parser.parse_args();

const getJsonKey = (option: Option<any>): string => {
return option.name.replace(/^-+/g, '').replace(/-/g, '_');
}
return option.name.replace(/^-+/g, "").replace(/-/g, "_");
};

const getOptionByName = (name: string): Option<any> | null => {
for (const option of this.#options) {
Expand All @@ -45,15 +45,15 @@ export class ConfigurationParser {
}
}
return null;
}
};

// Load config from file if it exists
let config: any = {};
logger.info('Loading config file: ' + args['config']);
const configFileExists = fs.existsSync(args['config']);
logger.info("Loading config file: " + args["config"]);
const configFileExists = fs.existsSync(args["config"]);
if (configFileExists) {
try {
config = JSON.parse(fs.readFileSync(args['config'], {encoding: 'utf-8'}));
config = JSON.parse(fs.readFileSync(args["config"], {encoding: "utf-8"}));

// Check for unknown options
for (const key of Object.keys(config)) {
Expand All @@ -71,19 +71,19 @@ export class ConfigurationParser {
continue;
}
for (const item of value) {
if (typeof item !== 'string') {
if (typeof item !== "string") {
throw new Error(`Error parsing option "${key}": Item is not a string: ${item}`);
}
}
}
}
} catch (error) {
logger.error('Failed to read config file!');
logger.error("Failed to read config file!");
logger.error(error);
process.exit(1);
}
} else {
logger.warn('Config file not found! Creating a default one...');
logger.warn("Config file not found! Creating a default one...");
}

// Override options from config with options from arguments and set defaults
Expand All @@ -92,14 +92,14 @@ export class ConfigurationParser {
if (args[key] === undefined) {
if (config[key] === undefined) {
const defaultValue = option.defaultValue;
if (typeof defaultValue === 'function') {
if (typeof defaultValue === "function") {
config[key] = defaultValue();
} else {
config[key] = defaultValue;
}
}
} else {
if (typeof args[key] === 'string') {
if (typeof args[key] === "string") {
config[key] = option.parse(args[key]);
} else {
config[key] = args[key];
Expand All @@ -110,8 +110,8 @@ export class ConfigurationParser {
// Save config file if it didn't exist
if (this.#saveIfNotExist) {
if (!configFileExists) {
fs.writeFileSync(args['config'], JSON.stringify(config, null, 4));
logger.info('Config saved to ' + args['config']);
fs.writeFileSync(args["config"], JSON.stringify(config, null, 4));
logger.info("Config saved to " + args["config"]);
}
}

Expand Down
Loading

0 comments on commit fe42515

Please sign in to comment.