A code formatting tool with typed configuration.
This CLI is a thin abstraction on top of prettier.
# w/ pnpm
pnpm add -D @pkg-tools/format @pkg-tools/config
# w/ yarn
yarn add -D @pkg-tools/format @pkg-tools/config
# w/ npm
npm install -D @pkg-tools/format @pkg-tools/config
In your package.json
, you can use the exported cli format
in your format script e.g.
"scripts": {
"format": "format"
"format:check": "format -c"
}
Define a pkg.config.ts
in the root of your package and add the following.
import { defineConfig } from '@pkg-tools/config';
export default defineConfig({
format: {
semi: true,
tabWidth: 2,
singleQuote: true,
},
});
Since @pkg-tools/format leverages prettier, you'll still need to create a prettier configuration file for @pkg-tools/format to work in your editor.
To do so create a file named .prettierrc.cjs
with the following contents in the root of your package.
const { getConfig } = require('@pkg-tools/format/config');
module.exports = getConfig();