Formats source code from stdin and writes the formatted code to stdout.
pnpm install
pnpm run build
pnpm add --global "$PWD"format-code <language> [--print-width=100] [--sql-dialect=sql] < inputLanguages: angular, css, glimmer, graphql, html, javascript, json,
json5, less, lwc, markdown, mdx, scss, typescript, vue, yaml,
sql, sql-output.
The sql-output language formats a SQL query and its result as two Markdown code
blocks.
To format the code on the macOS clipboard, run:
pbpaste | format-code json | pbcopyTo generate a signed shortcut for each language, run:
format-code shortcuts --sql-dialect postgresqlEach shortcut formats the code on the clipboard and copies the result back to the clipboard. The command writes the files to the current directory. To import a shortcut, open its file:
open "Format JSON.shortcut"To see all the options, run format-code shortcuts --help.
The project uses devenv to install Node.js and pnpm. To enter the dev shell, run:
devenv shellIf you use direnv, run direnv allow one time. Then
direnv loads the dev shell when you enter the folder.