Skip to content

Commit

Permalink
fixing lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasheartcliff committed Jan 21, 2024
1 parent f48c06a commit 300a55b
Show file tree
Hide file tree
Showing 15 changed files with 72 additions and 104 deletions.
14 changes: 6 additions & 8 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
],
"rules": {
"prettier/prettier": [
"error",
"warn",
{
"singleQuote": true,
"endOfLine": "auto"
Expand Down Expand Up @@ -35,12 +35,13 @@
},
"rules": {
"prettier/prettier": [
"error",
"warn",
{
"singleQuote": true,
"endOfLine": "auto"
}
],
"no-continue": "off",
"react/destructuring-assignment": "off", // Vscode doesn't support automatically destructuring, it's a pain to add a new variable
"react/require-default-props": "off", // Allow non-defined react props as undefined
"react/jsx-props-no-spreading": "off", // _app.tsx uses spread operator and also, react-hook-form
Expand All @@ -49,7 +50,7 @@
"@typescript-eslint/comma-dangle": "off", // Avoid conflict rule between Eslint and Prettier
"@typescript-eslint/consistent-type-imports": "error", // Ensure `import type` is used when it's necessary
"no-restricted-syntax": [
"error",
"warn",
"ForInStatement",
"LabeledStatement",
"WithStatement"
Expand All @@ -58,11 +59,8 @@
"simple-import-sort/imports": "error", // Import configuration for `eslint-plugin-simple-import-sort`
"simple-import-sort/exports": "error", // Export configuration for `eslint-plugin-simple-import-sort`
"@typescript-eslint/no-unused-vars": "off",
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"error",
{ "argsIgnorePattern": "^_" }
]
"unused-imports/no-unused-imports": "warn",
"unused-imports/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }]
}
},
// Configuration for testing
Expand Down
9 changes: 5 additions & 4 deletions src/components/CertificateCard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import ExportOutlined from "@ant-design/icons/ExportOutlined";
import Tooltip from "antd/lib/tooltip";
import React from "react";
import Link from "../Link";
import ExportOutlined from '@ant-design/icons/ExportOutlined';
import Tooltip from 'antd/lib/tooltip';
import React from 'react';

import Link from '../Link';

interface Props {
name: string;
Expand Down
4 changes: 2 additions & 2 deletions src/components/LanguageChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const buildState = (
textAnchor: 'end',
offsetX: 0,
offsetY: 0,
formatter(v) {
formatter(v: number) {
return `${v.toFixed(0)} h`;
},
dropShadow: {
Expand All @@ -59,7 +59,7 @@ const buildState = (
return `${val.toFixed(0)} hours worked`;
},
title: {
formatter(s) {
formatter() {
return '';
},
},
Expand Down
21 changes: 0 additions & 21 deletions src/components/Loading/Loading.tsx

This file was deleted.

9 changes: 0 additions & 9 deletions src/components/Loading/styled.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/ProjectCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function ProjectCard({
url,
}: Props) {
return (
<div className="w-46 flex h-28 flex-row items-center justify-center border p-4 shadow-lg">
<div className="flex h-28 w-44 flex-row items-center justify-center border p-4 shadow-lg">
<div className="w-full">
<div className="w-full overflow-hidden text-ellipsis whitespace-nowrap text-base font-semibold text-black">
<Tooltip title={name}>
Expand Down
12 changes: 6 additions & 6 deletions src/components/ProjectGrid/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from "react";
import React, { useState } from 'react';

import type { Props as CardProps } from "@/components/ProjectCard";
import ProjectCard from "@/components/ProjectCard";
import type { Props as CardProps } from '@/components/ProjectCard';
import ProjectCard from '@/components/ProjectCard';

interface Props {
items: CardProps[];
Expand All @@ -22,17 +22,17 @@ export default function ProjectGrid({

return (
<div className="flex flex-col items-center">
<div className="flex flex-wrap justify-items-start gap-1.5 w-full">
<div className="flex w-full flex-wrap justify-items-start gap-1.5">
{items.slice(0, visibleItems).map((item, index) => (
<ProjectCard key={index} {...item} />
))}
</div>
{visibleItems < items.length && (
<button
onClick={handleShowMore}
className="mt-4 rounded bg-blue-500 px-4 py-4 text-white"
className="mt-4 rounded bg-blue-500 p-4 text-white"
>
{"Show more projects..."}
{'Show more projects...'}
</button>
)}
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/components/Scroll/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import type { ScrollbarProps } from "react-custom-scrollbars-2";
import { Scrollbars } from "react-custom-scrollbars-2";
import React from 'react';
import type { ScrollbarProps } from 'react-custom-scrollbars-2';
import { Scrollbars } from 'react-custom-scrollbars-2';

interface Props extends ScrollbarProps {}

Expand Down
30 changes: 15 additions & 15 deletions src/components/Timeline/Item/index.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import CaretRightOutlined from "@ant-design/icons/CaretRightOutlined";
import Tooltip from "antd/lib/tooltip";
import moment from "moment";
import React from "react";
import CaretRightOutlined from '@ant-design/icons/CaretRightOutlined';
import Tooltip from 'antd/lib/tooltip';
import moment from 'moment';
import React from 'react';

interface Props {
title: string;
open: boolean;
startDate: string;
endTime?: string;
endDate?: string;
hasChildren?: boolean;
onClickToOpen?: (isOpen: boolean) => void;
}
export default function Item(props: Props) {
const DATE_FORMAT = "MMM YYYY";
const DATE_FORMAT = 'MMM YYYY';

const { title, open, startDate, endDate, hasChildren, onClickToOpen } = props;

function onClick() {
const v = !open;
onClickToOpen && onClickToOpen(v);
if (onClickToOpen) onClickToOpen(v);
}
function formatDuration() {
const start = moment(startDate);
Expand All @@ -28,24 +28,24 @@ export default function Item(props: Props) {

const years = duration.years();
const months = duration.months();
const days = duration.days();
// const days = duration.days();

let formattedString = "";
let formattedString = '';

if (years > 0) {
formattedString += `${years} ${years === 1 ? "year" : "years"}`;
formattedString += `${years} ${years === 1 ? 'year' : 'years'}`;
}

if (months > 0) {
formattedString += ` ${months} ${months === 1 ? "month" : "months"}`;
formattedString += ` ${months} ${months === 1 ? 'month' : 'months'}`;
}

formattedString = formattedString.trim();
return !formattedString ? "" : `(${formattedString.trim()})`;
return !formattedString ? '' : `(${formattedString.trim()})`;
}

const period = `${moment(startDate).format(DATE_FORMAT)} - ${
endDate ? moment(endDate).format(DATE_FORMAT) : "Now"
endDate ? moment(endDate).format(DATE_FORMAT) : 'Now'
} ${formatDuration()}`;

return (
Expand All @@ -66,13 +66,13 @@ export default function Item(props: Props) {

<div
className={` ml-5 items-end justify-center ${
!hasChildren ? "hidden" : ""
!hasChildren ? 'hidden' : ''
}`}
onClick={onClick}
>
<CaretRightOutlined
className={`text-base font-extrabold text-black ${
open ? "rotate-90" : ""
open ? 'rotate-90' : ''
}`}
/>
</div>
Expand Down
12 changes: 6 additions & 6 deletions src/components/Timeline/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function Timeline({ data }: Props) {
function nodesMapToList(map: Map<string, ItemNode>): ItemNode[] {
const result: { [k: number]: ItemNode } = {};

for (const item of map.values()) {
for (const item of Array.from(map.values())) {
result[item.order] = item;
}
return Object.values(result);
Expand Down Expand Up @@ -71,9 +71,9 @@ export default function Timeline({ data }: Props) {
order: count,
open: true,
});
count++;
count += 1;

if (hasChildren) {
if (hasChildren && parent.children?.length) {
for (const child of parent.children) {
key = `${i}.${j}`;
newNodeMap.set(key, {
Expand All @@ -83,11 +83,11 @@ export default function Timeline({ data }: Props) {
hasChildren: false,
isChild: true,
});
j++;
count++;
j += 1;
count += 1;
}
}
i++;
i += 1;
}
setNodeMap(newNodeMap);
setNodes(nodesMapToList(newNodeMap));
Expand Down
4 changes: 3 additions & 1 deletion src/layouts/Block.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';

interface Props {}
interface Props {
children: React.ReactNode;
}

export default function Block({ children }: Props) {
return <div className="flex flex-1 p-5">{children}</div>;
Expand Down
8 changes: 4 additions & 4 deletions src/layouts/Meta.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Head from "next/head";
import { useRouter } from "next/router";
import { NextSeo } from "next-seo";
import Head from 'next/head';
import { useRouter } from 'next/router';
import { NextSeo } from 'next-seo';

import { AppConfig } from "@/utils/AppConfig";
import { AppConfig } from '@/utils/AppConfig';

type IMetaProps = {
title: string;
Expand Down
6 changes: 4 additions & 2 deletions src/layouts/Row.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from 'react';

interface Props {}
interface Props {
children: React.ReactNode;
}

export default function Row({ children }: Props) {
return <div className="flex w-full flex-1 flex-row py-10">{children}</div>;
return <div className="flex w-full flex-1 flex-row py-10">{children}</div>;
}
31 changes: 13 additions & 18 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ const LanguageChart = dynamic(() => import('@/components/LanguageChart'), {

const Index = () => {
const router = useRouter();
const [data, setData] = useState([]);
const [githubProfile, setGithubProfile] = useState<any>({});
const [pinnedRepos, setPinnedRepos] = useState([]);
const [data, setData] = useState<any[]>([]);
const [pinnedRepos, setPinnedRepos] = useState<any[]>([]);

const {
name,
Expand All @@ -58,30 +57,30 @@ const Index = () => {
.then((responses) => {
return responses.map((r) => r.json());
})
.then(async ([repos, codingTime, languages]) => {
repos = await repos;
codingTime = await codingTime;
languages = await languages;
.then(async ([repos, codingTime, languages]: any[]) => {
const r = (await repos) as any;
const c = (await codingTime) as any;
const lang = (await languages) as any;
setPinnedRepos(
repos.map((v: any) => ({
r.map((v: any) => ({
...v,
url: GITHUB_REPO(username, v.name),
name: capitalize(v.name?.replace(/-/g, ' ')),
}))
);
const totalSeconds =
codingTime.data?.grand_total
?.total_seconds_including_other_language || 0;
c.data?.grand_total?.total_seconds_including_other_language || 0;

// Fixing data percentage
const totalPercentage =
languages.data?.reduce((acc: number, curr: any) => {
if (isProgrammingLanguage(curr.name)) acc += curr.percent;
return acc;
lang.data?.reduce((acc: number, curr: any) => {
let a = acc;
if (isProgrammingLanguage(curr.name)) a = curr.percent;
return a;
}, 0) || 100;

const langData = [];
for (const l of languages.data || []) {
for (const l of lang.data || []) {
if (!isProgrammingLanguage(l.name) || !l.percent) continue;
langData.push({
...l,
Expand All @@ -96,7 +95,6 @@ const Index = () => {
.getJsonP()
.then((r) => r.json())
.then((d) => {
console.log('profile', d.data);
setGithubProfile(d.data);
})
.catch((e) => console.error(e));
Expand Down Expand Up @@ -254,9 +252,6 @@ const Index = () => {
</div>
</Block>
</Row>
<Row>
<Block></Block>
</Row>
</div>
</Main>
</>
Expand Down
Loading

0 comments on commit 300a55b

Please sign in to comment.