-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
fforres
committed
Jul 10, 2020
0 parents
commit 139ee02
Showing
20 changed files
with
9,216 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["next/babel"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
**/node_modules/* | ||
**/out/* | ||
**/.next/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": ["@typescript-eslint"], | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:react/recommended", | ||
"plugin:@typescript-eslint/recommended" | ||
// Uncomment the following lines to enable eslint-config-prettier | ||
// Is not enabled right now to avoid issues with the Next.js repo | ||
// "prettier", | ||
// "prettier/@typescript-eslint" | ||
], | ||
"env": { | ||
"es6": true, | ||
"browser": true, | ||
"jest": true, | ||
"node": true | ||
}, | ||
"rules": { | ||
"react/react-in-jsx-scope": 0, | ||
"react/display-name": 0, | ||
"react/prop-types": 0, | ||
"@typescript-eslint/explicit-function-return-type": 0, | ||
"@typescript-eslint/explicit-member-accessibility": 0, | ||
"@typescript-eslint/indent": 0, | ||
"@typescript-eslint/member-delimiter-style": 0, | ||
"@typescript-eslint/no-explicit-any": 0, | ||
"@typescript-eslint/no-var-requires": 0, | ||
"@typescript-eslint/no-use-before-define": 0, | ||
"@typescript-eslint/no-unused-vars": [ | ||
2, | ||
{ | ||
"argsIgnorePattern": "^_" | ||
} | ||
], | ||
"no-console": [ | ||
2, | ||
{ | ||
"allow": ["warn", "error"] | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# dependencies | ||
node_modules | ||
|
||
# next.js | ||
.next | ||
.env*.local | ||
|
||
# testing | ||
coverage | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# misc | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
.next | ||
yarn.lock | ||
package-lock.json | ||
public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"semi": false, | ||
"singleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# NextJS Typescript Boilerplate | ||
|
||
Bootstrap a developer-friendly NextJS app configured with: | ||
|
||
- [Typescript](https://www.typescriptlang.org/) | ||
- Linting with [ESLint](https://eslint.org/) | ||
- Formatting with [Prettier](https://prettier.io/) | ||
- Linting, typechecking and formatting on by default using [`husky`](https://github.com/typicode/husky) for commit hooks | ||
- Testing with [Jest](https://jestjs.io/) and [`react-testing-library`](https://testing-library.com/docs/react-testing-library/intro) | ||
|
||
## Deploy your own | ||
|
||
Deploy the example using [Vercel](https://vercel.com): | ||
|
||
[](https://vercel.com/import/project?template=https://github.com/vercel/next.js/tree/canary/examples/with-typescript-eslint-jest) | ||
|
||
## How to use | ||
|
||
### Using `create-next-app` | ||
|
||
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: | ||
|
||
```bash | ||
npx create-next-app --example with-typescript-eslint-jest with-typescript-eslint-jest-app | ||
# or | ||
yarn create next-app --example with-typescript-eslint-jest with-typescript-eslint-jest-app | ||
``` | ||
|
||
### Download manually | ||
|
||
Download the example: | ||
|
||
```bash | ||
curl https://codeload.github.com/vercel/next.js/tar.gz/canary | tar -xz --strip=2 next.js-canary/examples/with-typescript-eslint-jest | ||
cd with-typescript-eslint-jest | ||
``` | ||
|
||
Install it and run: | ||
|
||
```bash | ||
npm install | ||
npm run dev | ||
# or | ||
yarn | ||
yarn dev | ||
``` | ||
|
||
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)). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module.exports = { | ||
roots: ['<rootDir>'], | ||
moduleFileExtensions: ['js', 'ts', 'tsx', 'json'], | ||
testPathIgnorePatterns: ['<rootDir>[/\\\\](node_modules|.next)[/\\\\]'], | ||
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(ts|tsx)$'], | ||
transform: { | ||
'^.+\\.(ts|tsx)$': 'babel-jest', | ||
}, | ||
watchPlugins: [ | ||
'jest-watch-typeahead/filename', | ||
'jest-watch-typeahead/testname', | ||
], | ||
moduleNameMapper: { | ||
'\\.(css|less|sass|scss)$': 'identity-obj-proxy', | ||
'\\.(gif|ttf|eot|svg|png)$': '<rootDir>/test/__mocks__/fileMock.js', | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/types/global" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"name": "with-typescript-eslint-jest", | ||
"author": "@erikdstock", | ||
"license": "MIT", | ||
"version": "1.0.0", | ||
"scripts": { | ||
"dev": "next dev", | ||
"build": "next build", | ||
"start": "next start", | ||
"type-check": "tsc --pretty --noEmit", | ||
"format": "prettier --write **/*.{js,ts,tsx}", | ||
"lint": "eslint . --ext ts --ext tsx --ext js", | ||
"test": "jest", | ||
"test-all": "yarn lint && yarn type-check && yarn test" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged", | ||
"pre-push": "yarn run type-check" | ||
} | ||
}, | ||
"lint-staged": { | ||
"*.@(ts|tsx)": [ | ||
"yarn lint", | ||
"yarn format" | ||
] | ||
}, | ||
"dependencies": { | ||
"next": "latest", | ||
"react": "^16.13.1", | ||
"react-dom": "^16.13.1" | ||
}, | ||
"devDependencies": { | ||
"@testing-library/react": "^10.0.1", | ||
"@types/jest": "^25.1.4", | ||
"@types/node": "^13.9.5", | ||
"@types/react": "^16.9.27", | ||
"@types/testing-library__react": "^10.0.0", | ||
"@typescript-eslint/eslint-plugin": "^2.25.0", | ||
"@typescript-eslint/parser": "^2.25.0", | ||
"babel-jest": "^25.2.3", | ||
"eslint": "^6.8.0", | ||
"eslint-config-prettier": "^6.10.1", | ||
"eslint-plugin-react": "^7.19.0", | ||
"husky": "^4.2.3", | ||
"jest": "^25.2.3", | ||
"jest-watch-typeahead": "^0.5.0", | ||
"lint-staged": "^10.0.10", | ||
"prettier": "^2.0.2", | ||
"typescript": "^3.8.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction | ||
|
||
import { NextApiRequest, NextApiResponse } from 'next' | ||
|
||
const handler = (req: NextApiRequest, res: NextApiResponse) => { | ||
res.statusCode = 200 | ||
res.json({ name: 'John Doe' }) | ||
} | ||
|
||
export default handler |
Oops, something went wrong.