Skip to content

Commit 4ae85c0

Browse files
committed
Initial commit from Create Next App
0 parents  commit 4ae85c0

20 files changed

+7113
-0
lines changed

.babelrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["next/babel"]
3+
}

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**/node_modules/*
2+
**/out/*
3+
**/.next/*

.eslintrc.json

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"parser": "@typescript-eslint/parser",
3+
"plugins": ["@typescript-eslint"],
4+
"extends": [
5+
"eslint:recommended",
6+
"plugin:react/recommended",
7+
"plugin:@typescript-eslint/recommended"
8+
// Uncomment the following lines to enable eslint-config-prettier
9+
// Is not enabled right now to avoid issues with the Next.js repo
10+
// "prettier",
11+
// "prettier/@typescript-eslint"
12+
],
13+
"env": {
14+
"es6": true,
15+
"browser": true,
16+
"jest": true,
17+
"node": true
18+
},
19+
"settings": {
20+
"react": {
21+
"version": "detect"
22+
}
23+
},
24+
"rules": {
25+
"react/react-in-jsx-scope": 0,
26+
"react/display-name": 0,
27+
"react/prop-types": 0,
28+
"@typescript-eslint/explicit-function-return-type": 0,
29+
"@typescript-eslint/explicit-member-accessibility": 0,
30+
"@typescript-eslint/indent": 0,
31+
"@typescript-eslint/member-delimiter-style": 0,
32+
"@typescript-eslint/no-explicit-any": 0,
33+
"@typescript-eslint/no-var-requires": 0,
34+
"@typescript-eslint/no-use-before-define": 0,
35+
"@typescript-eslint/no-unused-vars": [
36+
2,
37+
{
38+
"argsIgnorePattern": "^_"
39+
}
40+
],
41+
"no-console": [
42+
2,
43+
{
44+
"allow": ["warn", "error"]
45+
}
46+
]
47+
}
48+
}

.gitignore

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
# local env files
28+
.env.local
29+
.env.development.local
30+
.env.test.local
31+
.env.production.local
32+
33+
# vercel
34+
.vercel

.prettierignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
.next
3+
yarn.lock
4+
package-lock.json
5+
public

.prettierrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true
4+
}

README.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# NextJS Typescript Boilerplate
2+
3+
Bootstrap a developer-friendly NextJS app configured with:
4+
5+
- [Typescript](https://www.typescriptlang.org/)
6+
- Linting with [ESLint](https://eslint.org/)
7+
- Formatting with [Prettier](https://prettier.io/)
8+
- Linting, typechecking and formatting on by default using [`husky`](https://github.com/typicode/husky) for commit hooks
9+
- Testing with [Jest](https://jestjs.io/) and [`react-testing-library`](https://testing-library.com/docs/react-testing-library/intro)
10+
11+
## Deploy your own
12+
13+
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):
14+
15+
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-typescript-eslint-jest&project-name=with-typescript-eslint-jest&repository-name=with-typescript-eslint-jest)
16+
17+
## How to use
18+
19+
Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example:
20+
21+
```bash
22+
npx create-next-app --example with-typescript-eslint-jest with-typescript-eslint-jest-app
23+
# or
24+
yarn create next-app --example with-typescript-eslint-jest with-typescript-eslint-jest-app
25+
```
26+
27+
Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).

jest.config.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
roots: ['<rootDir>'],
3+
moduleFileExtensions: ['ts', 'tsx', 'js', 'json', 'jsx'],
4+
testPathIgnorePatterns: ['<rootDir>[/\\\\](node_modules|.next)[/\\\\]'],
5+
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(ts|tsx)$'],
6+
transform: {
7+
'^.+\\.(ts|tsx)$': 'babel-jest',
8+
},
9+
watchPlugins: [
10+
'jest-watch-typeahead/filename',
11+
'jest-watch-typeahead/testname',
12+
],
13+
moduleNameMapper: {
14+
'\\.(css|less|sass|scss)$': 'identity-obj-proxy',
15+
'\\.(gif|ttf|eot|svg|png)$': '<rootDir>/test/__mocks__/fileMock.js',
16+
},
17+
}

next-env.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/types/global" />

package.json

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "with-typescript-eslint-jest",
3+
"author": "@erikdstock",
4+
"license": "MIT",
5+
"version": "1.0.0",
6+
"scripts": {
7+
"dev": "next dev",
8+
"build": "next build",
9+
"start": "next start",
10+
"type-check": "tsc --pretty --noEmit",
11+
"format": "prettier --write .",
12+
"lint": "eslint . --ext ts --ext tsx --ext js",
13+
"test": "jest",
14+
"test-all": "yarn lint && yarn type-check && yarn test"
15+
},
16+
"husky": {
17+
"hooks": {
18+
"pre-commit": "lint-staged",
19+
"pre-push": "yarn run type-check"
20+
}
21+
},
22+
"lint-staged": {
23+
"*.@(ts|tsx)": [
24+
"yarn lint",
25+
"yarn format"
26+
]
27+
},
28+
"dependencies": {
29+
"next": "latest",
30+
"react": "^17.0.1",
31+
"react-dom": "^17.0.1"
32+
},
33+
"devDependencies": {
34+
"@testing-library/react": "^11.2.5",
35+
"@types/jest": "^26.0.20",
36+
"@types/node": "^14.14.25",
37+
"@types/react": "^17.0.1",
38+
"@typescript-eslint/eslint-plugin": "^4.14.2",
39+
"@typescript-eslint/parser": "^4.14.2",
40+
"babel-jest": "^26.6.3",
41+
"eslint": "^7.19.0",
42+
"eslint-config-prettier": "^7.2.0",
43+
"eslint-plugin-react": "^7.19.0",
44+
"husky": "^4.2.3",
45+
"identity-obj-proxy": "^3.0.0",
46+
"jest": "^26.6.3",
47+
"jest-watch-typeahead": "^0.6.1",
48+
"lint-staged": "^10.0.10",
49+
"prettier": "^2.0.2",
50+
"typescript": "^4.1.3"
51+
}
52+
}

pages/api/hello.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
2+
3+
import { NextApiRequest, NextApiResponse } from 'next'
4+
5+
const handler = (req: NextApiRequest, res: NextApiResponse) => {
6+
res.status(200).json({ name: 'John Doe' })
7+
}
8+
9+
export default handler

0 commit comments

Comments
 (0)