Skip to content

Commit

Permalink
Add TypeScript support
Browse files Browse the repository at this point in the history
  • Loading branch information
ewgenius committed Oct 14, 2014
1 parent 6013e7e commit dcc9e2d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -57,12 +57,12 @@ Or Settings/Preferences ➔ Packages ➔ Search for `atom-beautify`
- Requires [Uncrustify](http://sourceforge.net/projects/uncrustify/)
- [x] [Vala](https://github.com/Glavin001/atom-beautify/issues/57)
- Requires [Uncrustify](http://sourceforge.net/projects/uncrustify/)
- [x] [TypeScript](https://github.com/Glavin001/atom-beautify/issues/49)

### Road Map

#### Language support

- [ ] [TypeScript](https://github.com/Glavin001/atom-beautify/issues/49)
- [ ] [Perl](https://github.com/Glavin001/atom-beautify/issues/33)


Expand Down
8 changes: 8 additions & 0 deletions examples/simple-jsbeautifyrc/test.ts
@@ -0,0 +1,8 @@
module TestModule {
export class A {
constructor(private a: string) {
}
}
export class B extends A {
}
};
12 changes: 12 additions & 0 deletions lib/langs/typescript-beautify.coffee
@@ -0,0 +1,12 @@
"use strict"
TF = require("typescript-formatter/typescript-toolbox/lib/formatter")

module.exports = (text, options, callback) ->
opts = TF.createDefaultFormatCodeOptions()

opts.TabSize = options.tab_width
opts.IndentSize = options.indent_size

result = TF.applyFormatterToContent(text, opts)
callback result
result
5 changes: 5 additions & 0 deletions lib/language-options.coffee
Expand Up @@ -18,6 +18,7 @@ beautifyCoffeeScript = null
uncrustifyBeautifier = null
beautifyHTMLERB = null
beautifyMarkdown = null
beautifyTypeScript = null
Analytics = null

# Misc
Expand Down Expand Up @@ -50,6 +51,7 @@ module.exports =
"d"
"pawn"
"vala"
"typescript"
]

# Default options per language
Expand Down Expand Up @@ -233,6 +235,9 @@ module.exports =
options.languageOverride = "JAVA"
uncrustifyBeautifier ?= require("./langs/uncrustify/")
uncrustifyBeautifier text, options, beautifyCompleted
when "TypeScript"
beautifyTypeScript ?= require("./langs/typescript-beautify")
beautifyTypeScript text, self.getOptions("js", allOptions), beautifyCompleted
else
unsupportedGrammar = true

Expand Down
6 changes: 4 additions & 2 deletions package.json
Expand Up @@ -3,7 +3,7 @@
"main": "./lib/beautify",
"version": "0.13.4",
"private": true,
"description": "Beautify HTML, CSS, JavaScript, PHP, Python, Ruby, Java, C, C++, C#, Objective-C, CoffeeScript, and SQL in Atom",
"description": "Beautify HTML, CSS, JavaScript, PHP, Python, Ruby, Java, C, C++, C#, Objective-C, CoffeeScript, TypeScript, and SQL in Atom",
"repository": {
"type": "git",
"url": "https://github.com/Glavin001/atom-beautify"
Expand Down Expand Up @@ -63,6 +63,7 @@
"python",
"ruby",
"coffeescript",
"typescript",
"c",
"c++",
"cpp",
Expand Down Expand Up @@ -94,6 +95,7 @@
"coffee-formatter": "git+https://github.com/Glavin001/Coffee-Formatter.git",
"atom-message-panel": "^1.1.1",
"editorconfig": "^0.11.4",
"loophole": "^1.0.0"
"loophole": "^1.0.0",
"typescript-formatter": "~0.1.4"
}
}

0 comments on commit dcc9e2d

Please sign in to comment.