0.2.3 • Published 5 years ago

@dprint/development v0.2.3

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

dprint

npm version Build Status

Mono-repo for dprint—a configurable and plugable code formatter.

Note: This library is under active early development. I highly recommend you check its output to ensure it's doing its job correctly and only run this on code that has been checked into source control.

Goals

  1. Reasonable configuration.
  2. Satisfy my formatting needs.
  3. TypeScript and JSONC support.

Install

Install dprint and the plugins you want to use as a dev dependency.

For example:

yarn add --dev dprint dprint-plugin-typescript dprint-plugin-jsonc
# or
npm install --save-dev dprint dprint-plugin-typescript dprint-plugin-jsonc

Setup and Usage

Run npx dprint --init in the repository's main directory to create a dprint.config.js file.

Here's an example:

// @ts-check
const { TypeScriptPlugin } = require("dprint-plugin-typescript");
const { JsoncPlugin } = require("dprint-plugin-jsonc");

/** @type { import("dprint").Configuration } */
module.exports.config = {
    projectType: "openSource",
    lineWidth: 160,
    plugins: [
        new TypeScriptPlugin({
            useBraces: "preferNone",
            "tryStatement.nextControlFlowPosition": "sameLine"
        }),
        new JsoncPlugin({
            indentWidth: 2
        })
    ],
    // this could also be specified as a command line argument
    includes: ["**/*{.ts,.tsx,.json,.js}"],
    // optionally specify file globs for files to ignore
    excludes: []
};

Add a format script to your package.json's "scripts" section (see npx dprint --help for usage):

{
  "name": "your-package-name",
  "scripts": {
    "format": "dprint"
  }
}

Format:

yarn format
# or
npm run format

Links

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.1

5 years ago