Skip to content

Commit

Permalink
fix(eslint): fix ESLint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hckhanh committed Dec 17, 2021
1 parent d085863 commit aa6450a
Show file tree
Hide file tree
Showing 17 changed files with 1,164 additions and 346 deletions.
5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"root": true,
"extends": ["oclif", "oclif-typescript", "plugin:prettier/recommended"],
"rules": {
"quotes": ["error", "double"],
"no-await-in-loop": "off",
"node/no-missing-import": 1,
"quotes": ["error", "double"],
"unicorn/no-for-loop": "off",
"unicorn/filename-case": "off"
}
}
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,28 +72,28 @@
]
},
"dependencies": {
"@oclif/command": "^1",
"@oclif/config": "^1",
"@oclif/plugin-help": "^3",
"cli-ux": "^5.5.1",
"cross-spawn": "^7.0.3",
"ini": "^2.0.0",
"inquirer": "^8.0.0",
"js-yaml": "^4.0.0",
"tslib": "^2.1.0"
"@oclif/command": "1.8.15",
"@oclif/config": "1.18.2",
"@oclif/plugin-help": "5.1.10",
"cli-ux": "6.0.6",
"cross-spawn": "7.0.3",
"ini": "2.0.0",
"inquirer": "8.2.0",
"js-yaml": "4.1.0",
"tslib": "2.3.1"
},
"devDependencies": {
"@oclif/dev-cli": "^1",
"@types/cross-spawn": "^6",
"@types/ini": "^1",
"@types/inquirer": "^7",
"@types/js-yaml": "^4",
"@types/node": "^14",
"eslint": "^7.22.0",
"eslint-config-oclif": "^3.1",
"eslint-config-oclif-typescript": "^0.2.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-prettier": "^3.3.1",
"@types/node": "^16",
"eslint": "7.32.0",
"eslint-config-oclif": "4.0.0",
"eslint-config-oclif-typescript": "1.0.2",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-prettier": "4.0.0",
"prettier": "2.5.1",
"rimraf": "^3.0.2",
"ts-node": "^9.1.1",
Expand Down
2 changes: 1 addition & 1 deletion src/actions/AddScriptsAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { formatJson, readContentFromFile, withCurrentDir, writeContentToFile } f
import { Action } from "./Action";

export class AddScriptsAction extends Action {
constructor(private scripts: object, private enable: boolean) {
constructor(private scripts: Record<string, unknown>, private enable: boolean) {
super();
}

Expand Down
6 changes: 5 additions & 1 deletion src/actions/CreateConfigsFileAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { withCurrentDir, writeContentToFile } from "../process";
import { Action } from "./Action";

export class CreateConfigsFileAction extends Action {
constructor(private fileName: string, private configs: object, private formatter: Formatter) {
constructor(
private fileName: string,
private configs: Record<string, unknown>,
private formatter: Formatter,
) {
super();
}

Expand Down
2 changes: 1 addition & 1 deletion src/formatters/Formatter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export abstract class Formatter {
abstract format(configs: object): string;
abstract format(configs: Record<string, unknown>): string;

abstract formatFileName(fileName: string): string;
}
2 changes: 1 addition & 1 deletion src/formatters/IniFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { encode } from "ini";
import { Formatter } from "./Formatter";

export class IniFormatter extends Formatter {
format(configs: object) {
format(configs: Record<string, unknown>) {
const iniConfigs = encode(configs);
return iniConfigs.replace(/\.\*=true/g, ".*");
}
Expand Down
2 changes: 1 addition & 1 deletion src/formatters/JsFormatter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { JsonFormatter } from "./JsonFormatter";

export class JsFormatter extends JsonFormatter {
format(configs: object) {
format(configs: Record<string, unknown>) {
const jsonObj = super.format(configs);
return "module.exports = ".concat(jsonObj);
}
Expand Down
2 changes: 1 addition & 1 deletion src/formatters/JsonFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { formatJson } from "../process";
import { Formatter } from "./Formatter";

export class JsonFormatter extends Formatter {
format(configs: object) {
format(configs: Record<string, unknown>) {
return formatJson(configs);
}

Expand Down
2 changes: 1 addition & 1 deletion src/formatters/YamlFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { dump } from "js-yaml";
import { Formatter } from "./Formatter";

export class YamlFormatter extends Formatter {
format(configs: object) {
format(configs: Record<string, unknown>) {
return dump(configs);
}

Expand Down
4 changes: 2 additions & 2 deletions src/generators/ESLintGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { InquirerConfigs } from "../types";
import { Generator } from "./Generator";

export class ESLintGenerator extends Generator {
generateConfigs(userConfigs: InquirerConfigs): [object, string[]] {
generateConfigs(userConfigs: InquirerConfigs): [Record<string, unknown>, string[]] {
const configs: any = eslintBaseConfigs;
const packages = ["eslint"];

Expand Down Expand Up @@ -66,7 +66,7 @@ export class ESLintGenerator extends Generator {
}

initActions(
configs: object,
configs: Record<string, unknown>,
packages: string[],
userConfigs: InquirerConfigs,
formatter: Formatter,
Expand Down
4 changes: 2 additions & 2 deletions src/generators/FlowGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { InquirerConfigs } from "../types";
import { Generator } from "./Generator";

export class FlowGenerator extends Generator {
generateConfigs(userConfigs: InquirerConfigs): [object, string[]] {
generateConfigs(userConfigs: InquirerConfigs): [Record<string, unknown>, string[]] {
const configs: any = { ...flowConfigs };
const packages = ["flow-bin", "flow-typed"];

Expand All @@ -24,7 +24,7 @@ export class FlowGenerator extends Generator {
}

initActions(
configs: object,
configs: Record<string, unknown>,
packages: string[],
userConfigs: InquirerConfigs,
formatter: Formatter,
Expand Down
4 changes: 2 additions & 2 deletions src/generators/Generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export abstract class Generator {
this.actions = this.initActions(configs, packages, userConfigs, formatter, packager);
}

abstract generateConfigs(userConfigs: InquirerConfigs): [object, string[]];
abstract generateConfigs(userConfigs: InquirerConfigs): [Record<string, unknown>, string[]];

abstract initActions(
configs: object,
configs: Record<string, unknown>,
packages: string[],
userConfigs: InquirerConfigs,
formatter: Formatter,
Expand Down
12 changes: 6 additions & 6 deletions src/generators/PostGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import type { InquirerConfigs } from "../types";
import { Generator } from "./Generator";

export class PostGenerator extends Generator {
generateConfigs(userConfigs: InquirerConfigs): [object, string[]] {
generateConfigs(_userConfigs: InquirerConfigs): [Record<string, unknown>, string[]] {
return [{}, []];
}

initActions(
configs: object,
packages: string[],
userConfigs: InquirerConfigs,
formatter: Formatter,
packager: Packager,
_configs: Record<string, unknown>,
_packages: string[],
_userConfigs: InquirerConfigs,
_formatter: Formatter,
_packager: Packager,
): Action[] {
return [new CreateFileAction(".gitignore", postIgnoreFiles)];
}
Expand Down
4 changes: 2 additions & 2 deletions src/generators/PrettierGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import type { InquirerConfigs } from "../types";
import { Generator } from "./Generator";

export class PrettierGenerator extends Generator {
generateConfigs(userConfigs: InquirerConfigs): [object, string[]] {
generateConfigs(_userConfigs: InquirerConfigs): [Record<string, unknown>, string[]] {
return [prettierConfigs, ["prettier"]];
}

initActions(
configs: object,
configs: Record<string, unknown>,
packages: string[],
userConfigs: InquirerConfigs,
formatter: Formatter,
Expand Down
8 changes: 4 additions & 4 deletions src/generators/Yarn2Generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import type { InquirerConfigs } from "../types";
import { Generator } from "./Generator";

export class Yarn2Generator extends Generator {
generateConfigs(userConfigs: InquirerConfigs): [object, string[]] {
generateConfigs(_userConfigs: InquirerConfigs): [Record<string, unknown>, string[]] {
return [{}, []];
}

initActions(
configs: object,
packages: string[],
_configs: Record<string, unknown>,
_packages: string[],
userConfigs: InquirerConfigs,
formatter: Formatter,
_formatter: Formatter,
): Action[] {
return [
new CreateYarn2ConfigsAction(userConfigs),
Expand Down
8 changes: 4 additions & 4 deletions src/process.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { ChildProcessWithoutNullStreams } from "child_process";
import type { ChildProcessWithoutNullStreams } from "node:child_process";
import { spawn } from "cross-spawn";
import { readdir, readFile, rm, stat, writeFile } from "fs/promises";
import { readdir, readFile, rm, stat, writeFile } from "node:fs/promises";
import type { Stats } from "node:fs";
import { join } from "path";
import { join } from "node:path";

export const currentDir = process.cwd();

Expand Down Expand Up @@ -87,6 +87,6 @@ export async function readCurrentDir() {
return readdir(currentDir, { withFileTypes: true });
}

export function formatJson(obj: object): string {
export function formatJson(obj: Record<string, unknown>): string {
return JSON.stringify(obj, null, 2);
}
Loading

0 comments on commit aa6450a

Please sign in to comment.