Skip to content

Commit

Permalink
update CHANGELOG
Browse files Browse the repository at this point in the history
  • Loading branch information
Flet committed Sep 3, 2016
1 parent 1561f7b commit 84a394a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 8 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased
* engage
## 1.1.0
* update to standard v8 and add button to test `--fix`
8 changes: 4 additions & 4 deletions bundle.js

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,22 @@ standardizer.version(function (err, versions) {
})

function render (state) {
return h('div', [renderFormatButton(), renderMessages(state)])
return h('div', [renderFixButton(), renderFormatButton(), renderMessages(state)])
}

function renderFormatButton () {
return h('button', {onclick: formatCode}, 'Format Code')
return h('button', {onclick: formatCode}, 'Format using standard-format')
}

function renderFixButton () {
return h('button', {onclick: fixCode}, 'Correct errors using --fix')
}

function fixCode () {
standardizer.fix(editor.getValue(), function (err, text) {
if (err) throw err
editor.setValue(text)
})
}

function formatCode () {
Expand Down
17 changes: 17 additions & 0 deletions standardizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var url = 'https://standardizer.flet.io/'
var version = url + '/version'
var lint = url + '/lint'
var format = url + '/format'
var fix = url + '/fix'

var headers = {
'Content-Type': 'application/json'
Expand Down Expand Up @@ -42,6 +43,22 @@ module.exports = {
})
},

fix: function (text, cb) {
if (!text) return cb(null, [])

var opts = {
method: 'POST',
url: fix,
body: {text: text},
headers: headers
}
process(opts, function (err, resp) {
if (err) return cb(err)
var fixedText = resp.results[0].output || text
return cb(null, fixedText)
})
},

format: function (text, cb) {
if (!text) return cb(null, [])

Expand Down

0 comments on commit 84a394a

Please sign in to comment.