mirror of
https://github.com/mikaela/mikaela.github.io/
synced 2024-11-22 12:09:28 +01:00
4.6 KiB
4.6 KiB
{{ page.excerpt }}
Automaattinen sisällysluettelo / Automatically generated Table of Contents
The packages
- @prettier/plugin-ruby
- @prettier/plugin-xml
- prettier
- prettier-plugin-nginx
- prettier-plugin-sh
- prettier-plugin-toml
Installation
corepack pnpm install -D -E prettier@latest prettier-plugin-nginx@latest @prettier/plugin-ruby@latest prettier-plugin-toml@latest @prettier/plugin-xml@latest prettier-plugin-sh@latest
or probably justcorepack pnpm install -D
if it’s not your project.- If they don’t exist already
echo "{}" > .prettierrc && touch .prettierignore
corepack pnpm exec prettier . --write
orcorepack pnpm exec prettier . --check
Configuration
I do with .editorconfig
what I can, but for example my
template .prettierrc
looks like:
{
"insertPragma": true,
"proseWrap": "always",
"singleAttributePerLine": true,
"plugins": [
"@prettier/plugin-ruby",
"@prettier/plugin-xml",
"prettier-plugin-nginx",
"prettier-plugin-sh",
"prettier-plugin-toml"
],
"overrides": [
{ "files": ".prettierrc", "options": { "parser": "json" } },
{
"files": "conf/librewolf.overrides.cfg",
"options": { "parser": "babel" }
},
{
"files": "conf/autoconfig.js.online",
"options": { "parser": "babel" }
}
]
}
at the time of writing. It’s directly from documentation excluding the plugin names, but I will want it everywhere.
.pre-commit-config.yaml
This is the file that controls pre-commit
s
behaviour.
Offline
I accidentally wrote this while updating this page to reflect me
using prettier outside of pre-commit
too nowadays.
This has the advantage that the same local environment gets reused and
dependencies are managed centrally, but assumes everyone uses pnpm,
won’t work in pre-commit
ci and may have other issues I am not thinking of as a not-coder
myself.
ci:
skip: [pnpm-install-dev, prettier]
repos:
- repo: local
hooks:
- id: pnpm-install-dev
name: Install pnpm dev dependencies
entry: corepack pnpm install -D
language: system
always_run: true
#verbose: true
pass_filenames: false
- id: prettier
name: prettier
entry: corepack pnpm exec prettier --cache --ignore-unknown --write
language: system
# Better handled by pretty-format-json from pre-commit-hooks.
# Remember to have *.json in .prettierignore!
exclude_types: [json]
Online
repos:
#- repo: https://github.com/pre-commit/mirrors-prettier
- repo: https://github.com/rbubley/mirrors-prettier
rev: "v3.3.1"
hooks:
- id: prettier
# Better handled by pretty-format-json from pre-commit-hooks.
# Remember to have *.json in .prettierignore!
exclude_types: [json]
additional_dependencies: [
# https://aminda.eu/n/prettier
"prettier@3.3.1",
"prettier-plugin-nginx@1.0.3",
"@prettier/plugin-ruby@4.0.4",
"prettier-plugin-toml@2.0.1",
"@prettier/plugin-xml@3.4.1",
]