Skip to content

Commit

Permalink
Merge pull request #113 from KoheiNishino/feature/set_up_eslint_and_p…
Browse files Browse the repository at this point in the history
…rettier

Feature/set up eslint and prettier
  • Loading branch information
KoheiNishino authored Jul 23, 2022
2 parents cf284b2 + 314e04d commit 7e61bac
Show file tree
Hide file tree
Showing 30 changed files with 1,935 additions and 454 deletions.
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.next/
node_modules/
coverage/
__snapshots__/
package-lock.json
57 changes: 57 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"extends": [
"airbnb",
"plugin:@typescript-eslint/recommended",
"next/core-web-vitals",
"prettier"
],
"plugins": ["import", "unused-imports"],
"rules": {
"@typescript-eslint/no-unused-vars": "off",
"unused-imports/no-unused-imports": "warn",
"import/extensions": "off",
"import/order": [
"error",
{
"groups": [
"builtin",
"external",
"internal",
["parent", "sibling"],
"object",
"type",
"index"
],
"newlines-between": "always",
"pathGroupsExcludedImportTypes": ["builtin"],
"alphabetize": {
"order": "asc",
"caseInsensitive": true
}
}
],
"react/jsx-filename-extension": [
"error",
{
"extensions": [".jsx", ".tsx"]
}
],
"react/function-component-definition": [
"error",
{ "namedComponents": "arrow-function" }
],
"react/require-default-props": "off",
"jsx-a11y/anchor-is-valid": [
"error",
{
"components": ["Link"],
"specialLink": ["hrefLeft", "hrefRight"],
"aspects": ["invalidHref", "preferButton"]
}
],
"react/jsx-no-useless-fragment": ["error", { "allowExpressions": true }],
"react/jsx-props-no-spreading": "off"
},
"overrides": [],
"ignorePatterns": ["node_modules"]
}
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Ignore artifacts:
build
coverage

