npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@element-public/prettier-config

v1.0.0

Published

A mostly reasonable shared `prettier` configuration for element-public

Downloads

4

Readme

element-public-log

element-public-prettier

A mostly reasonable shared prettier configuration for element-public

npm i --save-dev @element-public/prettier-config

Choose your own adventure with prettier

Adoption of this common config for prettier can be achieved two ways:

  • use element-public-prettier by adding module reference to prettier in package.json
  • extend element-public-prettier by importing into local .prettierrc.js
  • copy boilerplate configuration into a local prettier config file

Learn more about shared prettier configurations on the prettier website.

Use element-public-prettier config

Sharing a Prettier configuration is simple: just publish a module that exports a configuration object, say @element-public/prettier-config, and reference it in your package.json:

{
    "name": "my-cool-library",
    "version": "1.0.0",
    "prettier": "@element-public/prettier-config/.prettierrc.json"
}

Note: This method does not offer a way to extend the configuration to overwrite some properties from the shared configuration.

Extend element-public-prettier config

If you need to [extend the configuration], import the file in a .prettierrc.js file and export the modifications, e.g:

module.exports = {
    ...require('@element-public/prettier-config'),
    semi: false
};

Note: see an example of extending prettier config in this very repo!

Helpful package.json scripts

A prettier "check" can be a handy quality-assurance step added to tests. Likewise a prettier "write" can become part of an automated lint fix process.

  "scripts": {
    "prettier:check": "prettier --check '**/*'",
    "prettier:write": "prettier --write '**/*'",
    "lint": "npm run prettier:write",
    "test": "npm run prettier:check"
  }

Ignoring Files

To have prettier ignore files include a .prettierignore file in the root of the repo and use ignore file syntax like with .gitignore. An example file is included with the @element-public/prettier-config bundle hosted on npm and can be copied as a good starting place.

Note: there is currently no good way to extend "ignore file" patterns with prettier or the ignore file pattern type syntax.

About prettier

Prettier is an opinionated code formatter.

Why use prettier?

It is generally accepted that having a common style guide is valuable for a project and team but getting there is a very painful and unrewarding process. People get very emotional around particular ways of writing code and nobody likes spending time writing and receiving nits.

What value does prettier provide?

What usually happens once people are using Prettier is that they realize that they actually spend a lot of time and mental energy formatting their code. With Prettier editor integration, you can just press that magic key binding and poof, the code is formatted.

Prettier is great at handling "formatting rules". It is incapable of catching or correcting "code-quality rules", which is why prettier is used along side various code linters for total code-style enforcement.

The Prettier website has information on editor integration as well as directions for how to use the prettier CLI.