Registry / devops / fte.js-formatter

fte.js-formatter

JSON →
library3.0.0-canary.fa90532jsnpmunverified

Formatter and linter for FTE template files (.nhtml). Stable version 3.0.0 is in development (canary). Provides an importable API (format, lint) and a CLI (fte-format). Parser-backed checks when available, with safe fallbacks. Key differentiators: opinionated formatting rules specific to FTE templates, conservative to avoid breaking semantics, and support for both CLI and programmatic usage.

npm install fte.js-formatter
INSTALL
IMPORT
SIG · FTE.JS-FORMATTER
F
fte.js-formatter
devopsjavascriptv3.0.0-canary.fa90532
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 'fte.js-formatter'
const format = require('fte.js-formatter').format
Package is ESM-only (TypeScript). CommonJS require not supported.
lint
import { lint } from 'fte.js-formatter'
import lint from 'fte.js-formatter'
lint is a named export, not default.
FormatOptions
import type { FormatOptions } from 'fte.js-formatter'
import { FormatOptions } from 'fte.js-formatter'
FormatOptions is a type; use import type for TypeScript.

Shows how to import and use format and lint functions on a simple template.

import { format, lint } from 'fte.js-formatter'; const source = `<# block main : #> Hello <# end #>`; const pretty = format(source); console.log(pretty); // <# block main : #> // Hello // <# end #> const issues = lint(source); console.log(issues); // [{ ruleId: 'end-on-own-line', ... }]
Debug
Known issues
gotchaCLI command is fte-format, not fte-formatter.
fix
Use fte-format in scripts; check npx fte-format.
affects: >=3.0.0
deprecatedOld API (v2) had formatSource and lintSource names; these may break in v3.
fix
Use format and lint as named exports in v3.
affects: >=3.0.0
gotchaParser-backed checks only work when fte.js-parser is installed; silent fallback may produce different results.
fix
Install fte.js-parser as optional peer dependency to enable full checks.
affects: >=3.0.0
gotchaFormatted output defaults to 2-space indent; to use tabs, set indent: 'tab'.
fix
Pass { indent: 'tab' } in options.
affects: >=3.0.0
gotchaRules are conservative; may not catch all edge cases. Open issues for bugs.
fix
Test with your templates and report false positives/negatives.
affects: >=3.0.0
Errors
Common errors & fixes
Error: Cannot find module 'fte.js-formatter'
Package not installed or ESM context missing.
fix
Run 'npm install -D fte.js-formatter' and ensure 'type': 'module' in package.json or use .mjs extension.
TypeError: fte.format is not a function
Trying default import instead of named import.
fix
Use 'import { format } from 'fte.js-formatter''.
Error: fte-format: command not found
CLI not in PATH or not installed globally.
fix
Use 'npx fte-format' or install package locally and run via npx.
Upgrade
Version history
3.0.0-canary.fa90532latest on npm
Audit
Dependencies
fte.js-parseroptionalOptional dependency for parser-backed checks; when absent, safe fallbacks are used.
Agent activity
2 hits · last 30 days
node
2
Resources
fte.js-formatter — npm install fte.js-formatter · libregistry