Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Yizack committed Oct 24, 2024
1 parent aa924e4 commit ece56d8
Show file tree
Hide file tree
Showing 14 changed files with 269 additions and 130 deletions.
67 changes: 43 additions & 24 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,31 +1,50 @@
import eslint from "@eslint/js";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { includeIgnoreFile } from "@eslint/compat";
import stylistic from "@stylistic/eslint-plugin";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const gitignorePath = path.resolve(__dirname, ".gitignore");

export default [
includeIgnoreFile(gitignorePath),
{
files: ["**/*.js"],
ignores: [
"node_modules/**/*",
"build/**/*",
"dist/**/*",
".output/**/*",
"docs/**/*",
],
files: ["**/*.js", "**/*.mjs"],
plugins: {
"@stylistic": stylistic
},
rules: {
...eslint.configs.recommended.rules,
"indent": ["error", 2, { "SwitchCase": 1 }],
"linebreak-style": ["error", "windows"],
"quotes": ["error", "double"],
"semi": ["error", "always"],
"camelcase": "off",
"arrow-spacing": ["error", { "before": true, "after": true }],
"no-console": ["error", {
"allow": ["info", "warn"]
}],
"brace-style": ["error", "stroustrup", { "allowSingleLine": true }],
"no-multi-spaces": "error",
"space-before-blocks": "error",
"no-trailing-spaces": "error",
"no-undef": "off"
"camelcase": ["error"],
"no-console": ["error", { allow: ["info", "warn"] }],
"@stylistic/indent": ["error", 2, { SwitchCase: 1 }],
"@stylistic/linebreak-style": ["error", process.platform === "win32" ? "windows" : "unix"],
"@stylistic/quotes": ["error", "double"],
"@stylistic/semi": ["error", "always"],
"@stylistic/no-extra-semi": "error",
"@stylistic/comma-dangle": ["error", "never"],
"@stylistic/space-before-function-paren": ["error", "always"],
"@stylistic/multiline-ternary": ["error", "never"],
"@stylistic/member-delimiter-style": ["error", { multiline: { delimiter: "semi" }, singleline: { delimiter: "comma" } }],
"@stylistic/arrow-spacing": ["error", { before: true, after: true }],
"@stylistic/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
"@stylistic/no-multi-spaces": "error",
"@stylistic/space-before-blocks": "error",
"@stylistic/no-trailing-spaces": "error",
"@stylistic/array-bracket-spacing": ["error", "never"],
"@stylistic/block-spacing": ["error", "always"],
"@stylistic/comma-spacing": ["error", { after: true, before: false }],
"@stylistic/comma-style": ["error", "last"],
"@stylistic/key-spacing": ["error", { afterColon: true, beforeColon: false }],
"@stylistic/keyword-spacing": ["error", { after: true, before: true }],
"@stylistic/object-curly-newline": "off",
"@stylistic/object-curly-spacing": ["error", "always"],
"@stylistic/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
"@stylistic/one-component-per-file": "off",
"@stylistic/require-default-prop": "off",
"@stylistic/space-in-parens": ["error", "never"],
"@stylistic/template-curly-spacing": "error",
"@stylistic/quote-props": ["error", "consistent-as-needed"]
}
}
];
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"lint": "eslint --fix"
},
"devDependencies": {
"@eslint/compat": "^1.2.1",
"@stylistic/eslint-plugin": "^2.9.0",
"@vitest/coverage-v8": "^2.1.3",
"clean-jsdoc-theme": "^4.3.0",
"dotenv": "^16.4.5",
Expand Down
118 changes: 118 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions resources/themes.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"default": {
"primary_color": "0969da",
"text_color": "434d58",
"bg_color": "fffefe",
"icon_color": "586069",
"border_color": "e4e2e2"
"primaryColor": "0969da",
"textColor": "434d58",
"bgColor": "fffefe",
"iconColor": "586069",
"borderColor": "e4e2e2"
},
"dark": {
"primary_color": "58a6ff",
"text_color": "c9d1d9",
"bg_color": "0d1117",
"icon_color": "58a6ff",
"border_color": "30363d"
"primaryColor": "58a6ff",
"textColor": "c9d1d9",
"bgColor": "0d1117",
"iconColor": "58a6ff",
"borderColor": "30363d"
}
}
30 changes: 15 additions & 15 deletions src/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,28 @@ const { X_LEFT, X_RIGHT, Y_DOWN, MAX_GISTS, DEFAULT_THEME, DEFAULT_TITLE, CARD_W
* @param {string} query.theme Theme name
* @param {number} query.n Number of gists to display
* @param {string} query.title Title of the card
* @param {Object[]} gists_response Gists response
* @param {Object[]} gistsResponse Gists response
* @returns {Object} Card object
*/
export const getCard = (query, gists_response) => {
export const getCard = (query, gistsResponse) => {
const { theme = DEFAULT_THEME, n = MAX_GISTS, title = DEFAULT_TITLE } = query; // get query parameters
let gists = []; // array of gists
let x = X_LEFT; // x position of gist
let y = 0; // y position of gist
let i = 0; // counter
let newLine = false; // new line flag

gists_response.filter((gist) => gist.public).some((gist) => {
gistsResponse.filter((gist) => gist.public).some((gist) => {
let filename = Object.keys(gist.files)[0]; // gist filename
let language = gist.files[filename].language; // gist language
let lang_color = getLanguageColor(language); // gist language color
let langColor = getLanguageColor(language); // gist language color

gists.push({
"filename": filename, // gist filename
"language": language, // gist language
"lang_color": lang_color, // gist language color
"y" : y, // y position of gist
"x" : x // x position of gist
filename: filename, // gist filename
language: language, // gist language
langColor: langColor, // gist language color
y: y, // y position of gist
x: x // x position of gist
});

if (x == X_LEFT && !newLine) {
Expand All @@ -63,12 +63,12 @@ export const getCard = (query, gists_response) => {
height = (i % 2 == 0) ? height - Y_DOWN : height; // height of the card

return { // card
"theme": getTheme(theme), // theme
"gists": gists,
"value": {
"title": title || DEFAULT_TITLE,
"height": height,
"width": CARD_WIDTH
theme: getTheme(theme), // theme
gists: gists,
value: {
title: title || DEFAULT_TITLE,
height: height,
width: CARD_WIDTH
}
};
};
2 changes: 1 addition & 1 deletion src/gistsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dotenv.config(); // load environment variables
* @returns {Promise<{data: any[]}>} Gists object
*/
export const getGists = async (user) => {
const req = await $fetch(`https://api.github.com/users/${user}/gists`, { headers: { Authorization: `Bearer ${process.env.token}` } }).catch(() => null);
const req = await $fetch(`https://api.github.com/users/${user}/gists`, { headers: { Authorization: `Bearer ${process.env.token}` } }).catch(() => null);

if (!req || !req.length) return [];
return req;
Expand Down
Loading

0 comments on commit ece56d8

Please sign in to comment.