Skip to content

Commit 04297a8

Browse files
committed
style: standardize double quotes for consistency
1 parent 4ce1aec commit 04297a8

4 files changed

Lines changed: 24 additions & 24 deletions

File tree

src/api/github.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export async function fetchLanguageData(useTestData = false) {
1717
const orgs = process.env.GITHUB_ORGS?.split(',').map(o => o.trim()).filter(Boolean) || [];
1818

1919
if(usernames.length === 0 && orgs.length === 0)
20-
throw new Error(`At least one of GITHUB_USERNAMES or GITHUB_ORGS must be set`);
20+
throw new Error("At least one of GITHUB_USERNAMES or GITHUB_ORGS must be set");
2121

2222
const fetchPromises = [
2323
...usernames.map(user => fetch(`https://api.github.com/users/${user}/repos?per_page=100`)),

tests/api/github.test.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ const languages = {
1515

1616
describe("fetchLanguageData", () => {
1717
beforeEach(() => {
18-
vi.stubEnv('GITHUB_USERNAMES', 'testuser');
19-
vi.stubEnv('IGNORED_REPOS', 'ignored-repo');
18+
vi.stubEnv("GITHUB_USERNAMES", "testuser");
19+
vi.stubEnv("IGNORED_REPOS", "ignored-repo");
2020
global.fetch = vi.fn();
2121
vi.resetModules();
2222
resetCache();
@@ -35,12 +35,12 @@ describe("fetchLanguageData", () => {
3535

3636
it("throws error when GITHUB_USERNAMES env variable not set", async () => {
3737
vi.unstubAllEnvs();
38-
await expect(fetchLanguageData()).rejects.toThrow('At least one of GITHUB_USERNAMES or GITHUB_ORGS must be set');
38+
await expect(fetchLanguageData()).rejects.toThrow("At least one of GITHUB_USERNAMES or GITHUB_ORGS must be set");
3939
});
4040

4141
it("handles missing IGNORED_REPOS env variable", async () => {
4242
vi.unstubAllEnvs();
43-
vi.stubEnv('GITHUB_USERNAMES', 'testuser');
43+
vi.stubEnv("GITHUB_USERNAMES", "testuser");
4444

4545
global.fetch
4646
.mockResolvedValueOnce({ ok: true, json: async () => repos })
@@ -64,17 +64,17 @@ describe("fetchLanguageData", () => {
6464
await fetchLanguageData();
6565

6666
expect(global.fetch).toHaveBeenCalledWith(
67-
'https://api.github.com/users/testuser/repos?per_page=100'
67+
"https://api.github.com/users/testuser/repos?per_page=100"
6868
);
6969
expect(global.fetch).toHaveBeenCalledWith(
70-
'https://api.github.com/repos/user/repo1/languages'
70+
"https://api.github.com/repos/user/repo1/languages"
7171
);
7272

7373
expect(global.fetch).not.toHaveBeenCalledWith(
74-
'https://api.github.com/repos/user/repo2/languages'
74+
"https://api.github.com/repos/user/repo2/languages"
7575
);
7676
expect(global.fetch).not.toHaveBeenCalledWith(
77-
'https://api.github.com/repos/user/ignored-repo/languages'
77+
"https://api.github.com/repos/user/ignored-repo/languages"
7878
);
7979
});
8080

@@ -97,10 +97,10 @@ describe("fetchLanguageData", () => {
9797
global.fetch.mockResolvedValueOnce({
9898
ok: false,
9999
status: 404,
100-
statusText: 'Not Found'
100+
statusText: "Not Found"
101101
});
102102

103-
await expect(fetchLanguageData()).rejects.toThrow('GitHub API error: 404 Not Found');
103+
await expect(fetchLanguageData()).rejects.toThrow("GitHub API error: 404 Not Found");
104104
});
105105

106106
it("caches results within refresh interval", async () => {
@@ -131,7 +131,7 @@ describe("fetchLanguageData", () => {
131131

132132
it("fetches from organizations", async () => {
133133
vi.unstubAllEnvs();
134-
vi.stubEnv('GITHUB_ORGS', 'test-org');
134+
vi.stubEnv("GITHUB_ORGS", "test-org");
135135

136136
const orgRepos = [
137137
{ name: "org-repo", fork: false, full_name: "test-org/org-repo" }
@@ -144,7 +144,7 @@ describe("fetchLanguageData", () => {
144144
const result = await fetchLanguageData();
145145

146146
expect(global.fetch).toHaveBeenCalledWith(
147-
'https://api.github.com/orgs/test-org/repos?per_page=100'
147+
"https://api.github.com/orgs/test-org/repos?per_page=100"
148148
);
149149
expect(result).toEqual({ TypeScript: 4000 });
150150
});
@@ -155,26 +155,26 @@ describe("processLanguageData", () => {
155155
const data = { JavaScript: 5000, Python: 3000, HTML: 2000 };
156156
const result = processLanguageData(data, 3);
157157
expect(result).toHaveLength(3);
158-
expect(result[0]).toEqual({ lang: 'JavaScript', pct: 50 });
159-
expect(result[1]).toEqual({ lang: 'Python', pct: 30 });
160-
expect(result[2]).toEqual({ lang: 'HTML', pct: 20 });
158+
expect(result[0]).toEqual({ lang: "JavaScript", pct: 50 });
159+
expect(result[1]).toEqual({ lang: "Python", pct: 30 });
160+
expect(result[2]).toEqual({ lang: "HTML", pct: 20 });
161161
});
162162

163163
it("sorts by percentage descending", () => {
164164
const data = { HTML: 1000, JavaScript: 5000, Python: 3000 };
165165
const result = processLanguageData(data, 3);
166166

167-
expect(result[0].lang).toBe('JavaScript');
168-
expect(result[1].lang).toBe('Python');
169-
expect(result[2].lang).toBe('HTML');
167+
expect(result[0].lang).toBe("JavaScript");
168+
expect(result[1].lang).toBe("Python");
169+
expect(result[2].lang).toBe("HTML");
170170
});
171171

172172
it("limits to count", () => {
173173
const data = { JavaScript: 5000, Python: 3000, HTML: 2000, CSS: 1000 };
174174
const result = processLanguageData(data, 2);
175175

176176
expect(result).toHaveLength(2);
177-
expect(result.map(l => l.lang)).toEqual(['JavaScript', 'Python']);
177+
expect(result.map(l => l.lang)).toEqual(["JavaScript", "Python"]);
178178
});
179179

180180
it("renormalizes percentages after slicing", () => {
@@ -186,6 +186,6 @@ describe("processLanguageData", () => {
186186
});
187187

188188
it("throws when no language data", () => {
189-
expect(() => processLanguageData({}, 5)).toThrow('No language data available');
189+
expect(() => processLanguageData({}, 5)).toThrow("No language data available");
190190
});
191191
});

tests/utils/params.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe("parseQueryParams", () => {
3838

3939
it("sanitizes title when provided", () => {
4040
const params = parseQueryParams({ title: `<scripts>alert("x")</script>` });
41-
expect(params.chartTitle).toBe(`&lt;scripts&gt;alert(&quot;x&quot;)&lt;/script&gt;`);
41+
expect(params.chartTitle).toBe("&lt;scripts&gt;alert(&quot;x&quot;)&lt;/script&gt;");
4242
});
4343

4444
it("clamps count between 1 and MAX_COUNT", () => {

tests/utils/sanitize.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ describe("sanitize", () => {
1111
});
1212

1313
it("escapes the criticial HTML characters", () => {
14-
expect(sanitize(`<>&"'`)).toBe(`&lt;&gt;&amp;&quot;&#39;`);
14+
expect(sanitize(`<>&"'`)).toBe("&lt;&gt;&amp;&quot;&#39;");
1515
});
1616

1717
it("leaves safe strings unchanged", () => {
1818
expect(sanitize("Hello world")).toBe("Hello world");
1919
});
2020

2121
it("escapes mixed content correctly", () => {
22-
expect(sanitize(`Hi <Mason> & "team"`)).toBe(`Hi &lt;Mason&gt; &amp; &quot;team&quot;`);
22+
expect(sanitize(`Hi <Mason> & "team"`)).toBe("Hi &lt;Mason&gt; &amp; &quot;team&quot;");
2323
});
2424
});

0 commit comments

Comments
 (0)