Skip to content

Commit d765e9c

Browse files
committed
fix: unify string quotes to single quotes and remove unused VSCode settings
1 parent edef292 commit d765e9c

File tree

9 files changed

+70
-79
lines changed

9 files changed

+70
-79
lines changed

.eslintrc.js

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
module.exports = {
2-
env: {
3-
es2021: true,
4-
node: true,
5-
browser: true,
6-
},
7-
extends: [
8-
'eslint:recommended',
9-
'plugin:@typescript-eslint/recommended',
10-
'prettier',
2+
env: {
3+
es2021: true,
4+
node: true,
5+
browser: true,
6+
},
7+
extends: [
8+
'eslint:recommended',
9+
'plugin:@typescript-eslint/recommended',
10+
'prettier',
11+
],
12+
parser: '@typescript-eslint/parser',
13+
parserOptions: {
14+
ecmaVersion: 'latest',
15+
sourceType: 'module',
16+
},
17+
plugins: ['@typescript-eslint', 'prettier'],
18+
rules: {
19+
'prettier/prettier': [
20+
'error',
21+
{
22+
endOfLine: 'auto',
23+
},
1124
],
12-
parser: '@typescript-eslint/parser',
13-
parserOptions: {
14-
ecmaVersion: 'latest',
15-
sourceType: 'module',
16-
},
17-
plugins: ['@typescript-eslint', 'prettier'],
18-
rules: {
19-
indent: ['error', 2],
20-
'prettier/prettier': [
21-
'error',
22-
{
23-
endOfLine: 'auto',
24-
},
25-
],
26-
},
27-
ignorePatterns: ['dist/'],
28-
};
25+
},
26+
ignorePatterns: ['dist/'],
27+
};

.vscode/settings.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/api/http.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import axios, { AxiosInstance } from "axios";
1+
import axios, { AxiosInstance } from 'axios';
22

