Skip to content

Commit 1a4d4dd

Browse files
author
Predrag
authored
Configure eslint and resolve reported errors (#34)
1 parent 26be763 commit 1a4d4dd

File tree

8 files changed

+1270
-218
lines changed

8 files changed

+1270
-218
lines changed

.eslintrc.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
browser: true,
5+
es2020: true,
6+
jest: true,
7+
node: true,
8+
},
9+
extends: ["eslint:recommended", "plugin:react/recommended"],
10+
parserOptions: {
11+
ecmaVersion: 2020,
12+
sourceType: "module",
13+
ecmaFeatures: {
14+
jsx: true,
15+
},
16+
},
17+
settings: {
18+
react: {
19+
version: "detect",
20+
},
21+
},
22+
ignorePatterns: ["public", "gatsby-node.js"],
23+
plugins: ["react-refresh", "react"],
24+
rules: {
25+
"react-refresh/only-export-components": [
26+
"warn",
27+
{ allowConstantExport: true },
28+
],
29+
"react/no-unescaped-entities": "off",
30+
"react/prop-types": "off",
31+
},
32+
};

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@
3333
},
3434
"devDependencies": {
3535
"babel-eslint": "10.1.0",
36-
"eslint": "7.24.0",
37-
"eslint-plugin-react": "7.23.2",
36+
"eslint": "^8.56.0",
37+
"eslint-plugin-react": "^7.37.5",
38+
"eslint-plugin-react-refresh": "^0.4.5",
3839
"gh-pages": "^3.1.0"
3940
},
4041
"dependencies": {

src/components/AuthorPost.js

Lines changed: 89 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,103 @@
1-
import React from 'react'
1+
import React from "react";
22

3-
export default function AuthorPost({post}) {
3+
export default function AuthorPost({ post }) {
4+
const { authors } = post;
45

5-
const {authors} = post
6-
7-
if (typeof authors[1] === "object") {
8-
return (
9-
<div className="flex flex-start">
10-
{post.authors.map((item, idx) => {
11-
return (
12-
<section className="flex flew-row mb-6 mr-4">
13-
<div className="relative">
14-
<div
15-
className="rounded-full bg-sdv-highlight top-0 left-0"
16-
style={{
17-
width: "49px",
18-
height: "49px",
19-
}}
20-
>
21-
<div
22-
className="overflow-hidden rounded-full absolute bottom-0 right-0"
23-
style={{
24-
width: "46px",
25-
height: "46px",
26-
}}
27-
>
28-
{item.profile_image ? (
29-
<img
30-
width={46}
31-
height={46}
32-
className="block rounded-full relative z-10 object-cover h-full"
33-
src={
34-
item.profile_image
35-
}
36-
alt={item.name}
37-
/>
38-
) : (
39-
<img
40-
width={46}
41-
height={46}
42-
className="block rounded-full relative z-10 object-cover h-full"
43-
src="/blog/images/icons/avatar.svg"
44-
alt={item.name}
45-
/>
46-
)}
47-
</div>
48-
</div>
49-
</div>
50-
<div className="text-xs px-4 flex flex-col justify-center">
51-
<p className="text-sm">
52-
<strong className="font-bold ">{item.name}</strong>
53-
</p>
54-
</div>
55-
</section>
56-
)
57-
})}
58-
</div>
59-
)
60-
}
61-
62-
return (
63-
<section className="flex flew-row mb-6">
64-
<div className="relative">
65-
<div
66-
className="rounded-full bg-sdv-highlight top-0 left-0"
67-
style={{
68-
width: "48px",
69-
height: "48px",
70-
}}
71-
>
72-
<div
73-
className="overflow-hidden rounded-full absolute bottom-0 right-0"
6+
if (typeof authors[1] === "object") {
7+
return (
8+
<div className="flex flex-start">
9+
{post.authors.map((item) => {
10+
return (
11+
<section key={item.name} className="flex flew-row mb-6 mr-4">
12+
<div className="relative">
13+
<div
14+
className="rounded-full bg-sdv-highlight top-0 left-0"
7415
style={{
16+
width: "49px",
17+
height: "49px",
18+
}}
19+
>
20+
<div
21+
className="overflow-hidden rounded-full absolute bottom-0 right-0"
22+
style={{
7523
width: "46px",
7624
height: "46px",
77-
}}
78-
>
79-
{post.primary_author.profile_image ? (
25+
}}
26+
>
27+
{item.profile_image ? (
8028
<img
81-
width={46}
82-
height={46}
83-
className="block rounded-full relative z-10 object-cover h-full"
84-
src={
85-
post.primary_author
86-
.profile_image
87-
}
88-
alt={post.primary_author.name}
29+
width={46}
30+
height={46}
31+
className="block rounded-full relative z-10 object-cover h-full"
32+
src={item.profile_image}
33+
alt={item.name}
8934
/>
90-
) : (
35+
) : (
9136
<img
92-
width={46}
93-
height={46}
94-
className="block rounded-full relative z-10 object-cover h-full"
95-
src="/blog/images/icons/avatar.svg"
96-
alt={post.primary_author.name}
37+
width={46}
38+
height={46}
39+
className="block rounded-full relative z-10 object-cover h-full"
40+
src="/blog/images/icons/avatar.svg"
41+
alt={item.name}
9742
/>
98-
)}
43+
)}
44+
</div>
45+
</div>
9946
</div>
47+
<div className="text-xs px-4 flex flex-col justify-center">
48+
<p className="text-sm">
49+
<strong className="font-bold ">{item.name}</strong>
50+
</p>
51+
</div>
52+
</section>
53+
);
54+
})}
55+
</div>
56+
);
57+
}
58+
59+
return (
60+
<section className="flex flew-row mb-6">
61+
<div className="relative">
62+
<div
63+
className="rounded-full bg-sdv-highlight top-0 left-0"
64+
style={{
65+
width: "48px",
66+
height: "48px",
67+
}}
68+
>
69+
<div
70+
className="overflow-hidden rounded-full absolute bottom-0 right-0"
71+
style={{
72+
width: "46px",
73+
height: "46px",
74+
}}
75+
>
76+
{post.primary_author.profile_image ? (
77+
<img
78+
width={46}
79+
height={46}
80+
className="block rounded-full relative z-10 object-cover h-full"
81+
src={post.primary_author.profile_image}
82+
alt={post.primary_author.name}
83+
/>
84+
) : (
85+
<img
86+
width={46}
87+
height={46}
88+
className="block rounded-full relative z-10 object-cover h-full"
89+
src="/blog/images/icons/avatar.svg"
90+
alt={post.primary_author.name}
91+
/>
92+
)}
10093
</div>
94+
</div>
10195
</div>
10296
<div className="text-xs px-4 flex flex-col justify-center">
103-
<p className="text-sm">
104-
<strong className="font-bold">{post.primary_author.name}</strong>
105-
</p>
97+
<p className="text-sm">
98+
<strong className="font-bold">{post.primary_author.name}</strong>
99+
</p>
106100
</div>
107-
</section>
108-
)
109-
}
101+
</section>
102+
);
103+
}

