You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: app/README.md
+55-1
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,39 @@ A starter [API route](https://nextjs.org/docs/api-routes/introduction) can be ac
22
22
23
23
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
24
24
25
+
## Local Linter and Typechecker Setup
26
+
27
+
### Setting up up linting and typechecking for local development
28
+
29
+
For linting, this application is leveraging `eslint`, `prettier` and Nava's [eslint-config-nava](https://github.com/navapbc/eslint-config-nava). Although, these will be run on CI and prior to commit, it is still recommended that we tell our code editor to auto-fix eslint and prettier errors on save.
30
+
31
+
In VSCode, do so by creating a `.vscode/settings.json` file with:
For typechecking, this application is leveraging Next.js' [incremental typechecking](https://nextjs.org/docs/basic-features/typescript#incremental-type-checking). NextJS will run type checking as a part of `next build`-- Although it is still recommended that we set up type checking using our code editor for development. In VSCode, do so by adding the following to your `.vscode/settings.json` file
44
+
45
+
```
46
+
"typescript.validate.enable": true
47
+
```
48
+
49
+
Note: make sure TypeScript and Javascript Language Features are enabled in VS Code Extensions.
50
+
51
+
### Eslint rules explained
52
+
53
+
- "@typescript-eslint/no-unused-vars": "error"
54
+
- Disallows unused variables-- prevents dead code accumulation.
55
+
- "@typescript-eslint/no-explicit-any": "error"
56
+
- Disallows usage of `any` type. The usage of `any` defeats the purpose of typescript. Consider using `unknown` type instead instead.
57
+
25
58
### Tsconfig additions to auto-generated file
26
59
27
60
-`target: es6` -- nextJS set this valule to `es5` by default.
@@ -34,4 +67,25 @@ The `pages/api` directory is mapped to `/api/*`. Files in this directory are tre
34
67
### Package.json
35
68
36
69
#### Scripts
37
-
-`test`: runs `jest --ci --coverage`. [--ci option](https://jestjs.io/docs/cli#--ci) is provided so that snapshots don't get created automatically, it will require Jest to be run with `--updateSnapshot`. [--coverage option](https://jestjs.io/docs/cli#--coverageboolean) is provided to instruct jest to collect and report test coverage in output.
70
+
-`format`: instructs prettier to rewrite files with fixes for formatting violations.
71
+
-`format-check`: instructs prettier to only check files for violations without fixing them.
72
+
-`test`: runs `jest --ci --coverage`. [--ci option](https://jestjs.io/docs/cli#--ci) is provided to prevent automatic creation of snapshots. This requires Jest to be run with `--updateSnapshot`. [--coverage option](https://jestjs.io/docs/cli#--coverageboolean) is provided to instruct jest to collect and report test coverage in output.
73
+
-`ts:check`: runs `tsc --noEmit`. [--noEmit option](https://www.typescriptlang.org/tsconfig#noEmit) is provided to prevent type checker compiler from outputting files.
74
+
75
+
#### Dependencies
76
+
-`@typescript-eslint/parser`: implemented in .eslint.json via `"parser": "@typescript-eslint/parser"`. This [plugin](https://www.npmjs.com/package/@typescript-eslint/parser) works in tandem with other plugins to help facilitate the usage of ESlint with TypeScript.
77
+
-`@types/jest-axe`: This package contains type definitions for [jest-axe](https://www.npmjs.com/package/jest-axe).
78
+
79
+
#### Dev Dependencies
80
+
-`@babel/preset-typescript`: This [module](https://babeljs.io/docs/en/babel-preset-typescript) allows us to use babel to transpile TypeScript into Javascript, specifically for [jest testing](https://jestjs.io/docs/getting-started#using-typescript) in our case. Implemented in .babelrc > presets.
81
+
-`@testing-library/dom`: This [module](https://github.com/testing-library/dom-testing-library) provides querying fo.
82
+
-`@testing-library/jest-dom`: This [module](https://testing-library.com/docs/ecosystem-jest-dom/) is a companion for testing-library/dom-- it provides DOM element matchers for jest.
83
+
-`@testing-library/react`: This [module](https://testing-library.com/docs/react-testing-library/intro/) works in tandem with testing-library/dom to add APIs for testing React components.
84
+
-`babel-jest`: This [module](https://www.npmjs.com/package/babel-jest) works to compile JavaScript/Typescript code using babel for testing. Automatically implemented if `jest-cli` is used.
85
+
-`eslint`: This [module](https://www.npmjs.com/package/eslint) provides linting. Configuration implemented in .eslintrc.
86
+
-`eslint-config-nava`: This [module](https://github.com/navapbc/eslint-config-nava) contains nava's preferred configurations for eslint. It is implemented in .eslintrc > extensions > nava.
87
+
-`eslint-config-next`: This [module](https://nextjs.org/docs/basic-features/eslint) is automatically installed by nextJS, it includes out of the eslint configuration. Implemented in .eslintrc.json > extends > next.
88
+
-`eslint-config-prettier`: This [module](https://github.com/prettier/eslint-config-prettier) turns off eslint rules that may conflict with prettier. Implemented in .eslintrc > extends > prettier.
89
+
-`jest-environment-jsdom`: This [module](https://www.npmjs.com/package/jest-environment-jsdom) simulates the DOM for testing. Implemented in jest.config.js > testEnvironment.
90
+
-`prettier`: This [module](https://prettier.io/) is used for code formatting. Implemented in .prettierrc.json.
91
+
-`ts-jest`: This [module](https://www.npmjs.com/package/ts-jest) lets ys yse hest to test our project written in TypeScript. Implemented in jest.config.js > preset > ts-jest
0 commit comments