# Ignore all HTML files:
*.html
*.md
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true
}
18 changes: 16 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
"dev": "NODE_OPTIONS='--inspect' next",
"build": "next build",
"start": "next start",
"typecheck": "tsc",
"postbuild": "next-sitemap"
"lint": "next lint --fix --dir src",
"format": "prettier --write .",
"postbuild": "next-sitemap",
"preinstall": "npx only-allow yarn"
},
"dependencies": {
"classnames": "2.3.1",
Expand All @@ -24,9 +26,21 @@
"@types/node": "^18.0.1",
"@types/react": "^17.0.43",
"@types/react-dom": "^17.0.13",
"@typescript-eslint/eslint-plugin": "^5.30.0",
"@typescript-eslint/parser": "^5.0.0",
"autoprefixer": "^10.4.7",
"eslint": "8.18.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-next": "12.1.6",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0",
"eslint-plugin-unused-imports": "^2.0.0",
"next-sitemap": "^2.5.28",
"postcss": "^8.4.14",
"prettier": "2.7.1",
"tailwindcss": "^3.1.4"
}
}
34 changes: 17 additions & 17 deletions public/favicon/site.webmanifest
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"name": "",
"short_name": "",
"icons": [
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
"name": "",
"short_name": "",
"icons": [
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
10 changes: 3 additions & 7 deletions src/components/container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ type Props = {
children?: ReactNode
}

const Container: FunctionComponent = ({ children }: Props) => {
return (
<div className="container mx-auto max-w-3xl px-5">
{children}
</div>
)
}
const Container: FunctionComponent = ({ children }: Props) => (
<div className="container mx-auto max-w-3xl px-5">{children}</div>
)

export default Container
9 changes: 6 additions & 3 deletions src/components/cover-image.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import cn from 'classnames'
import Image from 'next/image'
import Link from 'next/link'

type Props = {
Expand All @@ -9,24 +10,26 @@ type Props = {

const CoverImage = ({ title, src, slug }: Props) => {
const image = (
<img
<Image
src={src}
alt={`Cover Image for ${title}`}
layout="fill"
objectFit="contain"
className={cn('shadow-small', {
'hover:shadow-medium transition-shadow duration-200': slug,
})}
/>
)
return (
<div className="sm:mx-0">
<>
{slug ? (
<Link as={`/posts/${slug}`} href="/posts/[slug]">
<a aria-label={title}>{image}</a>
</Link>
) : (
image
)}
</div>
</>
)
}

Expand Down
29 changes: 14 additions & 15 deletions src/components/footer.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import Link from 'next/link'

import { BLOG_RELEASE_YEAR } from '@/lib/constants'

const Footer = () => {
return (
<footer className="text-secondary border-t border-solid border-opacity-10">
<div className="flex flex-col items-center">
<div className="text-sm md:text-lg py-5">
<Link href="/policy">
<a className="hover:underline" >Privacy Policy</a>
</Link>
</div>
<div className="text-sm md:text-lg pb-5">
© {BLOG_RELEASE_YEAR} Kohei Nishino
</div>
const Footer = () => (
<footer className="text-secondary border-t border-solid border-opacity-10">
<div className="flex flex-col items-center">
<div className="text-sm md:text-lg py-5">
<Link href="/policy">
<a className="hover:underline">Privacy Policy</a>
</Link>
</div>
<div className="text-sm md:text-lg pb-5">
© {BLOG_RELEASE_YEAR} Kohei Nishino
</div>
</footer>
)
}
</div>
</footer>
)

export default Footer
1 change: 1 addition & 0 deletions src/components/google-analytics.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Script from 'next/script'

import { GA_TRACKING_ID } from '@/lib/gtag'

const GoogleAnalytics = () => (
Expand Down
17 changes: 8 additions & 9 deletions src/components/header.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import Link from 'next/link'

import { BLOG_TITLE } from '@/lib/constants'

const Header = () => {
return (
<h2 className="text-2xl md:text-4xl font-bold tracking-tight md:tracking-tighter leading-tight mb-16 mt-8 mx-auto text-center sm:text-left">
<Link href="/">
<a>{BLOG_TITLE}</a>
</Link>
</h2>
)
}
const Header = () => (
<h2 className="text-2xl md:text-4xl font-bold tracking-tight md:tracking-tighter leading-tight mb-16 mt-8 mx-auto text-center sm:text-left">
<Link href="/">
<a>{BLOG_TITLE}</a>
</Link>
</h2>
)

export default Header
26 changes: 12 additions & 14 deletions src/components/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@ type Props = {
children: React.ReactNode
}

const Layout = ({ children }: Props) => {
return (
<>
<Meta />
<div className="min-h-screen">
<Container>
<Header />
<main>{children}</main>
<Footer />
</Container>
</div>
</>
)
}
const Layout = ({ children }: Props) => (
<>
<Meta />
<div className="min-h-screen">
<Container>
<Header />
<main>{children}</main>
<Footer />
</Container>
</div>
</>
)

export default Layout
2 changes: 1 addition & 1 deletion src/components/markdown-styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
}

.markdown p {
@apply whitespace-pre-wrap
@apply whitespace-pre-wrap;
}
61 changes: 37 additions & 24 deletions src/components/meta.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,42 @@
import Head from 'next/head'

import { BLOG_TITLE, BLOG_DESCRIPTION, BLOG_URL } from '@/lib/constants'

const Meta = () => {
return (
<Head>
<title>{BLOG_TITLE}</title>
<meta name="description" content={BLOG_DESCRIPTION} />
<meta property="og:url" content={BLOG_URL} />
<meta property="og:type" content="website" />
<meta property="og:title" content={BLOG_TITLE} />
<meta property="og:description" content={BLOG_DESCRIPTION} />
<meta property="og:site_name" content={BLOG_TITLE} />
<meta property="og:image" content={`${BLOG_URL}assets/og-image.jpeg`} />
<meta name="msapplication-TileColor" content="#000" />
<meta name="msapplication-config" content="/favicon/browserconfig.xml" />
<meta name="theme-color" content="#000" />
<link rel="apple-touch-icon" sizes="180x180" href="/favicon/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/favicon/favicon-16x16.png" />
<link rel="manifest" href="/favicon/site.webmanifest" />
<link rel="mask-icon" href="/favicon/safari-pinned-tab.svg" color="#000" />
<link rel="shortcut icon" href="/favicon/favicon.ico" />
<link rel="alternate" type="application/rss+xml" href="/feed.xml" />
</Head>
)
}
const Meta = () => (
<Head>
<title>{BLOG_TITLE}</title>
<meta name="description" content={BLOG_DESCRIPTION} />
<meta property="og:url" content={BLOG_URL} />
<meta property="og:type" content="website" />
<meta property="og:title" content={BLOG_TITLE} />
<meta property="og:description" content={BLOG_DESCRIPTION} />
<meta property="og:site_name" content={BLOG_TITLE} />
<meta property="og:image" content={`${BLOG_URL}assets/og-image.jpeg`} />
<meta name="msapplication-TileColor" content="#000" />
<meta name="msapplication-config" content="/favicon/browserconfig.xml" />
<meta name="theme-color" content="#000" />
<link
rel="apple-touch-icon"
sizes="180x180"
href="/favicon/apple-touch-icon.png"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="/favicon/favicon-32x32.png"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="/favicon/favicon-16x16.png"
/>
<link rel="manifest" href="/favicon/site.webmanifest" />
<link rel="mask-icon" href="/favicon/safari-pinned-tab.svg" color="#000" />
<link rel="shortcut icon" href="/favicon/favicon.ico" />
<link rel="alternate" type="application/rss+xml" href="/feed.xml" />
</Head>
)

export default Meta
Loading

1 comment on commit 7e61bac

@vercel
Copy link

@vercel vercel bot commented on 7e61bac Jul 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.