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

@schuchard/prettier

v5.1.0

Published

An Angular schematic for adding prettier

Downloads

4,800

Readme

Angular Prettier schematic

A Schematic that adds prettier and a pre-commit hook for formatting staged files.

CircleCI npm Commitizen friendly

Usage 🚀

Run in an Angular CLI project

ng add @schuchard/prettier

Then you're done. Continue your normal workflow of git add, commit, push or a similar workflow with your IDE/editor.

You can optionally install globally:

npm install -g @schuchard/prettier

then in an Angular CLI project:

ng g @schuchard/prettier:add

How does Prettier work with Angular

Automatically against staged files

By default lint-staged is configured along with a pre-commit hook. This will run Prettier against all new files as they are committed according to the settings defined in prettier.config.json. Generally speaking, your workflow should remain unchanged - git add, commit, push

lint-staged-example

Disabling lint-staged install

lint-stage and the precommit hook can be disabled with the following

ng g @schuchard/prettier:add --lintStaged=false

Manually

While lint-staged only runs prettier against staged files, you can manually run Prettier against ALL targeted files with the script added to the package.json

npm run prettier

Angular formatting

Beginning with 1.15, Prettier supports formatting HTML and Angular files.

Format all Angular Files - {js,json,css,md,ts,html,component.html}

format-angular-files

Format only Typescript files

Previous versions of this schematic only formatted Typescript files. That functionality is still available and is configured in the CLI prompts or via the --formatAllAngularFiles=false if desired. The default is true.

format-typescript-files

Default Prettier options

Angular 7

This schematic takes advantage of CLI prompts for configuring Prettier options. If you're unsure of a setting, press enter to select the default. You can skip a prompt by passing any of the options when call the schematic.

ng g @schuchard/prettier:add --printWidth=100

schematic-cli

< Angular 7

Without any CLI arguments the default Prettier options will be applied. The defaults can be changed in one of two ways:

  • modifying the ./prettier.config.js after the schematic runs
  • passing a flag to the schematic with the desired value for any of the options. For example:
    • ng g @schuchard/prettier:add --printWidth=100 --tabWidth=4

Example default prettier.config.js

printWidth = 80;
tabWidth = 2;
useTabs = false;
semi = true;
singleQuote = false;
trailingComma = "none";
bracketSpacing = true;
jsxBracketSameLine = false;
arrowParens = "avoid";
rangeStart = 0;
rangeEnd = Infinity;
requirePragma = false;
insertPragma = false;
proseWrap = "preserve";
lintStaged = true;

Contributing

Getting started

Install dependencies:

yarn && cd sandbox && yarn

Test changes to the schematic

yarn dev

Test changes to the schematic AND run E2E tests in the sandbox

yarn test

Reset the sandbox state after running the schematic locally

yarn clean

Updating the Sandbox

  1. remove the /sandbox directory
  2. npm i -g @angular/cli
  3. ng new sandbox
  4. update the package.json
"build": "ng build --prod --progress=false",
"test": "ng test --watch=false",

Documentation

Unsure how to do something with schematics? Check the Angular schematics for inspiration.

Inspiration came from this excellent article by Aaron Frost

Publishing

  • First, ensure you're authenticated with npm login.
npm run release

Issues & Requests 📬

Submit an issue