Skip to content

Commit

Permalink
fix: linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Johan committed Oct 13, 2021
1 parent abcf302 commit d2c41ba
Show file tree
Hide file tree
Showing 24 changed files with 66 additions and 50 deletions.
47 changes: 32 additions & 15 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,48 @@
"node": true
},
"rules": {
"@typescript-eslint/explicit-function-return-type": ["off"],
"@typescript-eslint/explicit-member-accessibility": [
"error",
{
"accessibility": "explicit",
"overrides": {
"constructors": "no-public"
}
}
],
"arrow-parens": ["error", "always"],
"complexity": ["error", 4],
"import/extensions": ["error", { "ts": "never" }],
"import/order": [
1,
{
"alphabetize": {
"order": "asc",
"caseInsensitive": true
},
"groups": ["external", "builtin", "internal", "sibling", "parent", "index"],
"pathGroups": [
{ "pattern": "components", "group": "internal" },
{ "pattern": "common", "group": "internal" },
{ "pattern": "routes/**", "group": "internal" },
{ "pattern": "assets/**", "group": "internal", "position": "after" }
],
"pathGroupsExcludedImportTypes": ["internal"]
}],
"import/prefer-default-export": ["off"],
"jest/no-disabled-tests": "warn",
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error",
"jest/prefer-to-have-length": "warn",
"jest/valid-expect": "error",
"max-len": "off",
"newline-per-chained-call": "off",
"no-console": "off",
"no-nested-ternary": "error",
"no-restricted-syntax": ["off", "ForOfStatement"],
"no-undefined": "error",
"no-undef": "error",
"@typescript-eslint/explicit-function-return-type": ["off"],
"@typescript-eslint/explicit-member-accessibility": [
"error",
{
"accessibility": "explicit",
"overrides": {
"constructors": "no-public"
}
}
],
"react/no-unescaped-entities": [
"error",
{
Expand All @@ -65,10 +86,6 @@
]
}
],
"jest/no-disabled-tests": "warn",
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error",
"jest/prefer-to-have-length": "warn",
"jest/valid-expect": "error"
"sort-imports": ["warn", { "ignoreCase": true, "ignoreDeclarationSort": true }]
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
ASUS Router CLI

