Socket
Book a DemoInstallSign in
Socket

@sensible-ts/prettier

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@sensible-ts/prettier

A sensible Prettier config

unpublished
latest
Source
npmnpm
Version
2.0.0
Version published
Maintainers
1
Created
Source

@sensible-ts/prettier

npm prettier code style: prettier semantic-release: conventional commits license: MIT

A sensible Prettier config. This configuration sticks to the Prettier defaults for the most part, with a few changes that work better with TypeScript.

Usage

First, install this package as a dev dependency.

npm install --save-dev @sensible-ts/prettier

Then, add the following line to your package.json.

{
  "prettier": "@sensible-ts/prettier"
}

Finally, add some scripts to format your code, or, better yet, install the Prettier plugin for your editor, and set it up to auto-format on save.

Rationale

This configuration makes a few changes to the Prettier default options. The following is my rationale for changing each of them.

Print width

Default value: 80 Configured value: 100

When writing TypeScript, it can be particularly easy to go over the 80 column mark. With type annotations, Prettier can print out some ugly looking code if it is forced to not go much over 80 columns. Using a width of around 100 columns gives enough breathing room to eliminate this issue in most circumstances without going overboard.

Trailing commas

Default value: "es5" Configured value: "all"

Trailing commas are really nice when you are making updates to a list.

If you want to add a new property, you can add a new line without modifying the previously last line if that line already uses a trailing comma. This makes version-control diffs cleaner and editing code might be less troublesome.

MDN Web Docs

By default, Prettier only permits trailing commas where they are valid in ES5. The docs mention that you can turn on trailing commas everywhere depending on your target.

To run, JavaScript code formatted this way needs an engine that supports ES2017 (Node.js 8+ or a modern browser) or downlevel compilation. This also enables trailing commas in type parameters in TypeScript (supported since TypeScript 2.7 released in January 2018).

Prettier documentation

If you're using TypeScript, this isn't really a concern, since the compiler can remove them if your target is set below ES2017.

License

Licensed under the MIT License.

FAQs

Package last updated on 24 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts