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

@kdeveloper/purs-tidy

v0.11.0

Published

A syntax tidy-upper (formatter) for PureScript.

Downloads

32

Readme

purescript-tidy

A syntax tidy-upper (formatter) for PureScript.

Install

$ npm install -g purs-tidy

Also available for Nix via Nixpkgs 22.11+ and Easy PureScript Nix

Usage

You can use purs-tidy to format files in place or via STDIN / STDOUT (which is useful for editor integration):

Formatting a collection of files in place:
$ purs-tidy format-in-place "src/**/*.purs"
Using STDIN to format a file:
$ purs-tidy format < MyFile.purs

You can also use purs-tidy to verify whether files have already been formatted. This is often useful to verify, in continuous integration, that all project files are formatted according to the configuration. Files that would be changed by running format-in-place are listed out.

Verifying files are formatted
$ purs-tidy check "src/**/*.purs"
All files are formatted.

Configuration

You can see all configuration that purs-tidy accepts using the --help flag for the command you are using:

$ purs-tidy format-in-place --help

Some common options include:

  • --indent to set the number of spaces used in indentation, which defaults to 2 spaces
  • --arrow-first or --arrow-last to control whether type signatures put arrows first on the line or last on the line (purty-style), which defaults to arrow-first.

You can generate a .tidyrc.json using the generate-config command. If a .tidyrc.json file is found, it will be used in lieu of CLI arguments.

Operator Precedence

To support correct operator precedence without having to parse your entire source tree (potentially for a single file), purs-tidy uses a pre-baked operator precedence table. By default, purs-tidy ships with a table built from the core and contrib organizations. If you need support for more operators, you can generate your own table using the generate-operators command.

$ spago sources | xargs purs-tidy generate-operators > .tidyoperators
$ purs-tidy generate-config --arrow-first --unicode-never --operators .tidyoperators

Editor Support

Spacemacs

Spacemacs' Purescript layer supports formatting using purs-tidy out of the box.

You can run the formatter manually with either M-x spacemacs/purescript-format or with the shortcut SPC m =.

To enable automatic formatting of the buffer on save, enable purescript-fmt-on-save in your spacemacs config:

  (setq-default dotspacemacs-configuration-layers '(
    (purescript :variables
                purescript-fmt-on-save t)))

Vim

via ALE

Add to your other fixers .vimrc or $XDG_CONFIG_HOME/neovim/init.vim

let b:ale_fixers = { 'purescript': [ 'purstidy' ] }
" suggested to fix on save
let g:ale_fix_on_save = 1

via Neoformat

Add to your .vimrc or $XDG_CONFIG_HOME/neovim/init.vim

let g:neoformat_enabled_purescript = ['purstidy']

VS Code

via PureScript IDE

The PureScript IDE plugin for VS Code supports purs-tidy as a built-in formatter in versions after 0.25.1. Choose purs-tidy from the list of supported formatters in the settings, or add this to your settings.json:

"purescript.formatter": "purs-tidy"

Development

Requirements

  • purs: 0.15
  • spago: 0.20
  • node: 14
  • esbuild: 0.14

Running bin

For local development pointing to the output directory:

$ npm run build
$ ./bin/index.dev.js --help

For a local production build pointing to the bundle directory:

$ npm run bundle
$ ./bin/index.js --help

If you would like to use your local build of purs-tidy in your editor, use path to bin/index.js instead of the purs-tidy binary in your settings. For example, instead of setting the format command to purs-tidy format, set it to $TIDY_DIR/bin/index.js format where $TIDY_DIR is the location of your checkout of this repository.

Running test

To accept snapshot tests:

$ npm run test -- -a "--accept"

Generating the built-in operator table

$ npm run generate-default-operators