Skip to content

Commit 2fd0a0b

Browse files
committed
create-next-app with-typescript-eslint-jest
0 parents  commit 2fd0a0b

20 files changed

+624
-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

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
"rules": {
20+
"react/react-in-jsx-scope": 0,
21+
"react/display-name": 0,
22+
"react/prop-types": 0,
23+
"@typescript-eslint/explicit-function-return-type": 0,
24+
"@typescript-eslint/explicit-member-accessibility": 0,
25+
"@typescript-eslint/indent": 0,
26+
"@typescript-eslint/member-delimiter-style": 0,
27+
"@typescript-eslint/no-explicit-any": 0,
28+
"@typescript-eslint/no-var-requires": 0,
29+
"@typescript-eslint/no-use-before-define": 0,
30+
"@typescript-eslint/no-unused-vars": [
31+
2,
32+
{
33+
"argsIgnorePattern": "^_"
34+
}
35+
],
36+
"no-console": [
37+
2,
38+
{
39+
"allow": ["warn", "error"]
40+
}
41+
]
42+
}
43+
}

.gitignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# dependencies
2+
node_modules
3+
4+
# next.js
5+
.next
6+
.env*.local
7+
8+
# testing
9+
coverage
10+
11+
# debug
12+
npm-debug.log*
13+
yarn-debug.log*
14+
yarn-error.log*
15+
16+
# misc
17+
.DS_Store

.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+
}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Tanner Krewson
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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):
14+
15+
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/import/project?template=https://github.com/vercel/next.js/tree/canary/examples/with-typescript-eslint-jest)
16+
17+
## How to use
18+
19+
### Using `create-next-app`
20+
21+
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:
22+
23+
```bash
24+
npx create-next-app --example with-typescript-eslint-jest with-typescript-eslint-jest-app
25+
# or
26+
yarn create next-app --example with-typescript-eslint-jest with-typescript-eslint-jest-app
27+
```
28+
29+
### Download manually
30+
31+
Download the example:
32+
33+
```bash
34+
curl https://codeload.github.com/vercel/next.js/tar.gz/canary | tar -xz --strip=2 next.js-canary/examples/with-typescript-eslint-jest
35+
cd with-typescript-eslint-jest
36+
```
37+
38+
Install it and run:
39+
40+
```bash
41+
npm install
42+
npm run dev
43+
# or
44+
yarn
45+
yarn dev
46+
```
47+
48+
Deploy it to the cloud with [Vercel](https://vercel.com/import?filter=next.js&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: ['js', 'ts', 'tsx', 'json'],
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": "rocketcrab",
3+
"author": "Tanner Krewson",
4+
"license": "MIT",
5+
"version": "0.0.1",
6+
"scripts": {
7+
"dev": "next dev",
8+
"build": "next build",
9+
"start": "next start",
10+
"type-check": "tsc --pretty --noEmit",
11+
"format": "prettier --write **/*.{js,ts,tsx}",
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": "^16.13.1",
31+
"react-dom": "^16.13.1"
32+
},
33+
"devDependencies": {
34+
"@testing-library/react": "^10.0.1",
35+
"@types/jest": "^25.1.4",
36+
"@types/node": "^13.9.5",
37+
"@types/react": "^16.9.27",
38+
"@types/testing-library__react": "^10.0.0",
39+
"@typescript-eslint/eslint-plugin": "^2.25.0",
40+
"@typescript-eslint/parser": "^2.25.0",
41+
"babel-jest": "^25.2.3",
42+
"eslint": "^6.8.0",
43+
"eslint-config-prettier": "^6.10.1",
44+
"eslint-plugin-react": "^7.19.0",
45+
"husky": "^4.2.3",
46+
"jest": "^25.2.3",
47+
"jest-watch-typeahead": "^0.5.0",
48+
"lint-staged": "^10.0.10",
49+
"prettier": "^2.0.2",
50+
"typescript": "^3.8.3"
51+
}
52+
}

pages/api/hello.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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.statusCode = 200
7+
res.json({ name: 'John Doe' })
8+
}
9+
10+
export default handler

0 commit comments

Comments
 (0)