33
export default class HttpClient {
44
private readonly rest: AxiosInstance;
5-
private readonly baseUrl = "https://api.github.com";
5+
private readonly baseUrl = 'https://api.github.com';
66

77
constructor() {
88
this.rest = axios.create({
@@ -14,11 +14,11 @@ export default class HttpClient {
1414
(response) => response,
1515
(error) => {
1616
console.error(
17-
"GitHub API Error:",
18-
error.response?.data?.message || error.message
17+
'GitHub API Error:',
18+
error.response?.data?.message || error.message,
1919
);
20-
throw new Error("GitHub API Error");
21-
}
20+
throw new Error('GitHub API Error');
21+
},
2222
);
2323
}
2424

src/commands/repo.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { httpClient } from "../api/http";
2-
import { ErrorObject, timeout } from "../errors/timeout";
1+
import { httpClient } from '../api/http';
2+
import { ErrorObject, timeout } from '../errors/timeout';
33

44
export async function getRepoData(repo: string): Promise<RepositoryData> {
55
const baseUrl = `https://api.github.com/repos/${repo}`;
@@ -21,14 +21,14 @@ export async function getRepoData(repo: string): Promise<RepositoryData> {
2121
updated_at,
2222
} = response;
2323
return {
24-
type: "repo",
24+
type: 'repo',
2525
name,
2626
owner: owner.login,
2727
profile_url: owner.html_url,
2828
repo_url: html_url,
2929
visibility,
3030
default_branch,
31-
license: license?.name || "NO LICENSE",
31+
license: license?.name || 'NO LICENSE',
3232
stars: stargazers_count,
3333
forks,
3434
open_issues,
@@ -37,6 +37,6 @@ export async function getRepoData(repo: string): Promise<RepositoryData> {
3737
};
3838
} catch (error) {
3939
timeout(error as ErrorObject);
40-
throw new Error("GitHub API Error: Failed to fetch repo data");
40+
throw new Error('GitHub API Error: Failed to fetch repo data');
4141
}
4242
}

src/commands/user.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { httpClient } from "../api/http";
2-
import { ErrorObject, timeout } from "../errors/timeout";
1+
import { httpClient } from '../api/http';
2+
import { ErrorObject, timeout } from '../errors/timeout';
33

44
export async function getUserData(username: string): Promise<UserData> {
55
const baseUrl = `https://api.github.com/users/${username}`;
@@ -23,14 +23,14 @@ export async function getUserData(username: string): Promise<UserData> {
2323
updated_at,
2424
} = response;
2525
return {
26-
type: "user",
26+
type: 'user',
2727
login,
2828
name,
2929
profile_url: html_url,
30-
company: company || "NO COMPANY",
31-
blog: blog || "NO BLOG",
30+
company: company || 'NO COMPANY',
31+
blog: blog || 'NO BLOG',
3232
location,
33-
email: email || "NO EMAIL",
33+
email: email || 'NO EMAIL',
3434
bio,
3535
public_repos,
3636
followers,
@@ -40,6 +40,6 @@ export async function getUserData(username: string): Promise<UserData> {
4040
};
4141
} catch (error) {
4242
timeout(error as ErrorObject);
43-
throw new Error("GitHub API Error: Failed to fetch user data");
43+
throw new Error('GitHub API Error: Failed to fetch user data');
4444
}
4545
}

src/errors/timeout.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ export interface ErrorObject {
44
}
55

66
export function timeout(error: ErrorObject): void {
7-
if (error.code === "ECONNABORTED") {
8-
console.error("Request timed out");
7+
if (error.code === 'ECONNABORTED') {
8+
console.error('Request timed out');
99
} else {
10-
console.error("Request failed:", error.message);
10+
console.error('Request failed:', error.message);
1111
}
1212
}

src/index.ts

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,42 @@
11
#!/usr/bin/env node
2-
3-
import { Command } from "commander";
4-
import { getRepoData } from "./commands/repo";
5-
import { getUserData } from "./commands/user";
6-
import { formatOutput } from "./utils/formatter";
2+
import { getRepoData } from './commands/repo';
3+
import { getUserData } from './commands/user';
4+
import { formatOutput } from './utils/formatter';
5+
import { Command } from 'commander';
76

87
const program = new Command();
98

109
program
11-
.name("github")
12-
.description("Github 정보를 분석하고 가져오는 CLI")
13-
.version("0.0.0", "-v", "--version")
10+
.name('github')
11+
.description('Github 정보를 분석하고 가져오는 CLI')
12+
.version('0.0.0', '-v', '--version')
1413
.showHelpAfterError();
1514

1615
program
17-
.command("repo")
18-
.description("Github 레포지토리 정보를 가져옵니다.")
19-
.argument("<repo>", "Github 레포지토리를 이름 (owner/repo 형식)")
20-
.option("--json", "JSON 형식으로 출력")
16+
.command('repo')
17+
.description('Github 레포지토리 정보를 가져옵니다.')
18+
.argument('<repo>', 'Github 레포지토리를 이름 (owner/repo 형식)')
19+
.option('--json', 'JSON 형식으로 출력')
2120
.action(async (repo, options) => {
2221
try {
2322
const data = await getRepoData(repo);
2423
console.log(formatOutput(data, options.json));
2524
} catch (error) {
26-
console.error("Error: ", error instanceof Error ? error.message : error);
25+
console.error('Error: ', error instanceof Error ? error.message : error);
2726
}
2827
});
2928

3029
program
31-
.command("user")
32-
.description("Github 사용자 정보를 가져옵니다.")
33-
.argument("<username>", "Github 사용자 이름 (username 형식)")
34-
.option("--json", "JSON 형식으로 출력")
30+
.command('user')
31+
.description('Github 사용자 정보를 가져옵니다.')
32+
.argument('<username>', 'Github 사용자 이름 (username 형식)')
33+
.option('--json', 'JSON 형식으로 출력')
3534
.action(async (username, options) => {
3635
try {
3736
const data = await getUserData(username);
3837
console.log(formatOutput(data, options.json));
3938
} catch (error) {
40-
console.error("Error: ", error instanceof Error ? error.message : error);
39+
console.error('Error: ', error instanceof Error ? error.message : error);
4140
}
4241
});
4342

src/types/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
interface RepositoryData {
2-
type: "repo";
2+
type: 'repo';
33
name: string;
44
owner: string;
55
profile_url: string;
@@ -15,7 +15,7 @@ interface RepositoryData {
1515
}
1616

1717
interface UserData {
18-
type: "user";
18+
type: 'user';
1919
login: string;
2020
name: string;
2121
profile_url: string;
@@ -31,4 +31,4 @@ interface UserData {
3131
updated_at: string;
3232
}
3333

34-
type OutputData = RepositoryData | UserData;
34+
export type OutputData = RepositoryData | UserData;

src/utils/formatter.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import chalk from "chalk";
1+
import { OutputData } from '../types';
2+
import chalk from 'chalk';
23

34
export function formatOutput(data: OutputData, isJson: boolean) {
45
if (isJson) {
56
return JSON.stringify(data, null, 2);
67
}
78

89
switch (data.type) {
9-
case "repo":
10+
case 'repo':
1011
return `
1112
Repo: ${chalk.blue.bold(data.name)} (${chalk.gray(data.owner)})
1213
Profile_url: ${chalk.blueBright(data.profile_url)}
@@ -21,7 +22,7 @@ export function formatOutput(data: OutputData, isJson: boolean) {
2122
Language: ${chalk.cyan(data.language)}
2223
Last Updated: ${chalk.magenta(data.updated_at)}
2324
`;
24-
case "user":
25+
case 'user':
2526
return `
2627
User: ${chalk.blue.bold(data.name)} (${chalk.gray(data.login)})
2728
Profile_url: ${chalk.magenta(data.profile_url)}

0 commit comments

Comments
 (0)