Add prettier check to CI (#1999)

* Add prettier check to CI

* Run prettier:format
This commit is contained in:
Steven 2022-09-06 03:09:45 -04:00 committed by GitHub
parent d5c94b6f57
commit 4c2307ab4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 56 additions and 38 deletions

View File

@ -25,5 +25,9 @@ jobs:
npm install
npm run test
- name: Run Prettier
run: |
npm run prettier:check:ci
- name: Code Coverage
uses: codecov/codecov-action@v1

View File

@ -8,7 +8,9 @@
"test:watch": "jest --watch",
"theme-readme-gen": "node scripts/generate-theme-doc",
"preview-theme": "node scripts/preview-theme",
"generate-langs-json": "node scripts/generate-langs-json"
"generate-langs-json": "node scripts/generate-langs-json",
"prettier:check:ci": "./node_modules/.bin/prettier --check .",
"prettier:format": "./node_modules/.bin/prettier --write ."
},
"author": "Anurag Hazra",
"license": "MIT",

View File

@ -1,26 +1,30 @@
const fs = require('fs');
const jsYaml = require('js-yaml');
const axios = require('axios');
const fs = require("fs");
const jsYaml = require("js-yaml");
const axios = require("axios");
const LANGS_FILEPATH = "./src/common/languageColors.json"
const LANGS_FILEPATH = "./src/common/languageColors.json";
//Retrieve languages from github linguist repository yaml file
//@ts-ignore
axios.get("https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml")
.then((response) => {
axios
.get(
"https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml",
)
.then((response) => {
//and convert them to a JS Object
const languages = jsYaml.load(response.data);
//and convert them to a JS Object
const languages = jsYaml.load(response.data);
const languageColors = {};
const languageColors = {};
//Filter only language colors from the whole file
Object.keys(languages).forEach((lang) => {
languageColors[lang] = languages[lang].color;
});
//Filter only language colors from the whole file
Object.keys(languages).forEach((lang) => {
languageColors[lang] = languages[lang].color;
//Debug Print
//console.dir(languageColors);
fs.writeFileSync(
LANGS_FILEPATH,
JSON.stringify(languageColors, null, " "),
);
});
//Debug Print
//console.dir(languageColors);
fs.writeFileSync(LANGS_FILEPATH, JSON.stringify(languageColors, null, ' '));
});

View File

@ -67,9 +67,9 @@ function calculateRank({
if (normalizedScore < RANK_S_VALUE) return "S+";
if (normalizedScore < RANK_DOUBLE_A_VALUE) return "S";
if (normalizedScore < RANK_A2_VALUE) return "A++";
if (normalizedScore < RANK_A3_VALUE) return "A+"
if (normalizedScore < RANK_A3_VALUE) return "A+";
return "B+";
})()
})();
return { level, score: normalizedScore };
}

View File

@ -67,8 +67,8 @@ const iconWithLabel = (icon, label, testid) => {
};
/**
* @param {import('../fetchers/types').RepositoryData} repo
* @param {Partial<import("./types").RepoCardOptions>} options
* @param {import('../fetchers/types').RepositoryData} repo
* @param {Partial<import("./types").RepoCardOptions>} options
* @returns {string}
*/
const renderRepoCard = (repo, options = {}) => {
@ -167,11 +167,11 @@ const renderRepoCard = (repo, options = {}) => {
return card.render(`
${
isTemplate
// @ts-ignore
? getBadgeSVG(i18n.t("repocard.template"), colors.textColor)
? // @ts-ignore
getBadgeSVG(i18n.t("repocard.template"), colors.textColor)
: isArchived
// @ts-ignore
? getBadgeSVG(i18n.t("repocard.archived"), colors.textColor)
? // @ts-ignore
getBadgeSVG(i18n.t("repocard.archived"), colors.textColor)
: ""
}

View File

@ -7,7 +7,7 @@ const { MissingParamError } = require("../common/utils");
*/
const fetchWakatimeStats = async ({ username, api_domain, range }) => {
if (!username) throw new MissingParamError(["username"]);
try {
const { data } = await axios.get(
`https://${

View File

@ -81,7 +81,10 @@ describe("FetchTopLanguages", () => {
it("should fetch correct language data while excluding the 'test-repo-1' repository", async () => {
mock.onPost("https://api.github.com/graphql").reply(200, data_langs);
let repo = await fetchTopLanguages("anuraghazra", exclude_repo=["test-repo-1"]);
let repo = await fetchTopLanguages(
"anuraghazra",
(exclude_repo = ["test-repo-1"]),
);
expect(repo).toStrictEqual({
HTML: {
color: "#0f0",

View File

@ -207,7 +207,7 @@ describe("Wakatime fetcher", () => {
mock.onGet(/\/https:\/\/wakatime\.com\/api/).reply(404, wakaTimeData);
await expect(fetchWakatimeStats("noone")).rejects.toThrow(
"Missing params \"username\" make sure you pass the parameters in URL",
'Missing params "username" make sure you pass the parameters in URL',
);
});
});

View File

@ -48,10 +48,15 @@ describe("Test Render Wakatime Card", () => {
});
it('should show "no coding activitiy this week" message when there hasn not been activity', () => {
document.body.innerHTML = renderWakatimeCard({
...wakaTimeData.data,
languages: undefined
}, {});
expect(document.querySelector(".stat").textContent).toBe("No coding activity this week")
})
document.body.innerHTML = renderWakatimeCard(
{
...wakaTimeData.data,
languages: undefined,
},
{},
);
expect(document.querySelector(".stat").textContent).toBe(
"No coding activity this week",
);
});
});

View File

@ -355,12 +355,12 @@ const themes = {
bg_color: "09131B",
border_color: "0c1a25",
},
"rose_pine":{
rose_pine: {
title_color: "9ccfd8",
icon_color: "ebbcba",
text_color: "e0def4",
bg_color: "191724",
}
},
};
module.exports = themes;