Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Yizack committed Jan 3, 2024
1 parent fc06f91 commit 335f5b1
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 52 deletions.
29 changes: 29 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = {
"env": {
"node": true,
"es2021": true,
"jest": true
},
"extends": "eslint:recommended",
"overrides": [
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {
"indent": ["error", 2],
"linebreak-style": ["error", process.platform === "win32" ? "windows" : "unix"],
"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",
}
};
41 changes: 0 additions & 41 deletions .eslintrc.json

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
},
"scripts": {
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage --verbose",
"docs": "jsdoc -c jsdoc.conf.json -r"
"docs": "jsdoc -c jsdoc.conf.json -r",
"lint": "eslint --ext .ts,.js --fix --ignore-path .gitignore ."
},
"dependencies": {
"axios": "^1.6.3",
Expand Down
6 changes: 3 additions & 3 deletions src/card.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @module Card
* @module Card
* @requires constants
* @requires functions
*/
Expand All @@ -15,7 +15,7 @@ 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 object
* @param {Object} gists_response Gists response object
* @param {Object[]} gists_response.data Gists data
* @returns {Object} Card object
*/
Expand All @@ -31,7 +31,7 @@ export const getCard = (query, gists_response) => {
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

gists.push({
"filename": filename, // gist filename
"language": language, // gist language
Expand Down
8 changes: 4 additions & 4 deletions src/functions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @module functions
/**
* @module functions
* @requires module
*/
import { createRequire } from "module";
Expand All @@ -8,10 +8,10 @@ const require = createRequire(import.meta.url);
const languages = require("./../resources/language_colors.json");
const themes = require("./../resources/themes.json");

/**
/**
* Returns the language hex color code from the language_colors.json file
* @function
* @param {string} name Name of the language
* @param {string} name Name of the language
* @returns {string} Hex color code
*/
export const getLanguageColor = (name) => { // export language color
Expand Down
4 changes: 2 additions & 2 deletions src/pin.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const { DEFAULT_THEME, BREAK_SIZE, PIN_WIDTH, PIN_HEIGHT, PIN_STATS_Y, CHARS_WRA
* @param {string} query.user User name
* @param {string} query.theme Theme name
* @param {boolean} query.owner Owner flag
* @param {Object} gist_response Gist response object
* @param {Object} gist_response Gist response object
* @param {Object} gist_response.data Gist data
* @returns {Object} Pin object
*/
Expand All @@ -43,7 +43,7 @@ export const getPin = async (query, gist_response) => {

let stars = 0;
let forks = 0;

try {
await axios.get(`https://gist.github.com/${user}/${id}/stargazers`).then((dom) => {
const { document } = parseHTML(dom.data);
Expand Down
2 changes: 1 addition & 1 deletion tests/wrapDescription.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe("wrapDescription", () => {
let description = wrapDescription("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", 60);

expect(description).toBe("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed</tspan><tspan dy=\"1.2em\" x=\"25\">do eiusmod tempor incididunt ut labore et dolore magna</tspan><tspan dy=\"1.2em\" x=\"25\">aliqua. Ut enim ad minim veniam, quis nostrud exercitation</tspan><tspan dy=\"1.2em\" x=\"25\">ullamco laboris nisi ut aliquip ex ea commodo consequat.");

expect((description.match(/dy/g) || []).length).toBe(3);
});
});

1 comment on commit 335f5b1

@vercel
Copy link

@vercel vercel bot commented on 335f5b1 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.