Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@thunder-tools/prettier-plugin-formatter

rwxrwx-rwx41MIT1.1.1TypeScript support: included

A prettier formatter plugin, supporting to sort and remove unused imports

readme

A prettier formatter plugin, supporting to sort and remove unused imports.

This plugin can work well with vscode, prettier cli and pretty-quick.

Installation

yarn add -D @thunder-tools/prettier-plugin-formatter

Usage with Visual Studio Code

Install Prettier extension for vscode:

esbenp.prettier-vscode

To apply auto format on save for vscode, you must create ".vscode > settings.json" with properties:

"[typescript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.formatOnSave": true

Then restart vscode

Usage with prettier cli

You can format ts imports using prettier cli, the example command line:

yarn prettier src\app\app.component.ts

Usage with lint-staged, pretty-quick

The tool can also format staged files before committing by GIT.

Firstly, we install the needed libraries.

yarn add -D lint-staged pretty-quick

Then we register this code to package.json

"lint-staged": {
  "*.{ts,tsx,js,jsx,json,scss,md}": [
    "pretty-quick --staged",
    "git add -f"
  ]
},

changelog

1.1.0 (2020-11-02)

Bug Fixes

  • prettier: fix build tool issue and manually update the prettier version to 1.0.19 (abfe275)
  • prettier-plugin-formatter: use typescript version from typescript-parser to prevent imports parser issue (75d081f)

Features

  • prettier: initialize @thunder/prettier-plugin-formatter project (a4a80e8)
  • prettier-plugin-formatter: expose ThunderTypescriptParser and upgrade npm packages (f6e9125)
  • prettier-plugin-formatter: publish @thunder/prettier-plugin-formatter to npm registry (2dc1091)
  • repo: initialize @thunder/web-tools repository (ab88cfe)