[![Build Status](https://travis-ci.com/jaspenlind/asuswrt-cli.svg)](https://travis-ci.com/jaspenlind/asuswrt-cli)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/93451c5afd954bd0a56d2417d2dbe301)](https://www.codacy.com/manual/jaspenlind/asuswrt-cli?utm_source=github.com&utm_medium=referral&utm_content=jaspenlind/asuswrt-cli&utm_campaign=Badge_Grade)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/93451c5afd954bd0a56d2417d2dbe301)](https://www.codacy.com/gh/jaspenlind/asuswrt-cli/dashboard?utm_source=github.com&utm_medium=referral&utm_content=jaspenlind/asuswrt-cli&utm_campaign=Badge_Grade)
![GitHub top language](https://img.shields.io/github/languages/top/jaspenlind/asuswrt-cli)
[![Coverage Status](https://coveralls.io/repos/jaspenlind/asuswrt-cli/badge.svg)](https://coveralls.io/r/jaspenlind/asuswrt-cli)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
Expand Down
9 changes: 5 additions & 4 deletions src/lib/cli.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/usr/bin/env node
import chalk from "chalk";
import { OptionMap, parse } from "args-any";
import { any } from "./helpers/array.helpers";
import declaration, { CommandDeclaration } from "../models/command-declaration";
import header from "../resources/header";
import chalk from "chalk";

import help from "./help";
import { any } from "./helpers/array.helpers";
import commandParser from "./parsers/command.parser";
import { check } from "./ssh/config";
import declaration, { CommandDeclaration } from "../models/command-declaration";
import header from "../resources/header";

const hasDebug = (options: OptionMap) => options.has("debug");
const hasHelp = (options: OptionMap) => options.has("h") || options.has("help");
Expand Down
2 changes: 1 addition & 1 deletion src/lib/commands/config/nvram/get.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env node
import { parse } from "args-any";
import promptly from "promptly";
import { execute } from "../../../ssh";
import { merlinCommand } from "../../../../models/command";
import { execute } from "../../../ssh";

const description = "Fetches a nvram config setting";
const hint = "[-key <name of nvram key to fetch>";
Expand Down
3 changes: 1 addition & 2 deletions src/lib/commands/config/nvram/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/usr/bin/env node
import { parse } from "args-any";
import { table } from "table";
// import { get } from "./get";
import { execute } from "../../../ssh";
import { merlinCommand } from "../../../../models/command";
import { execute } from "../../../ssh";

const description = "lists nvram config";
const hint = "[-filter.key <key starts with>]";
Expand Down
6 changes: 3 additions & 3 deletions src/lib/commands/config/ssh/add.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import promptly from "promptly";
import { exists, prompt } from "../../../ssh/config";

import { configCommand } from "../../../../models/command";
import { ConfigCreationData } from "../../../../types";
import edit from "./edit";
import { configCommand } from "../../../../models/command";
import { fromArgs } from "../../../../models/config-creation-data";
import { ConfigCreationData } from "../../../../types";
import { exists, prompt } from "../../../ssh/config";
import { proceed } from "../../../ssh/config/check";

const description = "Creates new SSH configuration";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/commands/config/ssh/edit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import configCreationData from "../../../../models/config-creation-data";
import { configCommand } from "../../../../models/command";
import configCreationData from "../../../../models/config-creation-data";
import { ConfigCreationData, get, prompt } from "../../../ssh/config";
import { proceed } from "../../../ssh/config/check";

Expand Down
3 changes: 1 addition & 2 deletions src/lib/commands/config/ssh/list.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import chalk from "chalk";
import flexi from "flexi-path";
import { get, SshConfig } from "../../../ssh/config";

import { configCommand } from "../../../../models/command";
import { get, SshConfig } from "../../../ssh/config";

interface ConfigOptions extends SshConfig {
keyFileExists: boolean;
Expand Down
1 change: 1 addition & 0 deletions src/lib/commands/firewall/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env node

import { create } from "../../../models/command";
import { execute, executeInTerminal } from "../../ssh";

Expand Down
2 changes: 1 addition & 1 deletion src/lib/commands/info/uptime.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node
import { execute } from "../../ssh";
import { merlinCommand } from "../../../models/command";
import { execute } from "../../ssh";

const description = "Display router uptime";

Expand Down
2 changes: 1 addition & 1 deletion src/lib/commands/jobs/add.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import promptly from "promptly";
import { execute } from "../../ssh";
import { create } from "../../../models/command";
import { execute } from "../../ssh";

const description = "Creates a new cron job";

Expand Down
4 changes: 2 additions & 2 deletions src/lib/commands/jobs/list.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import cron from "cron-parser";
import { table } from "table";
import { isEmpty } from "../../helpers/array.helpers";
import { create } from "../../../models/command";
import { ScheduledItem } from "../../../types";
import { isEmpty } from "../../helpers/array.helpers";
import { parse } from "../../parsers/scheduled-item.parser";
import { execute } from "../../ssh";
import { create } from "../../../models/command";

const description = "Lists existing cron jobs";

Expand Down
2 changes: 1 addition & 1 deletion src/lib/commands/jobs/remove.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import promptly from "promptly";
import { execute } from "../../ssh";
import { create } from "../../../models/command";
import { execute } from "../../ssh";

const description = "Removes a cron job";

Expand Down
2 changes: 1 addition & 1 deletion src/lib/commands/terminal.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node
import { executeInTerminal } from "../ssh";
import { create } from "../../models/command";
import { executeInTerminal } from "../ssh";

const description = "Opens an ssh connection to the router and executes the args (optional)";

Expand Down
2 changes: 1 addition & 1 deletion src/lib/commands/vpn/import.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { parse } from "args-any";
import vpn from "nordvpn-server-lister";
import promptly from "promptly";
import { table } from "table";
import vpn from "nordvpn-server-lister";

import { skynetCommand } from "../../../models/command";

Expand Down
3 changes: 1 addition & 2 deletions src/lib/commands/wan/nat/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env node

import { execute } from "../../../ssh";

import { merlinCommand } from "../../../../models/command";
import { execute } from "../../../ssh";

const description = "Displays nat configuration";

Expand Down
2 changes: 1 addition & 1 deletion src/lib/commands/wan/nat/rules/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node
import { table } from "table";
import { get } from "../../../config/nvram";
import { merlinCommand } from "../../../../../models/command";
import { get } from "../../../config/nvram";

const description = "NAT rules";

Expand Down
2 changes: 1 addition & 1 deletion src/lib/help.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node
import chalk from "chalk";
import { CommandDeclaration, empty } from "../models/command-declaration";
import parser from "./parsers/command.parser";
import { CommandDeclaration, empty } from "../models/command-declaration";

// const logger = moduleLogger.createLogger(module);
const isRoot = (command?: CommandDeclaration) => typeof command === "undefined" || command === empty;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/parsers/command.parser.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env node
import flexi, { FlexiPath, Path, until } from "flexi-path";
import argsAny from "args-any";
import { CommandParser } from "../../types";
import flexi, { FlexiPath, Path, until } from "flexi-path";
import command, { Command } from "../../models/command";
import declaration, { CommandDeclaration, create } from "../../models/command-declaration";
import { CommandParser } from "../../types";

const rootCommandPath = flexi.path(__dirname).parent().append("commands/");

Expand Down
6 changes: 3 additions & 3 deletions src/lib/ssh/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env node
import os from "os";
import flexi, { FlexiPath } from "flexi-path";
import { ExecOptions, ExecResult } from "../../types";
import { empty } from "../../models/sshConfig";
// eslint-disable-next-line import/order
import sh = require("shelljs");
import os from "os";
import { get } from "./config";
import { empty } from "../../models/sshConfig";
import { ExecOptions, ExecResult } from "../../types";
// import config = require("./config");

export const download = (file: FlexiPath): FlexiPath => {
Expand Down
2 changes: 1 addition & 1 deletion src/models/command-declaration.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command, CommandDeclaration, CommandRequirement } from "../types";
import command from "./command";
import { Command, CommandDeclaration, CommandRequirement } from "../types";

export { Command, CommandDeclaration };

Expand Down
2 changes: 1 addition & 1 deletion src/models/command.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command, CommandRequirement } from "../types";
import { distinct } from "../lib/helpers/array.helpers";
import { Command, CommandRequirement } from "../types";

export { Command, CommandRequirement };

Expand Down
4 changes: 2 additions & 2 deletions src/models/config-creation-data.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { parse } from "args-any";
import flexi from "flexi-path";
import { homedir } from "os";
import { parse } from "args-any";
import { ConfigCreationData } from "../types";
import sshConfig from "./sshConfig";
import { ConfigCreationData } from "../types";

// export { ConfigCreationData };

Expand Down
2 changes: 1 addition & 1 deletion test/resources/header.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import header from "../../src/resources/header";
import { version } from "../../package.json";
import header from "../../src/resources/header";

describe("header", () => {
it("can read header", () => {
Expand Down

0 comments on commit d2c41ba

Please sign in to comment.