Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR improves the developer experience around linting and type-checking. It does so in a number of ways.
Improvements
Less disruptive linting and type-checking
Linting will no longer raise build-preventing errors. This makes it ok to have temporary issues in your code while you're developing, as long as you fix them before committing.
The TypeScript type-checker does not run during NEXTjs development to avoid disrupting the development process. The philosophy is sane, but it did mean that it would never run with our existing setup, so our code actually contained errors which we weren't noticing.
With this PR,
docker-compose up
will spin up a separate container which just does typescript compilation and linting, alongside but separate from the NEXTjs development server. This means that we get linting and typescript errors in the terminal, but without disrupting the development flow.Standalone linting and pre-commit hook
The linting can now be run standalone using
docker-compose run main npm run lint
(or as part of the existingmain
container usingdocker-compose exec main npm run lint
.This command can also be used as a pre-commit hook, so that you never forget to verify style and type safety before committing code. This PR adds a hook in
.githooks/pre-commit
and an explanation in the README on how to configure it.How to test
git config core.hooksPath .githooks
)docker-compose up --build
)console.log()
somewheregit commit -a
)Expected result:
After step 4, the
linter
container should print out an error in the terminal. The code should still run ok in the browser.After step 5, another
linter
container should start up and run theeslint src && tsc
commands to validate the code. It should fail (due to the bad code introduced in step 4) and the commit should be prevented.