Skip to content

Commit 4c2307a

Browse files
Add prettier check to CI (#1999)
* Add prettier check to CI * Run prettier:format
1 parent d5c94b6 commit 4c2307a

File tree

10 files changed

+56
-38
lines changed

10 files changed

+56
-38
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,9 @@ jobs:
2525
npm install
2626
npm run test
2727
28+
- name: Run Prettier
29+
run: |
30+
npm run prettier:check:ci
31+
2832
- name: Code Coverage
2933
uses: codecov/codecov-action@v1

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"test:watch": "jest --watch",
99
"theme-readme-gen": "node scripts/generate-theme-doc",
1010
"preview-theme": "node scripts/preview-theme",
11-
"generate-langs-json": "node scripts/generate-langs-json"
11+
"generate-langs-json": "node scripts/generate-langs-json",
12+
"prettier:check:ci": "./node_modules/.bin/prettier --check .",
13+
"prettier:format": "./node_modules/.bin/prettier --write ."
1214
},
1315
"author": "Anurag Hazra",
1416
"license": "MIT",

scripts/generate-langs-json.js

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
1-
const fs = require('fs');
2-
const jsYaml = require('js-yaml');
3-
const axios = require('axios');
1+
const fs = require("fs");
2+
const jsYaml = require("js-yaml");
3+
const axios = require("axios");
44

5-
const LANGS_FILEPATH = "./src/common/languageColors.json"
5+
const LANGS_FILEPATH = "./src/common/languageColors.json";
66

77
//Retrieve languages from github linguist repository yaml file
88
//@ts-ignore
9-
axios.get("https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml")
10-
.then((response) => {
9+
axios
10+
.get(
11+
"https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml",
12+
)
13+
.then((response) => {
14+
//and convert them to a JS Object
15+
const languages = jsYaml.load(response.data);
1116

12-
//and convert them to a JS Object
13-
const languages = jsYaml.load(response.data);
17+
const languageColors = {};
1418

15-
const languageColors = {};
19+
//Filter only language colors from the whole file
20+
Object.keys(languages).forEach((lang) => {
21+
languageColors[lang] = languages[lang].color;
22+
});
1623

17-
//Filter only language colors from the whole file
18-
Object.keys(languages).forEach((lang) => {
19-
languageColors[lang] = languages[lang].color;
24+
//Debug Print
25+
//console.dir(languageColors);
26+
fs.writeFileSync(
27+
LANGS_FILEPATH,
28+
JSON.stringify(languageColors, null, " "),
29+
);
2030
});
21-
22-
//Debug Print
23-
//console.dir(languageColors);
24-
fs.writeFileSync(LANGS_FILEPATH, JSON.stringify(languageColors, null, ' '));
25-
26-
});

src/calculateRank.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ function calculateRank({
6767
if (normalizedScore < RANK_S_VALUE) return "S+";
6868
if (normalizedScore < RANK_DOUBLE_A_VALUE) return "S";
6969
if (normalizedScore < RANK_A2_VALUE) return "A++";
70-
if (normalizedScore < RANK_A3_VALUE) return "A+"
70+
if (normalizedScore < RANK_A3_VALUE) return "A+";
7171
return "B+";
72-
})()
72+
})();
7373

7474
return { level, score: normalizedScore };
7575
}

src/cards/repo-card.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ const iconWithLabel = (icon, label, testid) => {
6767
};
6868

6969
/**
70-
* @param {import('../fetchers/types').RepositoryData} repo
71-
* @param {Partial<import("./types").RepoCardOptions>} options
70+
* @param {import('../fetchers/types').RepositoryData} repo
71+
* @param {Partial<import("./types").RepoCardOptions>} options
7272
* @returns {string}
7373
*/
7474
const renderRepoCard = (repo, options = {}) => {
@@ -167,11 +167,11 @@ const renderRepoCard = (repo, options = {}) => {
167167
return card.render(`
168168
${
169169
isTemplate
170-
// @ts-ignore
171-
? getBadgeSVG(i18n.t("repocard.template"), colors.textColor)
170+
? // @ts-ignore
171+
getBadgeSVG(i18n.t("repocard.template"), colors.textColor)
172172
: isArchived
173-
// @ts-ignore
174-
? getBadgeSVG(i18n.t("repocard.archived"), colors.textColor)
173+
? // @ts-ignore
174+
getBadgeSVG(i18n.t("repocard.archived"), colors.textColor)
175175
: ""
176176
}
177177

src/fetchers/wakatime-fetcher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { MissingParamError } = require("../common/utils");
77
*/
88
const fetchWakatimeStats = async ({ username, api_domain, range }) => {
99
if (!username) throw new MissingParamError(["username"]);
10-
10+
1111
try {
1212
const { data } = await axios.get(
1313
`https://${

tests/fetchTopLanguages.test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ describe("FetchTopLanguages", () => {
8181
it("should fetch correct language data while excluding the 'test-repo-1' repository", async () => {
8282
mock.onPost("https://api.github.com/graphql").reply(200, data_langs);
8383

84-
let repo = await fetchTopLanguages("anuraghazra", exclude_repo=["test-repo-1"]);
84+
let repo = await fetchTopLanguages(
85+
"anuraghazra",
86+
(exclude_repo = ["test-repo-1"]),
87+
);
8588
expect(repo).toStrictEqual({
8689
HTML: {
8790
color: "#0f0",

tests/fetchWakatime.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ describe("Wakatime fetcher", () => {
207207
mock.onGet(/\/https:\/\/wakatime\.com\/api/).reply(404, wakaTimeData);
208208

209209
await expect(fetchWakatimeStats("noone")).rejects.toThrow(
210-
"Missing params \"username\" make sure you pass the parameters in URL",
210+
'Missing params "username" make sure you pass the parameters in URL',
211211
);
212212
});
213213
});

tests/renderWakatimeCard.test.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,15 @@ describe("Test Render Wakatime Card", () => {
4848
});
4949

5050
it('should show "no coding activitiy this week" message when there hasn not been activity', () => {
51-
document.body.innerHTML = renderWakatimeCard({
52-
...wakaTimeData.data,
53-
languages: undefined
54-
}, {});
55-
expect(document.querySelector(".stat").textContent).toBe("No coding activity this week")
56-
})
51+
document.body.innerHTML = renderWakatimeCard(
52+
{
53+
...wakaTimeData.data,
54+
languages: undefined,
55+
},
56+
{},
57+
);
58+
expect(document.querySelector(".stat").textContent).toBe(
59+
"No coding activity this week",
60+
);
61+
});
5762
});

themes/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,12 +355,12 @@ const themes = {
355355
bg_color: "09131B",
356356
border_color: "0c1a25",
357357
},
358-
"rose_pine":{
358+
rose_pine: {
359359
title_color: "9ccfd8",
360360
icon_color: "ebbcba",
361361
text_color: "e0def4",
362362
bg_color: "191724",
363-
}
363+
},
364364
};
365365

366366
module.exports = themes;

0 commit comments

Comments
 (0)