Package Exports
- dprint
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (dprint) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
dprint
TypeScript and JSONC code formatter mainly for use in my personal projects.
- Implemented nodes (140/155 -- only JSX nodes left)
- Configuration schema (more to come...)
- API declarations
Goals
- Reasonable configuration.
- Satisfy my formatting needs.
- TypeScript and JSONC support.
Usage
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
Create a dprint.config.js file in the repo. Here's an example (you don't need to copy this... use your own config):
// @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
})
]
};
Add a format script to your package.json's "scripts" section (see npx dprint --help
for usage):
{
"name": "your-package-name",
"scripts": {
"format": "dprint \"**/*{.ts,.tsx,.json,.js}\""
}
}
Format:
yarn format
# or
npm run format