Closes #341. Add indent_size option to Rubocop beautifier
This commit is contained in:
parent
94553b0a23
commit
198f0770dd
|
@ -40,3 +40,5 @@
|
|||
indent_class: true
|
||||
indent_with_tabs: 0
|
||||
indent_size: 1
|
||||
ruby:
|
||||
indent_size: 4
|
|
@ -9,15 +9,32 @@ module.exports = class Rubocop extends Beautifier
|
|||
name: "Rubocop"
|
||||
|
||||
options: {
|
||||
Ruby: true
|
||||
Ruby:
|
||||
indent_size: true
|
||||
}
|
||||
|
||||
beautify: (text, language, options) ->
|
||||
|
||||
# Generate config file
|
||||
yaml = require("yaml-front-matter")
|
||||
|
||||
config = {
|
||||
"Style/IndentationWidth":
|
||||
"Width": options.indent_size
|
||||
}
|
||||
configStr = yaml.safeDump(config)
|
||||
console.log("rubocop", config, configStr)
|
||||
|
||||
@run("rubocop", [
|
||||
"--auto-correct"
|
||||
"--config", @tempFile("rubocop-config", configStr)
|
||||
tempFile = @tempFile("temp", text)
|
||||
], {ignoreReturnCode: true})
|
||||
.then(=>
|
||||
# console.log('rubocop', arguments, tempFile)
|
||||
@readFile(tempFile)
|
||||
.then((text) ->
|
||||
console.log('rubocop', text)
|
||||
return text
|
||||
)
|
||||
)
|
||||
|
|
|
@ -9,7 +9,7 @@ module.exports = class RubyBeautify extends Beautifier
|
|||
name: "Ruby Beautify"
|
||||
|
||||
options: {
|
||||
Ruby: true
|
||||
Ruby: false
|
||||
}
|
||||
|
||||
beautify: (text, language, options) ->
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
# Get Atom defaults
|
||||
tabLength = atom?.config.get('editor.tabLength') ? 4
|
||||
softTabs = atom?.config.get('editor.softTabs') ? true
|
||||
defaultIndentSize = (if softTabs then tabLength else 1)
|
||||
defaultIndentChar = (if softTabs then " " else "\t")
|
||||
defaultIndentWithTabs = not softTabs
|
||||
|
||||
module.exports = {
|
||||
|
||||
name: "Ruby"
|
||||
|
@ -18,6 +25,11 @@ module.exports = {
|
|||
"rb"
|
||||
]
|
||||
|
||||
options: []
|
||||
options:
|
||||
indent_size:
|
||||
type: 'integer'
|
||||
default: defaultIndentSize
|
||||
minimum: 0
|
||||
description: "Indentation size/length"
|
||||
|
||||
}
|
Loading…
Reference in New Issue