Skip to content

Commit ece56d8

Browse files
committed
chore: lint
1 parent aa924e4 commit ece56d8

14 files changed

+269
-130
lines changed

eslint.config.mjs

+43-24
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,50 @@
1-
import eslint from "@eslint/js";
1+
import path from "node:path";
2+
import { fileURLToPath } from "node:url";
3+
import { includeIgnoreFile } from "@eslint/compat";
4+
import stylistic from "@stylistic/eslint-plugin";
5+
6+
const __filename = fileURLToPath(import.meta.url);
7+
const __dirname = path.dirname(__filename);
8+
const gitignorePath = path.resolve(__dirname, ".gitignore");
29

310
export default [
11+
includeIgnoreFile(gitignorePath),
412
{
5-
files: ["**/*.js"],
6-
ignores: [
7-
"node_modules/**/*",
8-
"build/**/*",
9-
"dist/**/*",
10-
".output/**/*",
11-
"docs/**/*",
12-
],
13+
files: ["**/*.js", "**/*.mjs"],
14+
plugins: {
15+
"@stylistic": stylistic
16+
},
1317
rules: {
14-
...eslint.configs.recommended.rules,
15-
"indent": ["error", 2, { "SwitchCase": 1 }],
16-
"linebreak-style": ["error", "windows"],
17-
"quotes": ["error", "double"],
18-
"semi": ["error", "always"],
19-
"camelcase": "off",
20-
"arrow-spacing": ["error", { "before": true, "after": true }],
21-
"no-console": ["error", {
22-
"allow": ["info", "warn"]
23-
}],
24-
"brace-style": ["error", "stroustrup", { "allowSingleLine": true }],
25-
"no-multi-spaces": "error",
26-
"space-before-blocks": "error",
27-
"no-trailing-spaces": "error",
28-
"no-undef": "off"
18+
"camelcase": ["error"],
19+
"no-console": ["error", { allow: ["info", "warn"] }],
20+
"@stylistic/indent": ["error", 2, { SwitchCase: 1 }],
21+
"@stylistic/linebreak-style": ["error", process.platform === "win32" ? "windows" : "unix"],
22+
"@stylistic/quotes": ["error", "double"],
23+
"@stylistic/semi": ["error", "always"],
24+
"@stylistic/no-extra-semi": "error",
25+
"@stylistic/comma-dangle": ["error", "never"],
26+
"@stylistic/space-before-function-paren": ["error", "always"],
27+
"@stylistic/multiline-ternary": ["error", "never"],
28+
"@stylistic/member-delimiter-style": ["error", { multiline: { delimiter: "semi" }, singleline: { delimiter: "comma" } }],
29+
"@stylistic/arrow-spacing": ["error", { before: true, after: true }],
30+
"@stylistic/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
31+
"@stylistic/no-multi-spaces": "error",
32+
"@stylistic/space-before-blocks": "error",
33+
"@stylistic/no-trailing-spaces": "error",
34+
"@stylistic/array-bracket-spacing": ["error", "never"],
35+
"@stylistic/block-spacing": ["error", "always"],
36+
"@stylistic/comma-spacing": ["error", { after: true, before: false }],
37+
"@stylistic/comma-style": ["error", "last"],
38+
"@stylistic/key-spacing": ["error", { afterColon: true, beforeColon: false }],
39+
"@stylistic/keyword-spacing": ["error", { after: true, before: true }],
40+
"@stylistic/object-curly-newline": "off",
41+
"@stylistic/object-curly-spacing": ["error", "always"],
42+
"@stylistic/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
43+
"@stylistic/one-component-per-file": "off",
44+
"@stylistic/require-default-prop": "off",
45+
"@stylistic/space-in-parens": ["error", "never"],
46+
"@stylistic/template-curly-spacing": "error",
47+
"@stylistic/quote-props": ["error", "consistent-as-needed"]
2948
}
3049
}
3150
];

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
"lint": "eslint --fix"
2626
},
2727
"devDependencies": {
28+
"@eslint/compat": "^1.2.1",
29+
"@stylistic/eslint-plugin": "^2.9.0",
2830
"@vitest/coverage-v8": "^2.1.3",
2931
"clean-jsdoc-theme": "^4.3.0",
3032
"dotenv": "^16.4.5",

pnpm-lock.yaml

+118
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/themes.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"default": {
3-
"primary_color": "0969da",
4-
"text_color": "434d58",
5-
"bg_color": "fffefe",
6-
"icon_color": "586069",
7-
"border_color": "e4e2e2"
3+
"primaryColor": "0969da",
4+
"textColor": "434d58",
5+
"bgColor": "fffefe",
6+
"iconColor": "586069",
7+
"borderColor": "e4e2e2"
88
},
99
"dark": {
10-
"primary_color": "58a6ff",
11-
"text_color": "c9d1d9",
12-
"bg_color": "0d1117",
13-
"icon_color": "58a6ff",
14-
"border_color": "30363d"
10+
"primaryColor": "58a6ff",
11+
"textColor": "c9d1d9",
12+
"bgColor": "0d1117",
13+
"iconColor": "58a6ff",
14+
"borderColor": "30363d"
1515
}
1616
}

