@pkg-tools/format
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

@pkg-tools/format

A code formatting tool with typed configuration.

@pkg-tools/format::version @pkg-tools/format::downloads

This CLI is a thin abstraction on top of prettier.

Install

# 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

Usage

In your package.json, you can use the exported cli format in your format script e.g.

"scripts": {
  "format": "format"
  "format:check": "format -c"
}

Configure

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();

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @pkg-tools/format

Weekly Downloads

2

Version

1.0.5

License

MIT

Unpacked Size

10.6 kB

Total Files

13

Last publish

Collaborators

  • joemckenney