src/components/FeaturedArticle.js

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,57 @@
11
import React from "react";
22
import { Link } from "gatsby";
3-
import Img from "gatsby-image";
43

5-
import AuthorCard from "./AuthorCard"
4+
import AuthorCard from "./AuthorCard";
65

76
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
87
import { faArrowRight } from "@fortawesome/free-solid-svg-icons";
98

10-
export default function FeaturedArticle({ post, featuredImg }) {
11-
return (
12-
<>
13-
<Link to={post.slug} className="link-wrap flex flex-wrap rounded-10 relative w-full">
14-
<div
15-
className="w-full md:w-5/12 overflow-hidden
9+
export default function FeaturedArticle({ post }) {
10+
return (
11+
<>
12+
<Link
13+
to={post.slug}
14+
className="link-wrap flex flex-wrap rounded-10 relative w-full"
15+
>
16+
<div
17+
className="w-full md:w-5/12 overflow-hidden
1618
rounded-tl-10 md:rounded-bl-10 rounded-tr-10 md:rounded-tr-none
1719
border border-t-stroke border-b-none md:border-b-stroke border-l-stroke border-r-stroke md:border-r-0
1820
bg-white justify-center relative z-10"
19-
>
20-
<div className="w-full feature-image relative h-full pb-pimg-sm md:pb-pimg-md"><img src={post.feature_image} className="absolute inset-0 md:w-full h-full object-cover object-center" alt={post.title}></img></div>
21-
</div>
22-
<div
23-
className="bg-white w-full md:w-7/12 xl:pl-28
21+
>
22+
<div className="w-full feature-image relative h-full pb-pimg-sm md:pb-pimg-md">
23+
<img
24+
src={post.feature_image}
25+
className="absolute inset-0 md:w-full h-full object-cover object-center"
26+
alt={post.title}
27+
></img>
28+
</div>
29+
</div>
30+
<div
31+
className="bg-white w-full md:w-7/12 xl:pl-28
2432
lg:pl-20 md:pl-5 md:pr-5 lg:pr-10 pr-5 pl-5 md:py-10 py-5
2533
md:rounded-r-10
2634
md:rounded-bl-none
2735
rounded-bl-10 rounded-br-10
2836
border-r border-b border-l border-t-none md:border-t
2937
relative z-10"
30-
>
31-
<AuthorCard post={post} />
32-
<div>
33-
<h3 className="text-sdv-heading mb-4 leading-none">
34-
{post.title}{" "}
35-
</h3>
36-
<p className="text-sdv-subheading font-light mb-3">
37-
{post.excerpt}
38-
</p>
39-
<p>
40-
<div
41-
className="read-more font-bold cursor-pointer"
42-
>
43-
Read more{" "}
44-
<FontAwesomeIcon width="16" icon={faArrowRight} />
45-
</div>
46-
</p>
47-
</div>
48-
</div>
49-
</Link> </>
50-
);
38+
>
39+
<AuthorCard post={post} />
40+
<div>
41+
<h3 className="text-sdv-heading mb-4 leading-none">
42+
{post.title}{" "}
43+
</h3>
44+
<p className="text-sdv-subheading font-light mb-3">
45+
{post.excerpt}
46+
</p>
47+
<p>
48+
<div className="read-more font-bold cursor-pointer">
49+
Read more <FontAwesomeIcon width="16" icon={faArrowRight} />
50+
</div>
51+
</p>
52+
</div>
53+
</div>
54+
</Link>{" "}
55+
</>
56+
);
5157
}

src/components/common/ScarfPixel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const ScarfPixel = () => {
66
{typeof window !== "undefined" &&
77
window.location.hostname === "sdv.dev" ? (
88
<img
9-
referrerpolicy="no-referrer-when-downgrade"
9+
referrerPolicy="no-referrer-when-downgrade"
1010
src="https://static.scarf.sh/a.png?x-pxid=af9a538f-69ef-4e05-8553-76897f21be21"
1111
alt="scarf"
1212
/>

src/components/community-stats/CommunityStatsContent.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ export default function CommunityStatsContent() {
1616
const fileUrl =
1717
"https://raw.githubusercontent.com/sdv-dev/sdv-dev.github.io/gatsby-home/assets/Downloads_Summary.xlsx";
1818

19+
function formatThousands(value) {
20+
if (value >= 1000000)
21+
return (value / 1000000).toFixed(2).replace(/\.00$/, "") + "M";
22+
if (value >= 1000) return (value / 1000).toFixed(0) + "K";
23+
return value.toString();
24+
}
25+
1926
useEffect(() => {
2027
async function fetchExcel() {
2128
try {
@@ -32,13 +39,6 @@ export default function CommunityStatsContent() {
3239
const rawData = XLSX.utils.sheet_to_json(worksheet);
3340
const rawDependencies = XLSX.utils.sheet_to_json(dependenciesWorksheet);
3441

35-
function formatThousands(value) {
36-
if (value >= 1_000_000)
37-
return (value / 1_000_000).toFixed(2).replace(/\.00$/, "") + "M";
38-
if (value >= 1_000) return (value / 1_000).toFixed(0) + "K";
39-
return value.toString();
40-
}
41-
4242
const filtered = rawData.filter(
4343
(item) =>
4444
item["Total Since Beginning"] !== undefined &&

src/components/sd-gym/SdGymContent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import AboutSdGym from "./AboutSdGym";
99
export default function SdGymContent() {
1010
const [data, setData] = useState([]);
1111
const [dateTags, setDateTags] = useState([]);
12-
const activeDateTag = dateTags.find((dt) => dt.active);
12+
// const activeDateTag = dateTags.find((dt) => dt.active);
1313

1414
const fileUrl =
1515
"https://raw.githubusercontent.com/sdv-dev/sdv-dev.github.io/gatsby-home/assets/sdgym-leaderboard-files/SDGym Monthly Run.xlsx";

0 commit comments

Comments
 (0)