src/card.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,28 @@ const { X_LEFT, X_RIGHT, Y_DOWN, MAX_GISTS, DEFAULT_THEME, DEFAULT_TITLE, CARD_W
1515
* @param {string} query.theme Theme name
1616
* @param {number} query.n Number of gists to display
1717
* @param {string} query.title Title of the card
18-
* @param {Object[]} gists_response Gists response
18+
* @param {Object[]} gistsResponse Gists response
1919
* @returns {Object} Card object
2020
*/
21-
export const getCard = (query, gists_response) => {
21+
export const getCard = (query, gistsResponse) => {
2222
const { theme = DEFAULT_THEME, n = MAX_GISTS, title = DEFAULT_TITLE } = query; // get query parameters
2323
let gists = []; // array of gists
2424
let x = X_LEFT; // x position of gist
2525
let y = 0; // y position of gist
2626
let i = 0; // counter
2727
let newLine = false; // new line flag
2828

29-
gists_response.filter((gist) => gist.public).some((gist) => {
29+
gistsResponse.filter((gist) => gist.public).some((gist) => {
3030
let filename = Object.keys(gist.files)[0]; // gist filename
3131
let language = gist.files[filename].language; // gist language
32-
let lang_color = getLanguageColor(language); // gist language color
32+
let langColor = getLanguageColor(language); // gist language color
3333

3434
gists.push({
35-
"filename": filename, // gist filename
36-
"language": language, // gist language
37-
"lang_color": lang_color, // gist language color
38-
"y" : y, // y position of gist
39-
"x" : x // x position of gist
35+
filename: filename, // gist filename
36+
language: language, // gist language
37+
langColor: langColor, // gist language color
38+
y: y, // y position of gist
39+
x: x // x position of gist
4040
});
4141

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

6565
return { // card
66-
"theme": getTheme(theme), // theme
67-
"gists": gists,
68-
"value": {
69-
"title": title || DEFAULT_TITLE,
70-
"height": height,
71-
"width": CARD_WIDTH
66+
theme: getTheme(theme), // theme
67+
gists: gists,
68+
value: {
69+
title: title || DEFAULT_TITLE,
70+
height: height,
71+
width: CARD_WIDTH
7272
}
7373
};
7474
};

src/gistsList.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dotenv.config(); // load environment variables
1515
* @returns {Promise<{data: any[]}>} Gists object
1616
*/
1717
export const getGists = async (user) => {
18-
const req = await $fetch(`https://api.github.com/users/${user}/gists`, { headers: { Authorization: `Bearer ${process.env.token}` } }).catch(() => null);
18+
const req = await $fetch(`https://api.github.com/users/${user}/gists`, { headers: { Authorization: `Bearer ${process.env.token}` } }).catch(() => null);
1919

2020
if (!req || !req.length) return [];
2121
return req;

0 commit comments

Comments
 (0)