

git/hooks/pre-commit and give it execute permission: #!/bin/shįILES=$(git diff -cached -name-only -diff-filter=ACMR | sed 's| |\\ |g') Shell scriptĪlternately you can save this script as. To read about how git-format-staged works see Automatic Code Formatting for Partially-Staged Files. Note that regardless of which extensions you list formatting will respect any. "Īdd or remove file extensions to suit your project. It supports multiple file states (staged - last-commit, git-files etc.) dotnet new tool-manifestĪfter installation you can add prettier task to the task-runner.json. Use Case: A dotnet solution to use Prettier along with other code quality tools (e.g. Read more at mirror of prettier package for pre-commit and the pre-commit website. pre-commit-config.yaml file: - repo: rev: "" # Use the sha or tag you want to point at hooks: - id: prettier Use Case: Great when working with multi-language projects.Ĭopy the following config into your.
#CODE PRETTIER INSTALL#
This will install husky and lint-staged, then add a configuration to the project’s package.json that will automatically format supported files in a pre-commit hook. Make sure Prettier is installed and is in your devDependencies before you proceed. ESLint, Stylelint, etc.) or if you need support for partially staged files ( git add -patch). Use Case: Useful for when you want to use other code quality tools along with Prettier (e.g. This can re-format your files that are marked as “staged” via git add before you commit. You can use Prettier with a pre-commit tool.
