Skip to content

Commit 4eea807

Browse files
committed
use my own @dowdiness/eslint-config eslint config
1 parent 76258f6 commit 4eea807

20 files changed

+336
-229
lines changed

.eslintrc

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
11
{
2-
"extends": "@dowdiness"
2+
"extends": "@dowdiness",
3+
"rules": {
4+
"@typescript-eslint/member-delimiter-style": [
5+
"error",
6+
{
7+
"multiline": {
8+
"delimiter": "none",
9+
"requireLast": false
10+
},
11+
"singleline": {
12+
"delimiter": "comma",
13+
"requireLast": false
14+
}
15+
}
16+
]
17+
}
318
}

.prettierrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"arrowParens": "avoid",
3-
"semi": false
3+
"semi": false,
4+
"singleQuote": true
45
}

.vscode/settings.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"editor.codeActionsOnSave": {
3+
"source.fixAll.eslint": true
4+
}
5+
}

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@
4747
"react-helmet-async": "^1.0.7"
4848
},
4949
"devDependencies": {
50-
"@dowdiness/eslint-config": "^0.0.9",
50+
"@dowdiness/eslint-config": "^0.1.3",
5151
"@types/react": "^16.9.53",
5252
"@types/react-dom": "^16.9.8",
5353
"@types/react-helmet-async": "^1.0.3",
54+
"eslint-config-prettier": "^6.15.0",
55+
"eslint-plugin-prettier": "^3.1.4",
5456
"gatsby-plugin-root-import": "^2.0.5",
5557
"prettier": "2.1.2",
5658
"tailwindcss": "^1.9.5",

src/__generated__/gatsby-types.ts

+160-119
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Image/index.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import React from "react"
2-
import { graphql, StaticQuery } from "gatsby"
1+
import React from 'react'
2+
import { graphql, StaticQuery } from 'gatsby'
33

4-
import Image from "gatsby-image"
5-
import BackgroundImage from "gatsby-background-image"
4+
import Image from 'gatsby-image'
5+
import BackgroundImage from 'gatsby-background-image'
66

77
type ImageProps = {
88
filename: string

src/components/Layout/Footer.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import AniLink from "gatsby-plugin-transition-link/AniLink"
2-
import Image from "src/components/Image"
1+
import React from 'react'
2+
import AniLink from 'gatsby-plugin-transition-link/AniLink'
3+
import Image from 'src/components/Image'
34

4-
export type FooterProps = {}
5+
export type FooterProps = unknown
56

67
export const Footer: React.FCX<FooterProps> = ({ className }) => {
78
return (

src/components/Layout/Header.tsx

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import AniLink from "gatsby-plugin-transition-link/AniLink"
2-
import Image from "src/components/Image"
1+
import React from 'react'
2+
import AniLink from 'gatsby-plugin-transition-link/AniLink'
3+
import Image from 'src/components/Image'
34

45
// hooks
5-
import useWindowScroll from "src/hooks/useWindowScroll"
6+
import useWindowScroll from 'src/hooks/useWindowScroll'
67

7-
export type HeaderProps = {}
8-
export const Header: React.FCX<HeaderProps> = ({className}) => {
8+
export type HeaderProps = unknown
9+
export const Header: React.FCX<HeaderProps> = ({ className }) => {
910
const { y } = useWindowScroll()
1011

1112
return (
@@ -28,21 +29,19 @@ export const Header: React.FCX<HeaderProps> = ({className}) => {
2829
weakness.
2930
</h3>
3031
</div>
31-
<h1
32-
className="flex justify-center text-6xl italic font-black text-white neumorphism"
33-
>
32+
<h1 className="flex justify-center text-6xl italic font-black text-white neumorphism">
3433
弱いzine
35-
</h1>
34+
</h1>
3635
</AniLink>
3736
</section>
3837
<header
39-
className={`fixed top-0 flex items-center justify-center w-full h-16 transition duration-300 ease-in-out transform bg-white shadow-sm z-20 ${y > 580 ? "translate-y-0 opacity-100" : "-translate-y-16 opacity-0"}`}
38+
className={`fixed top-0 flex items-center justify-center w-full h-16 transition duration-300 ease-in-out transform bg-white shadow-sm z-20 ${
39+
y > 580 ? 'translate-y-0 opacity-100' : '-translate-y-16 opacity-0'
40+
}`}
4041
>
4142
<div className={className}>
4243
<AniLink fade to="/">
43-
<h1
44-
className="flex justify-center text-4xl italic font-black text-white neumorphism"
45-
>
44+
<h1 className="flex justify-center text-4xl italic font-black text-white neumorphism">
4645
弱いzine
4746
</h1>
4847
</AniLink>

src/components/Layout/index.tsx

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import Header from "./Header"
2-
import Footer from "./Footer"
1+
import React from 'react'
2+
import Header from './Header'
3+
import Footer from './Footer'
34

45
type LayoutProps = {
56
location?: Location
@@ -12,11 +13,7 @@ const Layout: React.FC<LayoutProps> = ({ children }) => {
1213
return (
1314
<div className="">
1415
<Header className="" />
15-
<main
16-
className="container w-auto"
17-
>
18-
{children}
19-
</main>
16+
<main className="container w-auto">{children}</main>
2017
<Footer className="" />
2118
</div>
2219
)

src/components/bio.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
*
55
* See: https://www.gatsbyjs.com/docs/use-static-query/
66
*/
7+
import React from 'react'
78

8-
import { useStaticQuery, graphql } from "gatsby"
9-
import Image from "gatsby-image"
9+
import { useStaticQuery, graphql } from 'gatsby'
10+
import Image from 'gatsby-image'
1011

1112
const Bio = () => {
1213
const data = useStaticQuery<GatsbyTypes.BioQueryQuery>(graphql`

src/hooks/useEffectOnce.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { EffectCallback, useEffect } from 'react'
22

3-
const useEffectOnce = (effect: EffectCallback) => {
3+
const useEffectOnce = (effect: EffectCallback): void => {
44
useEffect(effect, [])
55
}
66

src/hooks/useRafState.ts

+16-19
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
1-
import { useRef, useState, useCallback, Dispatch, SetStateAction } from 'react';
2-
3-
import useUnmount from './useUnmount';
4-
5-
const useRafState = <S>(initialState: S | (() => S)): [S, Dispatch<SetStateAction<S>>] => {
6-
const frame = useRef(0);
7-
const [state, setState] = useState(initialState);
1+
import { useRef, useState, useCallback, Dispatch, SetStateAction } from 'react'
2+
import useUnmount from './useUnmount'
83

4+
const useRafState = <S>(
5+
initialState: S | (() => S)
6+
): [S, Dispatch<SetStateAction<S>>] => {
7+
const frame = useRef(0)
8+
const [state, setState] = useState(initialState)
99
const setRafState = useCallback((value: S | ((prevState: S) => S)) => {
10-
cancelAnimationFrame(frame.current);
11-
10+
cancelAnimationFrame(frame.current)
1211
frame.current = requestAnimationFrame(() => {
13-
setState(value);
14-
});
15-
}, []);
16-
12+
setState(value)
13+
})
14+
}, [])
1715
useUnmount(() => {
18-
cancelAnimationFrame(frame.current);
19-
});
20-
21-
return [state, setRafState];
22-
};
16+
cancelAnimationFrame(frame.current)
17+
})
18+
return [state, setRafState]
19+
}
2320

24-
export default useRafState;
21+
export default useRafState

src/hooks/useTategaki.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface Tategaki {
77
}
88

99
const useTategaki = (): Tategaki => {
10+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1011
const tategakiRef = useRef<HTMLElement>(null!)
1112

1213
const adjustSize = () => {
@@ -23,16 +24,22 @@ const useTategaki = (): Tategaki => {
2324
tategakiRef.current.style.height = ''
2425
tategakiRef.current.style.paddingBottom = ''
2526
const fullHeight = tategakiRef.current.scrollHeight
26-
const defaultHeight = Number(getComputedStyle(tategakiRef.current).height.replace('px', ''))
27-
tategakiRef.current.style.paddingBottom = `${fullHeight - defaultHeight}px`
27+
const defaultHeight = Number(
28+
getComputedStyle(tategakiRef.current).height.replace('px', '')
29+
)
30+
tategakiRef.current.style.paddingBottom = `${
31+
fullHeight - defaultHeight
32+
}px`
2833
})
2934
})
3035
return
3136
}
3237

3338
tategakiRef.current.style.paddingBottom = ''
3439
const fullHeight = tategakiRef.current.scrollHeight
35-
const defaultHeight = Number(getComputedStyle(tategakiRef.current).height.replace('px', ''))
40+
const defaultHeight = Number(
41+
getComputedStyle(tategakiRef.current).height.replace('px', '')
42+
)
3643
console.log(fullHeight, defaultHeight)
3744
tategakiRef.current.style.paddingBottom = `${fullHeight - defaultHeight}px`
3845
}

src/hooks/useUnmount.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
12
import { useRef } from 'react'
23
import useEffectOnce from './useEffectOnce'
34

@@ -8,6 +9,5 @@ const useUnmount = (fn: () => any): void => {
89
fnRef.current = fn
910

1011
useEffectOnce(() => () => fnRef.current())
11-
};
12-
12+
}
1313
export default useUnmount

src/hooks/useWindowScroll.tsx

+15-22
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,31 @@
1-
import { useEffect } from 'react';
2-
import { isClient } from './util';
3-
4-
import useRafState from './useRafState';
5-
1+
import { useEffect } from 'react'
2+
import { isClient } from './util'
3+
import useRafState from './useRafState'
64
export interface State {
7-
x: number;
8-
y: number;
5+
x: number
6+
y: number
97
}
108

119
const useWindowScroll = (): State => {
1210
const [state, setState] = useRafState<State>({
1311
x: isClient ? window.pageXOffset : 0,
1412
y: isClient ? window.pageYOffset : 0,
15-
});
16-
13+
})
1714
useEffect(() => {
1815
const handler = () => {
1916
setState({
2017
x: window.pageXOffset,
2118
y: window.pageYOffset,
22-
});
23-
};
24-
19+
})
20+
}
2521
window.addEventListener('scroll', handler, {
2622
capture: false,
2723
passive: true,
28-
});
29-
24+
})
3025
return () => {
31-
window.removeEventListener('scroll', handler);
32-
};
33-
}, []);
34-
35-
return state;
36-
};
37-
38-
export default useWindowScroll;
26+
window.removeEventListener('scroll', handler)
27+
}
28+
}, [])
29+
return state
30+
}
31+
export default useWindowScroll

src/hooks/util.ts

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
import isDeepEqualReact from 'fast-deep-equal/react';
1+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
2+
/* eslint-disable @typescript-eslint/no-explicit-any */
3+
import isDeepEqualReact from 'fast-deep-equal/react'
24

3-
export const isClient = typeof window === 'object';
5+
export const isClient = typeof window === 'object'
46

57
export const isFirefox = isClient && navigator.userAgent.includes('Firefox')
68

7-
export const on = (obj: any, ...args: any[]) => obj.addEventListener(...args);
9+
export const on = (obj: any, ...args: any[]) => obj.addEventListener(...args)
810

9-
export const off = (obj: any, ...args: any[]) => obj.removeEventListener(...args);
11+
export const off = (obj: any, ...args: any[]) =>
12+
obj.removeEventListener(...args)
1013

11-
export type FnReturningPromise = (...args: any[]) => Promise<any>;
14+
export type FnReturningPromise = (...args: any[]) => Promise<any>
1215

13-
export type PromiseType<P extends Promise<any>> = P extends Promise<infer T> ? T : never;
16+
export type PromiseType<P extends Promise<any>> = P extends Promise<infer T>
17+
? T
18+
: never
1419

15-
export const isDeepEqual: (a: any, b: any) => boolean = isDeepEqualReact;
20+
export const isDeepEqual: (a: any, b: any) => boolean = isDeepEqualReact

src/pages/404.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { PageProps } from "gatsby"
1+
import React from 'react'
2+
import { PageProps } from 'gatsby'
23

3-
import { GatsbySeo } from "gatsby-plugin-next-seo"
4+
import { GatsbySeo } from 'gatsby-plugin-next-seo'
45

56
const NotFoundPage: React.FC<PageProps> = ({}) => {
67
return (

src/pages/index.tsx

+13-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { graphql } from "gatsby"
2-
import { PageProps } from "gatsby"
1+
import React from 'react'
2+
import { graphql, PageProps } from 'gatsby'
33

4-
import AniLink from "gatsby-plugin-transition-link/AniLink"
4+
import AniLink from 'gatsby-plugin-transition-link/AniLink'
55

6-
import Bio from "src/components/bio"
7-
import { GatsbySeo } from "gatsby-plugin-next-seo"
6+
import Bio from 'src/components/bio'
7+
import { GatsbySeo } from 'gatsby-plugin-next-seo'
88

99
const BlogIndex: React.FC<PageProps<GatsbyTypes.IndexPageQuery>> = ({
1010
data,
@@ -28,7 +28,7 @@ const BlogIndex: React.FC<PageProps<GatsbyTypes.IndexPageQuery>> = ({
2828
return (
2929
<>
3030
<GatsbySeo title="弱いZINE" titleTemplate="%s" />
31-
<ol style={{ listStyle: `none` }}>
31+
<ol style={{ listStyle: 'none' }}>
3232
{posts.map(post => {
3333
const title = post.frontmatter?.title || post.fields?.slug
3434

@@ -42,7 +42,10 @@ const BlogIndex: React.FC<PageProps<GatsbyTypes.IndexPageQuery>> = ({
4242
<header>
4343
<h2>
4444
<AniLink
45-
to={`/vol${post.frontmatter?.vol}${post.fields?.slug}` || `/`}
45+
to={
46+
`/vol${post.frontmatter?.vol}${post.fields?.slug}` ||
47+
'/'
48+
}
4649
fade
4750
>
4851
<span itemProp="headline">{title}</span>
@@ -54,9 +57,9 @@ const BlogIndex: React.FC<PageProps<GatsbyTypes.IndexPageQuery>> = ({
5457
<p
5558
dangerouslySetInnerHTML={{
5659
__html:
57-
post.frontmatter?.description ||
58-
post.excerpt ||
59-
`見つかりません`,
60+
post.frontmatter?.description ??
61+
post.excerpt ??
62+
'見つかりません',
6063
}}
6164
itemProp="description"
6265
/>

0 commit comments

Comments
 (0)