Beautify all src/ files to pass linting with Coffeelint
This commit is contained in:
parent
6b7b3d6401
commit
c1f09e4f8b
|
@ -1,10 +1,13 @@
|
||||||
{
|
{
|
||||||
"indentation" : {
|
"indentation": {
|
||||||
"level" : "error",
|
"level": "error",
|
||||||
"value" : 2
|
"value": 2
|
||||||
},
|
},
|
||||||
"line_endings" : {
|
"line_endings": {
|
||||||
"value" : "unix",
|
"value": "unix",
|
||||||
"level" : "error"
|
"level": "error"
|
||||||
|
},
|
||||||
|
"max_line_length": {
|
||||||
|
"value": false
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,7 +5,7 @@ Requires https://github.com/hhatto/autopep8
|
||||||
"use strict"
|
"use strict"
|
||||||
Beautifier = require('./beautifier')
|
Beautifier = require('./beautifier')
|
||||||
|
|
||||||
module.exports = class autopep8 extends Beautifier
|
module.exports = class Autopep8 extends Beautifier
|
||||||
|
|
||||||
name: "autopep8"
|
name: "autopep8"
|
||||||
|
|
||||||
|
|
|
@ -61,9 +61,9 @@ module.exports = class Beautifier
|
||||||
temp.open(name, (err, info) =>
|
temp.open(name, (err, info) =>
|
||||||
@debug('tempFile', name, err, info)
|
@debug('tempFile', name, err, info)
|
||||||
return reject(err) if err
|
return reject(err) if err
|
||||||
fs.write(info.fd, contents, (err) =>
|
fs.write(info.fd, contents, (err) ->
|
||||||
return reject(err) if err
|
return reject(err) if err
|
||||||
fs.close(info.fd, (err) =>
|
fs.close(info.fd, (err) ->
|
||||||
return reject(err) if err
|
return reject(err) if err
|
||||||
resolve(info.path)
|
resolve(info.path)
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,7 +5,7 @@ Requires http://golang.org/cmd/gofmt/
|
||||||
"use strict"
|
"use strict"
|
||||||
Beautifier = require('./beautifier')
|
Beautifier = require('./beautifier')
|
||||||
|
|
||||||
module.exports = class gofmt extends Beautifier
|
module.exports = class Gofmt extends Beautifier
|
||||||
name: "gofmt"
|
name: "gofmt"
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
|
|
|
@ -673,7 +673,7 @@ module.exports = class Beautifiers extends EventEmitter
|
||||||
# http://editorconfig.org/
|
# http://editorconfig.org/
|
||||||
editorconfig ?= require('editorconfig')
|
editorconfig ?= require('editorconfig')
|
||||||
editorConfigOptions = editorconfig.parse(editedFilePath)
|
editorConfigOptions = editorconfig.parse(editedFilePath)
|
||||||
.then((editorConfigOptions) =>
|
.then((editorConfigOptions) ->
|
||||||
|
|
||||||
logger.verbose('editorConfigOptions', editorConfigOptions)
|
logger.verbose('editorConfigOptions', editorConfigOptions)
|
||||||
|
|
||||||
|
@ -788,9 +788,9 @@ module.exports = class Beautifiers extends EventEmitter
|
||||||
# where `selection` could be `html`, `js`, 'css', etc
|
# where `selection` could be `html`, `js`, 'css', etc
|
||||||
for selection in selections
|
for selection in selections
|
||||||
# Merge current options on top of fallback options
|
# Merge current options on top of fallback options
|
||||||
logger.verbose('options', selection, currOptions[selection]);
|
logger.verbose('options', selection, currOptions[selection])
|
||||||
_.merge collectedConfig, currOptions[selection]
|
_.merge collectedConfig, currOptions[selection]
|
||||||
logger.verbose('options', selection, collectedConfig);
|
logger.verbose('options', selection, collectedConfig)
|
||||||
|
|
||||||
extend result, collectedConfig
|
extend result, collectedConfig
|
||||||
, {})
|
, {})
|
||||||
|
|
|
@ -5,7 +5,7 @@ Requires https://github.com/nrc/rustfmt
|
||||||
"use strict"
|
"use strict"
|
||||||
Beautifier = require('./beautifier')
|
Beautifier = require('./beautifier')
|
||||||
|
|
||||||
module.exports = class rustfmt extends Beautifier
|
module.exports = class Rustfmt extends Beautifier
|
||||||
|
|
||||||
name: "rustfmt"
|
name: "rustfmt"
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ Requires https://github.com/andialbrecht/sqlparse
|
||||||
"use strict"
|
"use strict"
|
||||||
Beautifier = require('./beautifier')
|
Beautifier = require('./beautifier')
|
||||||
|
|
||||||
module.exports = class sqlformat extends Beautifier
|
module.exports = class Sqlformat extends Beautifier
|
||||||
name: "sqlformat"
|
name: "sqlformat"
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
|
|
|
@ -23,7 +23,7 @@ module.exports = class Uncrustify extends Beautifier
|
||||||
|
|
||||||
beautify: (text, language, options) ->
|
beautify: (text, language, options) ->
|
||||||
# console.log('uncrustify.beautify', language, options)
|
# console.log('uncrustify.beautify', language, options)
|
||||||
return new @Promise((resolve, reject) =>
|
return new @Promise((resolve, reject) ->
|
||||||
configPath = options.configPath
|
configPath = options.configPath
|
||||||
unless configPath
|
unless configPath
|
||||||
# No custom config path
|
# No custom config path
|
||||||
|
|
|
@ -56,9 +56,8 @@ beautifier.on('beautify::end', ->
|
||||||
loadingView?.hide()
|
loadingView?.hide()
|
||||||
)
|
)
|
||||||
# Show error
|
# Show error
|
||||||
showError = (error) =>
|
showError = (error) ->
|
||||||
if not atom.config.get("atom-beautify.muteAllErrors")
|
if not atom.config.get("atom-beautify.muteAllErrors")
|
||||||
|
|
||||||
# console.log(e)
|
# console.log(e)
|
||||||
stack = error.stack
|
stack = error.stack
|
||||||
detail = error.description or error.message
|
detail = error.description or error.message
|
||||||
|
@ -95,13 +94,11 @@ beautify = ({onSave}) ->
|
||||||
# User's Home path
|
# User's Home path
|
||||||
# Project path
|
# Project path
|
||||||
# Asynchronously and callback-style
|
# Asynchronously and callback-style
|
||||||
beautifyCompleted = (text)=>
|
beautifyCompleted = (text) ->
|
||||||
|
|
||||||
# console.log 'beautifyCompleted'
|
|
||||||
if not text?
|
if not text?
|
||||||
|
|
||||||
|
|
||||||
# Do nothing, is undefined
|
# Do nothing, is undefined
|
||||||
|
# console.log 'beautifyCompleted'
|
||||||
else if text instanceof Error
|
else if text instanceof Error
|
||||||
showError(text)
|
showError(text)
|
||||||
else if typeof text is "string"
|
else if typeof text is "string"
|
||||||
|
@ -110,16 +107,13 @@ beautify = ({onSave}) ->
|
||||||
# console.log "Replacing current editor's text with new text"
|
# console.log "Replacing current editor's text with new text"
|
||||||
posArray = getCursors(editor)
|
posArray = getCursors(editor)
|
||||||
|
|
||||||
|
|
||||||
# console.log "posArray:
|
# console.log "posArray:
|
||||||
origScrollTop = editor.getScrollTop()
|
origScrollTop = editor.getScrollTop()
|
||||||
|
|
||||||
|
|
||||||
# console.log "origScrollTop:
|
# console.log "origScrollTop:
|
||||||
if not forceEntireFile and isSelection
|
if not forceEntireFile and isSelection
|
||||||
selectedBufferRange = editor.getSelectedBufferRange()
|
selectedBufferRange = editor.getSelectedBufferRange()
|
||||||
|
|
||||||
|
|
||||||
# console.log "selectedBufferRange:
|
# console.log "selectedBufferRange:
|
||||||
editor.setTextInBufferRange selectedBufferRange, text
|
editor.setTextInBufferRange selectedBufferRange, text
|
||||||
else
|
else
|
||||||
|
@ -130,7 +124,6 @@ beautify = ({onSave}) ->
|
||||||
# console.log "setCursors"
|
# console.log "setCursors"
|
||||||
setCursors editor, posArray
|
setCursors editor, posArray
|
||||||
|
|
||||||
|
|
||||||
# console.log "Done setCursors"
|
# console.log "Done setCursors"
|
||||||
# Let the scrollTop setting run after all the save related stuff is run,
|
# Let the scrollTop setting run after all the save related stuff is run,
|
||||||
# otherwise setScrollTop is not working, probably because the cursor
|
# otherwise setScrollTop is not working, probably because the cursor
|
||||||
|
@ -190,6 +183,7 @@ beautify = ({onSave}) ->
|
||||||
catch e
|
catch e
|
||||||
showError(e)
|
showError(e)
|
||||||
return
|
return
|
||||||
|
|
||||||
beautifyFilePath = (filePath, callback) ->
|
beautifyFilePath = (filePath, callback) ->
|
||||||
|
|
||||||
# Show in progress indicate on file's tree-view entry
|
# Show in progress indicate on file's tree-view entry
|
||||||
|
@ -235,6 +229,7 @@ beautifyFilePath = (filePath, callback) ->
|
||||||
catch e
|
catch e
|
||||||
return cb(e)
|
return cb(e)
|
||||||
)
|
)
|
||||||
|
|
||||||
beautifyFile = ({target}) ->
|
beautifyFile = ({target}) ->
|
||||||
filePath = target.dataset.path
|
filePath = target.dataset.path
|
||||||
return unless filePath
|
return unless filePath
|
||||||
|
@ -243,6 +238,7 @@ beautifyFile = ({target}) ->
|
||||||
# console.log("Beautify File
|
# console.log("Beautify File
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
beautifyDirectory = ({target}) ->
|
beautifyDirectory = ({target}) ->
|
||||||
dirPath = target.dataset.path
|
dirPath = target.dataset.path
|
||||||
return unless dirPath
|
return unless dirPath
|
||||||
|
@ -274,12 +270,12 @@ beautifyDirectory = ({target}) ->
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
debug = () ->
|
debug = () ->
|
||||||
|
|
||||||
# Get current editor
|
# Get current editor
|
||||||
editor = atom.workspace.getActiveTextEditor()
|
editor = atom.workspace.getActiveTextEditor()
|
||||||
|
|
||||||
|
|
||||||
# Check if there is an active editor
|
# Check if there is an active editor
|
||||||
if not editor?
|
if not editor?
|
||||||
return confirm("Active Editor not found.\n" +
|
return confirm("Active Editor not found.\n" +
|
||||||
|
@ -343,7 +339,7 @@ debug = () ->
|
||||||
allOptions = beautifier.getOptionsForPath(filePath, editor)
|
allOptions = beautifier.getOptionsForPath(filePath, editor)
|
||||||
# Resolve options with promises
|
# Resolve options with promises
|
||||||
Promise.all(allOptions)
|
Promise.all(allOptions)
|
||||||
.then((allOptions) =>
|
.then((allOptions) ->
|
||||||
# Extract options
|
# Extract options
|
||||||
[
|
[
|
||||||
editorOptions
|
editorOptions
|
||||||
|
@ -371,7 +367,6 @@ debug = () ->
|
||||||
"```json\n#{JSON.stringify(projectOptions, undefined, 4)}\n```")
|
"```json\n#{JSON.stringify(projectOptions, undefined, 4)}\n```")
|
||||||
logs = ""
|
logs = ""
|
||||||
subscription = logger.onLogging((msg) ->
|
subscription = logger.onLogging((msg) ->
|
||||||
|
|
||||||
# console.log('logging', msg)
|
# console.log('logging', msg)
|
||||||
logs += msg
|
logs += msg
|
||||||
)
|
)
|
||||||
|
@ -399,10 +394,10 @@ debug = () ->
|
||||||
return cb(e)
|
return cb(e)
|
||||||
)
|
)
|
||||||
|
|
||||||
handleSaveEvent = =>
|
handleSaveEvent = ->
|
||||||
atom.workspace.observeTextEditors (editor) =>
|
atom.workspace.observeTextEditors (editor) ->
|
||||||
buffer = editor.getBuffer()
|
buffer = editor.getBuffer()
|
||||||
disposable = buffer.onDidSave(({path : filePath}) =>
|
disposable = buffer.onDidSave(({path : filePath}) ->
|
||||||
path ?= require('path')
|
path ?= require('path')
|
||||||
# Get Grammar
|
# Get Grammar
|
||||||
grammar = editor.getGrammar().name
|
grammar = editor.getGrammar().name
|
||||||
|
@ -441,3 +436,4 @@ plugin.activate = ->
|
||||||
atom.commands.add "atom-workspace", "atom-beautify:help-debug-editor", debug
|
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 .file .name", "atom-beautify:beautify-file", beautifyFile
|
||||||
atom.commands.add ".tree-view .directory .name", "atom-beautify:beautify-directory", beautifyDirectory
|
atom.commands.add ".tree-view .directory .name", "atom-beautify:beautify-directory", beautifyDirectory
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ class MessageView extends View
|
||||||
destroy: ->
|
destroy: ->
|
||||||
|
|
||||||
addMessage: (message) =>
|
addMessage: (message) =>
|
||||||
@messages.push(message);
|
@messages.push(message)
|
||||||
@refresh()
|
@refresh()
|
||||||
|
|
||||||
clearMessages: =>
|
clearMessages: =>
|
||||||
|
|
Loading…
Reference in New Issue