/fjs

format js

Primary LanguageJavaScript

FJS

Format JS (fjs) is meant to be an opinionated pretty printer for JavaScript code. Given a snippet of code it will format it. Being highly configurable is not a goal.

Implementation / Features

These are the goals fjs tries to adhere to. If any of these properties are violated please open an issue!

pure

All functionality of fjs should be pure functions, given the same input they produce the same output. There are no side-effects anywhere.

format agnostic

Code that is formatted should be formatted solely based on the AST. Given an AST the same output should be printed regardless of any existing formatting.

Exceptions:

  1. Comments: When printing comments new lines before and after the comments are maintained according to the original formatting.

constant AST

This process should not change the AST in any way. Modifying the AST is a job for another tool.

Exceptions:

  1. (None yet.)

source maps

TODO:

  1. I still need to figure out how to do this one :)
  2. This is also the level cursor tracking should come from. Probably? That way any AST changes can be applied and cursors are tracked through them.