
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
@sensible-ts/prettier
Advanced tools
A sensible Prettier config. This configuration sticks to the Prettier defaults for the most part, with a few changes that work better with TypeScript.
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.
This configuration makes a few changes to the Prettier default options. The following is my rationale for changing each of them.
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.
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.
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).
If you're using TypeScript, this isn't really a concern, since the compiler can remove them if your target is set below ES2017.
Licensed under the MIT License.
FAQs
A sensible Prettier config
We found that @sensible-ts/prettier demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.