@magic/format
@magic/format
run oxfmt and format your code.
install
be in a nodejs project.
npm i --save-dev --save-exact @magic/formatUsage
npm run scripts
Add the @magic/test bin scripts to package.json
{"scripts": {"format": "f -w","format:check": "f"},"devDependencies": {"@magic/format": "0.0.1"}}
then use the npm run scripts
npm run formatnpm run format:check
cli
// first install globallynpm i -g @magic/format// check formatting using oxfmt but do not write// oxfmt --list-differentf// format files using oxfmt// oxfmt --writef -w
configuration
the shared oxfmt config shipped by @magic/format is applied by default, so you do not have to declare formatting rules yourself.
a project own oxfmt config (.oxfmtrc.json or .oxfmtrc.jsonc) merges over the shared defaults when present, or pass one explicitly:
f --config my-config.jsonlanguages
@magic/format uses oxfmt, which natively supports a wide range of languages out of the box:
- javascript: js, mjs, cjs
- typescript: ts, tsx
- jsx: jsx
- json: json, jsonc, json5, gltf
- css: css, scss, less
- markdown: md, markdown, mdx
- html: html
- vue: vue
- graphql: graphql
- yaml: yaml
- toml: toml
svelte and astro are supported when their peer package is installed:
- svelte: install the svelte package
- astro: install the @astrojs/compiler-rs package