Skip to content

Commit 268d357

Browse files
erikdstocklfades
andauthored
[examples] with-ts-eslint-jest example app (#12025)
* set up with-ts-eslint-jest example app * eslint ignore new app bc it has a conflicting eslintrc * make eslint + husky setup manual * clarify app README setup notes * move page tests out of pages/ dir * Simplifying configs * extend "prettier" * format fix * Updated rules * Added husky configs and removed debug option * Removed notes and configuration * Updated pages * Added links to readme * Added example to .prettierignore * Updated snap * Make the lint work Co-authored-by: Luis Alvarez D <luis@vercel.com>
1 parent 5a5e600 commit 268d357

File tree

20 files changed

+604
-1
lines changed

20 files changed

+604
-1
lines changed

.eslintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ node_modules
22
**/.next/**
33
**/_next/**
44
**/dist/**
5-
examples/with-ioc/**
5+
examples/with-typescript-eslint-jest/**
66
examples/with-kea/**
77
packages/next/compiled/**/*
88
packages/react-refresh-utils/**/*.js
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["next/babel"]
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**/node_modules/*
2+
**/out/*
3+
**/.next/*
Lines changed: 43 additions & 0 deletions
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+
}
Lines changed: 17 additions & 0 deletions
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
Lines changed: 5 additions & 0 deletions
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
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true
4+
}
Lines changed: 48 additions & 0 deletions
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/zeit/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/zeit/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/zeit/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)).
Lines changed: 17 additions & 0 deletions
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+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/types/global" />

0 commit comments

Comments
 (0)