Prettier Plugin for Telepact
raw JSON → 1.0.0-alpha.301 verified Sat Apr 25 auth: no javascript
A Prettier plugin that formats Telepact API schema files (*.telepact.json and *.telepact.yaml). Currently in alpha (v1.0.0-alpha.301), released as part of the Telepact monorepo with weekly updates. It focuses on consistent docstring formatting and indentation. Unlike generic JSON/YAML formatters, this plugin understands the Telepact schema structure, ensuring proper alignment of docstrings and fields. Primarily useful for teams that author schemas in JSON; YAML block scalars are recommended for new projects.
Common errors
error Error: No parser could be inferred for file: example.telepact.json ↓
cause Missing parser override in Prettier configuration.
fix
Add override: { 'files': '*.telepact.json', 'options': { 'parser': 'telepact-parse' } }
error Cannot find module 'prettier-plugin-telepact' ↓
cause Plugin not installed or not in node_modules.
fix
Run 'npm install prettier-plugin-telepact' and ensure it's listed in package.json.
Warnings
gotcha The plugin only formats files when the parser is explicitly set to 'telepact-parse'. Without the parser override, Prettier will fall back to the default JSON parser. ↓
fix Add override in .prettierrc: { 'files': '*.telepact.json', 'options': { 'parser': 'telepact-parse' } }
gotcha The plugin is only needed for .telepact.json files; .telepact.yaml files can be formatted with standard YAML plugins. Using this plugin on YAML files may produce unexpected results. ↓
fix Only apply this plugin to .telepact.json files via overrides.
deprecated The plugin is in alpha and may undergo breaking changes. Schema structure changes in future Telepact releases may cause formatting inconsistencies. ↓
fix Pin to a specific version and test formatting after upgrading Telepact.
Install
npm install prettier-plugin-telepact yarn add prettier-plugin-telepact pnpm add prettier-plugin-telepact Imports
- prettier-plugin-telepact
Add to Prettier plugins array in config: 'plugins': ['prettier-plugin-telepact']
Quickstart
// .prettierrc
{
"plugins": ["prettier-plugin-telepact"],
"overrides": [
{
"files": "*.telepact.json",
"options": {
"parser": "telepact-parse"
}
}
]
}
// Run: npx prettier --write '**/*.telepact.json'