Skip to content

Commit 67d5d56

Browse files
committed
Added eslint, prettier and typescript beta
1 parent 6dd8b9d commit 67d5d56

File tree

10 files changed

+1264
-52
lines changed

10 files changed

+1264
-52
lines changed

.eslintrc.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
module.exports = {
2+
env: {
3+
node: true,
4+
jest: true,
5+
es2021: true,
6+
browser: true,
7+
commonjs: true,
8+
},
9+
extends: [
10+
'airbnb',
11+
'prettier',
12+
'plugin:react/recommended',
13+
'eslint-config-prettier',
14+
],
15+
parser: '@typescript-eslint/parser',
16+
parserOptions: {
17+
ecmaFeatures: {
18+
jsx: true,
19+
},
20+
ecmaVersion: 12,
21+
sourceType: 'module',
22+
},
23+
plugins: [
24+
'react',
25+
'react-hooks',
26+
'@typescript-eslint',
27+
],
28+
rules: {
29+
'import/no-unresolved': 'off',
30+
'react/prop-types': 'off',
31+
'react/jsx-uses-react': 'off',
32+
'react/react-in-jsx-scope': 'off',
33+
'react/jsx-filename-extension': 'off',
34+
'react/jsx-props-no-spreading': 'off',
35+
'react/jsx-one-expression-per-line': 'off',
36+
},
37+
};

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"trailingComma": "es5",
3+
"singleQuote": true,
4+
"semi": true
5+
}

.vscode/settings.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"git.ignoreLimitWarning": true
3-
}
2+
"git.ignoreLimitWarning": true,
3+
"editor.formatOnSave": true
4+
}
File renamed without changes.

package.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"scripts": {
66
"dev": "next dev",
77
"build": "next build",
8-
"start": "next start"
8+
"start": "next start",
9+
"lint": "eslint --ignore-path .gitignore .",
10+
"format": "prettier --ignore-path .gitignore --write \"**/*.+(ts|tsx|json)\""
911
},
1012
"dependencies": {
1113
"next": "10.0.0",
@@ -15,6 +17,16 @@
1517
"devDependencies": {
1618
"@types/node": "^14.14.6",
1719
"@types/react": "^16.9.55",
18-
"typescript": "^4.0.5"
20+
"@typescript-eslint/eslint-plugin": "^4.6.0",
21+
"@typescript-eslint/parser": "^4.6.0",
22+
"eslint": "^7.12.1",
23+
"eslint-config-airbnb": "^18.2.0",
24+
"eslint-config-prettier": "^6.15.0",
25+
"eslint-plugin-import": "^2.22.1",
26+
"eslint-plugin-jsx-a11y": "^6.4.1",
27+
"eslint-plugin-react": "^7.21.5",
28+
"eslint-plugin-react-hooks": "^4.2.0",
29+
"prettier": "^2.1.2",
30+
"typescript": "^4.1.0-beta"
1931
}
2032
}

pages/_app.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { AppProps } from "next/app";
1+
import type { AppProps } from 'next/app';
2+
import { getTranslate, Translate } from 'i18n';
23

3-
import "../styles/globals.css";
4-
import { getTranslate, Translate } from "../_i18n";
4+
import '../styles/globals.css';
55

66
type CustomProps = {
77
t: Translate;

pages/api/hello.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
22

33
export default (req, res) => {
4-
res.statusCode = 200
5-
res.json({ name: 'John Doe' })
6-
}
4+
res.statusCode = 200;
5+
res.json({ name: 'John Doe' });
6+
};

pages/index.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
import Head from "next/head";
2-
import Image from "next/image";
3-
import { useRouter } from "next/router";
4-
import { Translate } from "../_i18n";
1+
import Head from 'next/head';
2+
import Image from 'next/image';
3+
import { useRouter } from 'next/router';
4+
import { NextPage } from 'next';
5+
import { Translate } from 'i18n';
56

6-
import styles from "../styles/Home.module.css";
7+
import styles from '../styles/Home.module.css';
78

8-
type HomeProps = {
9+
type PageProps = {
910
t: Translate;
1011
};
1112

12-
export default function Home({ t }: HomeProps) {
13+
const Home: NextPage<PageProps> = ({ t }) => {
1314
const { locale } = useRouter();
1415
return (
1516
<div className={styles.container}>
@@ -19,7 +20,7 @@ export default function Home({ t }: HomeProps) {
1920
</Head>
2021

2122
<main className={styles.main}>
22-
<h1 className={styles.title}>{t("welcome")}</h1>
23+
<h1 className={styles.title}>{t('welcome')}</h1>
2324
<p>Current locale: {locale}</p>
2425
<Image
2526
src="/takah.jpg"
@@ -29,7 +30,7 @@ export default function Home({ t }: HomeProps) {
2930
/>
3031

3132
<p className={styles.description}>
32-
Get started by editing{" "}
33+
Get started by editing
3334
<code className={styles.code}>pages/index.js</code>
3435
</p>
3536

@@ -70,10 +71,12 @@ export default function Home({ t }: HomeProps) {
7071
target="_blank"
7172
rel="noopener noreferrer"
7273
>
73-
Powered by{" "}
74+
Powered by{' '}
7475
<img src="/vercel.svg" alt="Vercel Logo" className={styles.logo} />
7576
</a>
7677
</footer>
7778
</div>
7879
);
79-
}
80+
};
81+
82+
export default Home;

tsconfig.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@
1616
"moduleResolution": "node",
1717
"resolveJsonModule": true,
1818
"isolatedModules": true,
19-
"jsx": "preserve"
19+
"jsx": "preserve",
20+
"baseUrl": ".",
2021
},
2122
"include": [
2223
"next-env.d.ts",
2324
"**/*.ts",
24-
"**/*.tsx", "next.config.js"
25+
"**/*.tsx",
26+
"next.config.js"
2527
],
2628
"exclude": [
2729
"node_modules"
28-
]
30+
],
2931
}

0 commit comments

Comments
 (0)