From d6c59b720a20a0b57657c29e9b4515d0da9b1c46 Mon Sep 17 00:00:00 2001 From: Abed Zantout Date: Mon, 6 Apr 2020 21:21:48 +0300 Subject: [PATCH] style(app): run prettier --- next.config.js | 2 +- pages/_app.tsx | 2 +- pages/index.tsx | 8 ++++---- pages/post/index.tsx | 4 ++-- .../components/tag-filters/tag-filters.component.tsx | 2 +- utils/contentful.js | 8 ++++---- utils/helpers.js | 4 ++-- utils/sitemap.js | 12 ++++++------ 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/next.config.js b/next.config.js index 617fe14..d4342bb 100644 --- a/next.config.js +++ b/next.config.js @@ -5,7 +5,7 @@ const Dotenv = require('dotenv-webpack'); const { generateAllArticles } = require('./utils/helpers'); const next_config = { - webpack: config => { + webpack: (config) => { config.plugins = config.plugins || []; config.plugins = [ diff --git a/pages/_app.tsx b/pages/_app.tsx index 4ee76d6..505c7dd 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -15,7 +15,7 @@ import { trackPageView } from '../core/gtag'; import Footer from '../shared/components/footer/footer.component'; import Header from '../shared/components/header/header.component'; -Router.events.on('routeChangeComplete', url => trackPageView(url)); +Router.events.on('routeChangeComplete', (url) => trackPageView(url)); class MyApp extends App { render() { diff --git a/pages/index.tsx b/pages/index.tsx index a038b12..9847b52 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -11,7 +11,7 @@ import Card from '../shared/components/card/card.component'; import Paginator from '../shared/components/paginator/paginator.component'; import TagFilters from '../shared/components/tag-filters/tag-filters.component'; -const calculateRange = length => Array.from({ length }, (v, k) => k + 1); +const calculateRange = (length) => Array.from({ length }, (v, k) => k + 1); type Props = { entries: BlogPost[]; @@ -23,7 +23,7 @@ type Props = { page?: number; }; -const cards = entries => +const cards = (entries) => entries.map((entry, index) => ); const IndexPage: NextPage = (props: Props) => { @@ -43,7 +43,7 @@ const IndexPage: NextPage = (props: Props) => { void router.push({ pathname: '/', query: { page: page, tag: tag } }); }, [page, tag]); - const handleTagChosen = tag => { + const handleTagChosen = (tag) => { updatePage(1); updateTag(tag); }; @@ -64,7 +64,7 @@ const IndexPage: NextPage = (props: Props) => {
updatePage(event)} + handlePaginationChange={(event) => updatePage(event)} range={range} skip={page} /> diff --git a/pages/post/index.tsx b/pages/post/index.tsx index 4367c4d..fdfc8bf 100644 --- a/pages/post/index.tsx +++ b/pages/post/index.tsx @@ -14,7 +14,7 @@ type Props = { suggestedArticles: BlogPost[]; }; -const renderCards = suggestions => +const renderCards = (suggestions) => suggestions.map((suggestion, index) => ( )); @@ -51,7 +51,7 @@ PostPage.getInitialProps = async ({ query }) => { const { post } = query; const article = await contentfulService.getPostBySlug(post); - const tags = article.tags ? article.tags.map(tag => tag.sys.id) : []; + const tags = article.tags ? article.tags.map((tag) => tag.sys.id) : []; const suggestedArticles = await contentfulService.fetchSuggestions( tags, diff --git a/shared/components/tag-filters/tag-filters.component.tsx b/shared/components/tag-filters/tag-filters.component.tsx index 62d1267..57e99b3 100644 --- a/shared/components/tag-filters/tag-filters.component.tsx +++ b/shared/components/tag-filters/tag-filters.component.tsx @@ -11,7 +11,7 @@ const TagFilters: FunctionComponent = ({ updatePage, selectedTagId }) => { - const handleTagChosen = tag => { + const handleTagChosen = (tag) => { updatePage(tag); }; diff --git a/utils/contentful.js b/utils/contentful.js index 0ad6ec8..3a2a168 100644 --- a/utils/contentful.js +++ b/utils/contentful.js @@ -105,14 +105,14 @@ const tagFields = [ } ]; -module.exports = function(migration, context) { +module.exports = function (migration, context) { const tag = migration.createContentType('tag', { name: 'Tag', description: 'tag', displayField: 'name' }); - tagFields.forEach(field => { + tagFields.forEach((field) => { tag.createField(field.id, { name: field.name, type: field.type, @@ -126,7 +126,7 @@ module.exports = function(migration, context) { displayField: 'name' }); - authorFields.forEach(field => { + authorFields.forEach((field) => { author.createField(field.id, { name: field.name, type: field.type, @@ -139,7 +139,7 @@ module.exports = function(migration, context) { displayField: 'title' }); - blogFields.forEach(field => { + blogFields.forEach((field) => { const options = { name: field.name, type: field.type, diff --git a/utils/helpers.js b/utils/helpers.js index f4f4f40..6937f11 100644 --- a/utils/helpers.js +++ b/utils/helpers.js @@ -27,10 +27,10 @@ const getAllArticles = async () => { }; exports.generateAllAuthors = async () => { const authors = await getAllAuthors(); - return authors.items.map(item => ({ ...item.fields })); + return authors.items.map((item) => ({ ...item.fields })); }; exports.generateAllArticles = async () => { const articles = await getAllArticles(); - return articles.items.map(item => ({ ...item.fields })); + return articles.items.map((item) => ({ ...item.fields })); }; diff --git a/utils/sitemap.js b/utils/sitemap.js index cb13e0f..e6020d6 100644 --- a/utils/sitemap.js +++ b/utils/sitemap.js @@ -9,9 +9,9 @@ const fs = require('fs'); const { exportPathMap } = require('../next.config'); const { generateAllArticles } = require('./helpers'); // Format to the right date -const formatDate = date => `${date.toISOString().split('.')[0]}+0:00`; +const formatDate = (date) => `${date.toISOString().split('.')[0]}+0:00`; // Priority is determined by path depth. Feel free to modify this if needed: -const getPriority = url => +const getPriority = (url) => url.includes('/our-insights') ? 0.9 : ((100 - (url.split('/').length - 2) * 10) / 100).toFixed(2); @@ -24,7 +24,7 @@ const xmlHeader = ` `; // Wrap all pages in tags -const xmlUrlWrapper = nodes => `${xmlHeader} +const xmlUrlWrapper = (nodes) => `${xmlHeader} ${nodes} `; @@ -54,14 +54,14 @@ exports.generateSitemap = async (domain, targetFolder) => { const entries = await exportPathMap(); - const pages = Object.entries({ ...entries }).map(item => item[0]); + const pages = Object.entries({ ...entries }).map((item) => item[0]); const sitemap = `${xmlUrlWrapper( - pages.map(page => xmlUrlNode(domain, page, lastModified)).join(` + pages.map((page) => xmlUrlNode(domain, page, lastModified)).join(` `) )}`; - fs.writeFile(`${writeLocation}`, sitemap, err => { + fs.writeFile(`${writeLocation}`, sitemap, (err) => { if (err) throw err; console.log( `sitemap.xml with ${pages.length} entries was written to ${targetFolder}${fileName}`