Skip to main content

A tool that formats all kinds of languages consistently

Project description

Monoformat

Opinionated and "zero config" formatters like Black and Prettier are amazing in the sense that they remove any need for thinking about formatting. However, they still require you to:

  • Be used separately (one is Python and the other is Node)
  • Be configured for the language version and so forth

Monoformat does this automatically. You can only use the language version that monoformat allows and you can configure literally nothing except which files it's going to reformat and which it's not.

Installation

Monoformat is available on PyPI:

pip install monoformat

Usage

Monoformat is a command line tool. You can run it with:

monoformat .

This will reformat all files in the current directory and its subdirectories.

It will take care to avoid .git and other special directories. There is a default pattern embedded but you can change it with the --do-not-enter flag, which is a pattern matching folder or file names you don't want to consider.

On addition to the --do-not-enter rule, it will by default check all .gitignore files and .formatignore files (which use the .gitignore syntax but only affect the decision of whether to format a file or not, not to put them in git) and.

Default project

Let's say you have a Django project. It contains lots of files, including a node_modules somewhere and a a lot of big migration files.

You might want to have at the root of your repo a .gitignore file that looks like that:

node_modules
.idea
.vscode
.env
*.pyc

And then specifically to avoid formatting migrations (which can be super expensive), and to avoid running prettier on Django templates (which ends up badly) add a .formatignore file that looks like that:

**/migrations/*
**/templates/*

Then you can run monoformat . and it will only format the files that are relevant to your project.

Without install

I've actually spent an absurd amount of time to make it extremely simple to run Python and JS code without installing anything. You can do this with:

curl -s https://pypi.run/monoformat | python3.10 - .

Doing so will entirely reformat with black, isort and prettier the current directory.

Supported languages

Monoformat supports the following languages:

  • Python 3.10 (Black)
  • JavaScript (Prettier)
  • TypeScript (Prettier)
  • JSON (Prettier)
  • Markdown (Prettier)
  • YAML (Prettier)
  • HTML (Prettier)
  • CSS (Prettier)
  • SCSS (Prettier)
  • Vue (Prettier)
  • Svelte (Prettier)
  • PHP (Prettier)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

monoformat-0.1.0b3.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

monoformat-0.1.0b3-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file monoformat-0.1.0b3.tar.gz.

File metadata

  • Download URL: monoformat-0.1.0b3.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.5 Linux/5.10.0-18-amd64

File hashes

Hashes for monoformat-0.1.0b3.tar.gz
Algorithm Hash digest
SHA256 8f6164e5876d24c831710f8d4abc3ea1467c4ffbff780e2bccebbea7d5806598
MD5 1f44a601842275800390ca62f133fcc1
BLAKE2b-256 329b69d119634a935866717fd4701f87abf400b64e474b7c1333215c7ab8d9ee

See more details on using hashes here.

Provenance

File details

Details for the file monoformat-0.1.0b3-py3-none-any.whl.

File metadata

  • Download URL: monoformat-0.1.0b3-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.5 Linux/5.10.0-18-amd64

File hashes

Hashes for monoformat-0.1.0b3-py3-none-any.whl
Algorithm Hash digest
SHA256 373c13e643487bbbcf60f1267612aa5824ea29ada731712d7082a683a74920e7
MD5 7462bb69effcaf82a3e28e70d0ee80e4
BLAKE2b-256 05aa6a4faf80d4c602487db7a04070a7d1a9d9a2205b75b5c7ef7aaa5a3f3b94

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page