Skip to main content

A lightweight rule-based JavaScript/TypeScript code formatter

Project description

CutyJS

CutyJS currently doesn't obey PEP 8 in many cases. It is a work in progress and may not be ready for production use. Use with caution and report any issues you encounter.

A lightweight JavaScript/TypeScript code formatter.

Installation

pip install cutyjs

About

CutyJS is a minimal and fast JavaScript/TypeScript formatter designed to enforce consistent formatting rules across JS/TS codebases.

Unlike large formatters that heavily restructure code, CutyJS focuses on deterministic formatting rules applied through a small rule engine. Each rule handles a specific formatting concern such as indentation, spacing, blank lines, or import ordering.

The formatter processes files using modular formatting rules, making the system easier to reason about, extend, and control.

Features

  • Deterministic JavaScript/TypeScript formatting
  • Rule-based formatting system
  • Import sorting
  • Consistent indentation enforcement
  • Blank line normalization
  • Trailing space cleanup
  • Line ending normalization
  • Automatic EOF newline insertion
  • Optional check mode for CI pipelines

Usage

Format a file or directory:

cutyjs path/to/file_or_directory

Check if files need formatting (useful for CI or pre-commit):

cutyjs --check path/to/project

If formatting changes are required in check mode, CutyJS exits with a non-zero status code.

Formatting Rules

CutyJS applies a set of focused formatting rules:

  • Blank line normalization
  • Declaration spacing adjustments
  • Removal of excessive blank lines
  • End-of-file newline enforcement
  • Import ordering
  • Indentation consistency
  • Leading blank line cleanup
  • Line ending normalization
  • Trailing comma formatting
  • Removal of trailing spaces

Each rule operates independently, allowing the formatter to remain simple and predictable.

Project Structure

cutyjs
├── __init__.py
├── fmt.py
├── format_file.py
└── rules
    └── format
        ├── blank_lines.py
        ├── declaration_spacing.py
        ├── double_blanks.py
        ├── eof_newline.py
        ├── import_sort.py
        ├── indentation.py
        ├── leading_blank_lines.py
        ├── line_endings.py
        ├── trailing_commas.py
        └── trailing_spaces.py
  • fmt.py provides the CLI entrypoint.
  • format_file.py handles formatting of individual files.
  • rules/format contains independent formatting rules applied sequentially.

Design Philosophy

CutyJS is built around a few core ideas:

  • Minimal implementation
  • Explicit formatting rules
  • Predictable output
  • Easy extensibility
  • Suitable for automation (CI / pre-commit)

Rather than trying to cover every stylistic decision, CutyPy focuses on enforcing a small set of reliable formatting guarantees.

Status

Experimental and under active development.

Links

Made by AttAditya

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

cutyjs-0.2.6.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cutyjs-0.2.6-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file cutyjs-0.2.6.tar.gz.

File metadata

  • Download URL: cutyjs-0.2.6.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for cutyjs-0.2.6.tar.gz
Algorithm Hash digest
SHA256 9f8458593e77379db6c0f59f2f9c447a9ad1b9f900570e76b0a6175642073f84
MD5 cb90ea807dec012e09029359d86bd6d2
BLAKE2b-256 d291b0568b487ea3bc36e0649e7e6067be7874a62166befc7b05fe34a0d181e1

See more details on using hashes here.

File details

Details for the file cutyjs-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: cutyjs-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for cutyjs-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 497d603f7377c5ac9ae84ca6e3ad1d0bd4f615db68744fe5f9132e973a4ca141
MD5 4237b7ac15daeca9b648558539b066f7
BLAKE2b-256 6d556b58ee24f1c5c109ceeb15066c55ef105b54ede257f7de7fd897bc1368d4

See more details on using hashes here.

Supported by

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