Beautify all src/ files to pass linting with Coffeelint

This commit is contained in:
Glavin Wiechert 2015-06-11 22:57:03 -03:00
parent 6b7b3d6401
commit c1f09e4f8b
15 changed files with 479 additions and 480 deletions

View File

@ -1,10 +1,13 @@
{
"indentation" : {
"level" : "error",
"value" : 2
"indentation": {
"level": "error",
"value": 2
},
"line_endings" : {
"value" : "unix",
"level" : "error"
"line_endings": {
"value": "unix",
"level": "error"
},
"max_line_length": {
"value": false
}
}

View File

@ -5,7 +5,7 @@ Requires https://github.com/hhatto/autopep8
"use strict"
Beautifier = require('./beautifier')
module.exports = class autopep8 extends Beautifier
module.exports = class Autopep8 extends Beautifier
name: "autopep8"

View File

@ -61,9 +61,9 @@ module.exports = class Beautifier
temp.open(name, (err, info) =>
@debug('tempFile', name, err, info)
return reject(err) if err
fs.write(info.fd, contents, (err) =>
fs.write(info.fd, contents, (err) ->
return reject(err) if err
fs.close(info.fd, (err) =>
fs.close(info.fd, (err) ->
return reject(err) if err
resolve(info.path)
)

View File

@ -5,7 +5,7 @@ Requires http://golang.org/cmd/gofmt/
"use strict"
Beautifier = require('./beautifier')
module.exports = class gofmt extends Beautifier
module.exports = class Gofmt extends Beautifier
name: "gofmt"
options: {

View File

@ -673,7 +673,7 @@ module.exports = class Beautifiers extends EventEmitter
# http://editorconfig.org/
editorconfig ?= require('editorconfig')
editorConfigOptions = editorconfig.parse(editedFilePath)
.then((editorConfigOptions) =>
.then((editorConfigOptions) ->
logger.verbose('editorConfigOptions', editorConfigOptions)
@ -788,9 +788,9 @@ module.exports = class Beautifiers extends EventEmitter
# where `selection` could be `html`, `js`, 'css', etc
for selection in selections
# Merge current options on top of fallback options
logger.verbose('options', selection, currOptions[selection]);
logger.verbose('options', selection, currOptions[selection])
_.merge collectedConfig, currOptions[selection]
logger.verbose('options', selection, collectedConfig);
logger.verbose('options', selection, collectedConfig)
extend result, collectedConfig
, {})

View File

@ -5,7 +5,7 @@ Requires https://github.com/nrc/rustfmt
"use strict"
Beautifier = require('./beautifier')
module.exports = class rustfmt extends Beautifier
module.exports = class Rustfmt extends Beautifier
name: "rustfmt"

View File

@ -5,7 +5,7 @@ Requires https://github.com/andialbrecht/sqlparse
"use strict"
Beautifier = require('./beautifier')
module.exports = class sqlformat extends Beautifier
module.exports = class Sqlformat extends Beautifier
name: "sqlformat"
options: {

View File

@ -23,7 +23,7 @@ module.exports = class Uncrustify extends Beautifier
beautify: (text, language, options) ->
# console.log('uncrustify.beautify', language, options)
return new @Promise((resolve, reject) =>
return new @Promise((resolve, reject) ->
configPath = options.configPath
unless configPath
# No custom config path

View File

@ -56,9 +56,8 @@ beautifier.on('beautify::end', ->
loadingView?.hide()
)
# Show error
showError = (error) =>
showError = (error) ->
if not atom.config.get("atom-beautify.muteAllErrors")
# console.log(e)
stack = error.stack
detail = error.description or error.message
@ -95,13 +94,11 @@ beautify = ({onSave}) ->
# User's Home path
# Project path
# Asynchronously and callback-style
beautifyCompleted = (text)=>
beautifyCompleted = (text) ->
# console.log 'beautifyCompleted'
if not text?
# Do nothing, is undefined
# console.log 'beautifyCompleted'
else if text instanceof Error
showError(text)
else if typeof text is "string"
@ -110,16 +107,13 @@ beautify = ({onSave}) ->
# console.log "Replacing current editor's text with new text"
posArray = getCursors(editor)
# console.log "posArray:
origScrollTop = editor.getScrollTop()
# console.log "origScrollTop:
if not forceEntireFile and isSelection
selectedBufferRange = editor.getSelectedBufferRange()
# console.log "selectedBufferRange:
editor.setTextInBufferRange selectedBufferRange, text
else
@ -130,7 +124,6 @@ beautify = ({onSave}) ->
# console.log "setCursors"
setCursors editor, posArray
# console.log "Done setCursors"
# Let the scrollTop setting run after all the save related stuff is run,
# otherwise setScrollTop is not working, probably because the cursor
@ -190,6 +183,7 @@ beautify = ({onSave}) ->
catch e
showError(e)
return
beautifyFilePath = (filePath, callback) ->
# Show in progress indicate on file's tree-view entry
@ -235,6 +229,7 @@ beautifyFilePath = (filePath, callback) ->
catch e
return cb(e)
)
beautifyFile = ({target}) ->
filePath = target.dataset.path
return unless filePath
@ -243,6 +238,7 @@ beautifyFile = ({target}) ->
# console.log("Beautify File
)
return
beautifyDirectory = ({target}) ->
dirPath = target.dataset.path
return unless dirPath
@ -274,12 +270,12 @@ beautifyDirectory = ({target}) ->
)
)
return
debug = () ->
# Get current editor
editor = atom.workspace.getActiveTextEditor()
# Check if there is an active editor
if not editor?
return confirm("Active Editor not found.\n" +
@ -343,7 +339,7 @@ debug = () ->
allOptions = beautifier.getOptionsForPath(filePath, editor)
# Resolve options with promises
Promise.all(allOptions)
.then((allOptions) =>
.then((allOptions) ->
# Extract options
[
editorOptions
@ -371,7 +367,6 @@ debug = () ->
"```json\n#{JSON.stringify(projectOptions, undefined, 4)}\n```")
logs = ""
subscription = logger.onLogging((msg) ->
# console.log('logging', msg)
logs += msg
)
@ -399,10 +394,10 @@ debug = () ->
return cb(e)
)
handleSaveEvent = =>
atom.workspace.observeTextEditors (editor) =>
handleSaveEvent = ->
atom.workspace.observeTextEditors (editor) ->
buffer = editor.getBuffer()
disposable = buffer.onDidSave(({path : filePath}) =>
disposable = buffer.onDidSave(({path : filePath}) ->
path ?= require('path')
# Get Grammar
grammar = editor.getGrammar().name
@ -441,3 +436,4 @@ plugin.activate = ->
atom.commands.add "atom-workspace", "atom-beautify:help-debug-editor", debug
atom.commands.add ".tree-view .file .name", "atom-beautify:beautify-file", beautifyFile
atom.commands.add ".tree-view .directory .name", "atom-beautify:beautify-directory", beautifyDirectory

View File

@ -59,7 +59,7 @@ class MessageView extends View
destroy: ->
addMessage: (message) =>
@messages.push(message);
@messages.push(message)
@refresh()
clearMessages: =>