Registry / devops / grunt-typescript-formatter

grunt-typescript-formatter

JSON →
library0.4.1jsnpmunverified

A Grunt plugin that wraps typescript-formatter to automatically format TypeScript files according to configurable rules. Current stable version is 0.4.1, last updated in 2015. It integrates into Grunt ~0.4.1 workflows with a single task named 'typescript-formatter'. Alternatives include running typescript-formatter directly or using other formatters like prettier. The plugin is minimal and takes a 'files' configuration for source files and an optional 'options.configuration' object.

npm install grunt-typescript-formatter
INSTALL
IMPORT
SIG · GRUNT-TYPESCRIPT-F
G
grunt-typescript-formatter
devopsjavascriptv0.4.1
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.

grunt file (Gruntfile.js)
grunt.loadNpmTasks('grunt-typescript-formatter'); grunt.initConfig({ 'typescript-formatter': { files: { src: ['**/*.ts'] } } });
grunt.loadNpmTasks('typescript-formatter');
Common mistake: loading the wrong npm module name or not loading the plugin at all.
grunt.initConfig task name
'typescript-formatter': { ... }
'tsfmt': { ... } or 'grunt-typescript-formatter': { ... }
The task name must exactly match 'typescript-formatter' (with hyphen).
options.configuration
options: { configuration: { ... } }
options: { ... }
The formatting options must be inside a 'configuration' key, otherwise they are ignored.

Shows how to configure and run the grunt-typescript-formatter task in a Gruntfile.

// Gruntfile.js module.exports = function(grunt) { grunt.loadNpmTasks('grunt-typescript-formatter'); grunt.initConfig({ 'typescript-formatter': { options: { configuration: { indent: ' ', newLine: 'LF' } }, files: { src: ['src/**/*.ts'] } } }); grunt.registerTask('format', ['typescript-formatter']); };
Debug
Known issues
breakingThe module file used in this plugin is a Gruntfile, not a JavaScript/TypeScript module. It requires Grunt to be run.
fix
Ensure Grunt is installed and you run the command 'grunt' after setting up the task.
affects: all
deprecatedThis plugin is no longer maintained. May not work with recent Node.js or TypeScript versions.
fix
Consider using typescript-formatter directly or prettier.
affects: >=0.4.1
gotchaThe task name must be 'typescript-formatter' (hyphenated), not 'tsfmt' or 'typescript_formatter'.
fix
Use the exact string 'typescript-formatter' in grunt.initConfig.
affects: all
gotchaOptions must be nested under 'configuration' key inside 'options' to be passed to typescript-formatter.
fix
Set options.configuration instead of options directly.
affects: all
Errors
Common errors & fixes
Warning: Task "typescript-formatter" not found. Use --force to continue.
The plugin is not loaded or installed. grunt.loadNpmTasks('grunt-typescript-formatter') is missing or misspelled.
fix
Run 'npm install grunt-typescript-formatter --save-dev' and add 'grunt.loadNpmTasks('grunt-typescript-formatter');' to Gruntfile.
Fatal error: Unable to find module 'typescript-formatter'.
The peer dependency typescript-formatter is not installed.
fix
Run 'npm install typescript-formatter --save-dev'.
TypeError: Cannot read property 'configuration' of undefined
The 'configuration' property is missing from the options object, or options is undefined.
fix
Ensure options is an object with a 'configuration' key, e.g., options: { configuration: { indent: '  ' } }.
Upgrade
Version history
0.4.1latest on npm
Audit
Dependencies
gruntrequiredPeer dependency required for Grunt plugin functionality.
typescript-formatterrequiredPeer dependency; the core formatting library.
Agent activity
4 hits · last 30 days
node
4
Resources
grunt-typescript-formatter — npm install grunt-typescript-formatter · libregistry