question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pre-commit hook prettier (vs npx prettier) questions

See original GitHub issue

First, running npm run prettier-md does not yield the same results as what the pre-commit hook does (hook installation explained in https://dvc.org/doc/user-guide/contributing-documentation). Should it? And how do we equalize them if so?

For example with npm the bullet lists are standardized to * while with the pre-commit hook they’re -. I understand we want the latter.

UPDATE: I needed to run npm install as my node_modules prettier version was outdated. npx prettier --write <file pattern>. Apparently oesn’t necessarily behave the same as the pre-commit hook (which specifies a prettier version in .pre-commit-config.yaml) so

  • I think we should remind people in the contribution guides to npm i often.

Secondly, the pre-commit hook introduces extra indentation in YAML block e.g.

md5: df06d8d51e6483ed5a74d3979f8fe42e
outs:
-- cache: true
-  md5: b8f4d5a78e55e88906d5f4aeaf43802e.dir
-  metric: false
-  path: pics
+  - cache: true
+    md5: b8f4d5a78e55e88906d5f4aeaf43802e.dir
+    metric: false
+    path: pics
wdir: .

(from …/commands-reference/add.md) but those are just copy-paste of actual DVC-files so


  • Last, we need to run prettier once we’re sure how to and that it’s behaving correctly on all .md files with
$ npm run prettier-md

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
shchekleincommented, May 21, 2019

@algomaster99 Looks like husky is a good option to keep everything under package.json control. I like it. 👍 After that we can even enable a JS linter with it as far as I understand.

@jorgeorpinel I agree that we should keep the version same. Allow patches, but not major changes.

1reaction
jorgeorpinelcommented, May 21, 2019

@algomaster99 would you like to briefly mention the option to use husky here? Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pre-commit Hook - Prettier
You can use Prettier with a pre-commit tool. This can re-format your files that are marked as “staged” via git add before you...
Read more >
Prettier on git commit hook shows code style issues, but only ...
I work with files in MyApp/ClientApp directory with VS Code, which does all the formatting on save. So far so good. However, when...
Read more >
Automatically Format your code on Git ... - DEV Community ‍ ‍
Luckily we can automate this crucial process using Husky, ESLint, Prettier to make sure the code is formatted, every time someone commits. 1....
Read more >
Automatically Format your code on Git ... - Tapajyoti Bose
Luckily we can automate this crucial process using Husky, ESLint, Prettier to make sure the code is formatted, every time someone commits. 1....
Read more >
How To Write Better JavaScript Code With a Pre-Commit Hook
How to set up Prettier and ESLint with a Git pre-commit hook ... analyzes your code to quickly find problems in JavaScript code,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found