Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add format check to validate script #146

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ for linting, testing, building, and more.
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->


- [Installation](#installation)
- [Usage](#usage)
- [Overriding Config](#overriding-config)
Expand Down Expand Up @@ -126,7 +125,7 @@ add `@babel/preset-flow` to the `presets`-section.

### TypeScript Support

If the `tsconfig.json`-file is present in the project root directory and
If the `tsconfig.json`-file is present in the project root directory and
`typescript` is a dependency the `@babel/preset-typescript` will automatically
get loaded when you use the default babel config that comes with `kcd-scripts`.
If you customised your `.babelrc`-file you might need to manually add
Expand All @@ -135,8 +134,9 @@ If you customised your `.babelrc`-file you might need to manually add
`kcd-scripts` will automatically load any `.ts` and `.tsx` files, including the
default entry point, so you don't have to worry about any rollup configuration.

`tsc --build tsconfig.json` will run during before committing to verify that files will compile.
So make sure to add the `noEmit` flag to the `tsconfig.json`'s `compilerOptions`.
`tsc --build tsconfig.json` will run during before committing to verify that
files will compile. So make sure to add the `noEmit` flag to the
`tsconfig.json`'s `compilerOptions`.

## Inspiration

Expand Down Expand Up @@ -203,6 +203,7 @@ Thanks goes to these people ([emoji key][emojis]):

<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors][all-contributors] specification.
Expand Down
3 changes: 3 additions & 0 deletions src/scripts/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ const useDefaultScripts = typeof validateScripts !== 'string'
const scripts = useDefaultScripts
? {
build: ifScript('build', 'npm run build --silent'),
format: preCommit
? null
: ifScript('format', 'npm run format -- --check'),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when prettier is passed --write and --check at the same time?

Also, this kinda assumes that the format script is using something that accepts the --check flag (like kcd-scripts format which forwards the flags to prettier). So it probably does, but maybe we should note that in a code comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test one also assumes there's a test script that accepts a --coverage flag, so I don't think we should mind the --check flag

Have to look into the code so we don't send the --write flag when checking I think.

lint: preCommit ? null : ifScript('lint', 'npm run lint --silent'),
test: preCommit
? null
Expand Down