Registry / devops / jformatter

jformatter

JSON →
library1.0.13jsnpmunverified

A JavaScript code formatter that formats JS files via CLI or API. Current version is 1.0.13 (last released in 2015). It uses esprima for AST parsing and offers many configuration options (indentation, spacing, quotes, semicolons, etc.) and auto-fix capabilities. However, the project is no longer actively maintained. It is similar to Prettier or JSBeautify but with a focus on configurability and auto-fixing common issues.

npm install jformatter
INSTALL
IMPORT
SIG · JFORMATTER
J
jformatter
devopsjavascriptv1.0.13
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

format
import { format } from 'jformatter'
const format = require('jformatter').format
CommonJS require works but ESM import is preferred if your environment supports it.
formatFile
import { formatFile } from 'jformatter'
Same import pattern as format.
default export
import jformatter from 'jformatter'
const jformatter = require('jformatter')
Default import provides an object with methods: format, formatFile, version, getDefaultConfig.

Shows basic usage of jformatter: format a code string with custom indentation and spacing options.

const jformatter = require('jformatter'); const code = 'function foo( ) { return 1;}'; const formatted = jformatter.format(code, { indent: 2, spaces: { before: { parentheses: false } } }); console.log(formatted); // Output: function foo() { // return 1; // }
Debug
Known issues
deprecatedjformatter is no longer maintained. Last release was in 2015.
fix
Consider migrating to a modern formatter like Prettier.
affects: >=1.0.0
gotchaSome configuration options are marked as TODO and may not be fully implemented.
fix
Check the README for implemented options before relying on a specific feature.
affects: >=1.0.0
gotchaThe CLI may not work correctly on Windows paths due to a bug fixed in v1.0.7.
fix
Update to at least version 1.0.7.
affects: <1.0.7
Errors
Common errors & fixes
Error: Cannot find module 'esprima'
Missing dependency: jformatter requires esprima for parsing.
fix
Install esprima: npm install esprima
throw err; // SyntaxError: Unexpected token
The input code contains a syntax error that esprima cannot parse.
fix
Fix the syntax error in your source code before formatting.
Upgrade
Version history
1.0.13latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
jformatter — npm install jformatter · libregistry