Skip to content

Commit 13c45b7

Browse files
committed
chore: 🚀 add eslint config and cleanups
1 parent b4f703f commit 13c45b7

File tree

9 files changed

+45
-25
lines changed

9 files changed

+45
-25
lines changed

.eslintignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.eslintrc.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"extends": ["next/core-web-vitals", "eslint:recommended"],
3+
"plugins": ["unused-imports"],
4+
"rules": {
5+
"@next/next/no-html-link-for-pages": "off",
6+
"@next/next/no-img-element": "off",
7+
"no-unused-vars": 1,
8+
"unused-imports/no-unused-imports": "error",
9+
"unused-imports/no-unused-vars": [
10+
"warn",
11+
{
12+
"vars": "all",
13+
"varsIgnorePattern": "^_",
14+
"args": "after-used",
15+
"argsIgnorePattern": "^_"
16+
}
17+
]
18+
}
19+
}

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"dev": "faust dev",
77
"build": "faust build",
88
"generate": "faust generatePossibleTypes",
9-
"start": "faust start"
9+
"start": "faust start",
10+
"lint": "next lint"
1011
},
1112
"dependencies": {
1213
"@apollo/client": "^3.6.6",
@@ -20,5 +21,10 @@
2021
"react": "^17.0.2",
2122
"react-dom": "^17.0.2",
2223
"sass": "^1.54.9"
24+
},
25+
"devDependencies": {
26+
"eslint": "8.26.0",
27+
"eslint-config-next": "13.0.1",
28+
"eslint-plugin-unused-imports": "^2.0.0"
2329
}
2430
}

pages/example.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ export default function Page(props) {
1818
});
1919
const title = props.title;
2020

21-
const { title: siteTitle, description: siteDescription } = data?.generalSettings;
21+
const { title: siteTitle, description: siteDescription } =
22+
data?.generalSettings ?? {};
2223
const primaryMenu = data?.headerMenuItems?.nodes ?? [];
2324
const footerMenu = data?.footerMenuItems?.nodes ?? [];
2425

@@ -33,7 +34,7 @@ export default function Page(props) {
3334
<Main>
3435
<Container>
3536
<Hero title={title} />
36-
<div className="text-center">
37+
<div className='text-center'>
3738
<p>This page is utilizing the Next.js File based routes.</p>
3839
<code>pages/example.js</code>
3940
</div>
@@ -70,10 +71,13 @@ Page.query = gql`
7071
Page.variables = () => {
7172
return {
7273
headerLocation: MENUS.PRIMARY_LOCATION,
73-
footerLocation: MENUS.FOOTER_LOCATION
74+
footerLocation: MENUS.FOOTER_LOCATION,
7475
};
7576
};
7677

7778
export function getStaticProps(ctx) {
78-
return getNextStaticProps(ctx, {Page, props: {title: 'File Page Example'}});
79+
return getNextStaticProps(ctx, {
80+
Page,
81+
props: { title: 'File Page Example' },
82+
});
7983
}

utilities/flatListToHierarchical.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
export default function flatListToHierarchical(
22
data = [],
3-
{
4-
idKey = 'id',
5-
parentKey = 'parentId',
6-
childrenKey = 'children'
7-
} = {}
3+
{ idKey = 'id', parentKey = 'parentId', childrenKey = 'children' } = {}
84
) {
95
const tree = [];
106
const childrenOf = {};
117

128
data.forEach((item) => {
13-
const newItem = {...item};
14-
const {
15-
[idKey]: id,
16-
[parentKey]: parentId = 0
17-
} = newItem;
9+
const newItem = { ...item };
10+
const { [idKey]: id, [parentKey]: parentId = 0 } = newItem;
1811

1912
childrenOf[id] = childrenOf[id] || [];
2013
newItem[childrenKey] = childrenOf[id];
@@ -25,4 +18,4 @@ export default function flatListToHierarchical(
2518
});
2619

2720
return tree;
28-
};
21+
}

wp-templates/category.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515

1616
export default function Component(props) {
1717
const { title: siteTitle, description: siteDescription } =
18-
props?.data?.generalSettings;
18+
props?.data?.generalSettings ?? {};
1919
const primaryMenu = props?.data?.headerMenuItems?.nodes ?? [];
2020
const footerMenu = props?.data?.footerMenuItems?.nodes ?? [];
2121
const { name, posts } = props.data.nodeByUri;
@@ -34,6 +34,7 @@ export default function Component(props) {
3434
<Container>
3535
{posts.edges.map((post) => (
3636
<Post
37+
key={post.node.id}
3738
title={post.node.title}
3839
content={post.node.content}
3940
date={post.node.date}

wp-templates/page.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import {
55
Header,
66
Footer,
77
Main,
8-
Container,
98
ContentWrapper,
10-
EntryHeader,
119
NavigationMenu,
1210
FeaturedImage,
1311
SEO,
@@ -20,10 +18,10 @@ export default function Component(props) {
2018
}
2119

2220
const { title: siteTitle, description: siteDescription } =
23-
props?.data?.generalSettings;
21+
props?.data?.generalSettings ?? {};
2422
const primaryMenu = props?.data?.headerMenuItems?.nodes ?? [];
2523
const footerMenu = props?.data?.footerMenuItems?.nodes ?? [];
26-
const { title, content, featuredImage } = props?.data?.page ?? { title: '' };
24+
const { content, featuredImage } = props?.data?.page ?? { title: '' };
2725

2826
return (
2927
<>

wp-templates/single.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default function Component(props) {
2020
}
2121

2222
const { title: siteTitle, description: siteDescription } =
23-
props?.data?.generalSettings;
23+
props?.data?.generalSettings ?? {};
2424
const primaryMenu = props?.data?.headerMenuItems?.nodes ?? [];
2525
const footerMenu = props?.data?.footerMenuItems?.nodes ?? [];
2626
const { title, content, featuredImage, date, author } = props.data.post;

wp-templates/tag.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515

1616
export default function Component(props) {
1717
const { title: siteTitle, description: siteDescription } =
18-
props?.data?.generalSettings;
18+
props?.data?.generalSettings ?? {};
1919
const primaryMenu = props?.data?.headerMenuItems?.nodes ?? [];
2020
const footerMenu = props?.data?.footerMenuItems?.nodes ?? [];
2121
const { name, posts } = props.data.nodeByUri;
@@ -34,6 +34,7 @@ export default function Component(props) {
3434
<Container>
3535
{posts.edges.map((post) => (
3636
<Post
37+
key={post.node.id}
3738
title={post.node.title}
3839
content={post.node.content}
3940
date={post.node.date}

0 commit comments

Comments
 (0)