added import sorting using isort + small yapf fix
This commit is contained in:
parent
04528f7643
commit
1bc919eafa
|
@ -15,10 +15,24 @@ module.exports = class Autopep8 extends Beautifier
|
|||
|
||||
beautify: (text, language, options) ->
|
||||
@run("autopep8", [
|
||||
@tempFile("input", text)
|
||||
tempFile = @tempFile("input", text)
|
||||
"-i"
|
||||
["--max-line-length", "#{options.max_line_length}"] if options.max_line_length?
|
||||
["--indent-size","#{options.indent_size}"] if options.indent_size?
|
||||
["--ignore","#{options.ignore.join(',')}"] if options.ignore?
|
||||
], help: {
|
||||
link: "https://github.com/hhatto/autopep8"
|
||||
})
|
||||
.then(=>
|
||||
if options.sort_imports
|
||||
@run("isort",
|
||||
[tempFile],
|
||||
help: {
|
||||
link: "https://github.com/timothycrosley/isort"
|
||||
})
|
||||
.then(=>
|
||||
@readFile(tempFile)
|
||||
)
|
||||
else
|
||||
@readFile(tempFile)
|
||||
)
|
||||
|
|
|
@ -15,8 +15,22 @@ module.exports = class Yapf extends Beautifier
|
|||
|
||||
beautify: (text, language, options) ->
|
||||
@run("yapf", [
|
||||
"-i"
|
||||
["--style=pep8"]
|
||||
@tempFile("input", text)
|
||||
tempFile = @tempFile("input", text)
|
||||
], help: {
|
||||
link: "https://github.com/google/yapf"
|
||||
})
|
||||
}, ignoreReturnCode: true)
|
||||
.then(=>
|
||||
if options.sort_imports
|
||||
@run("isort",
|
||||
[tempFile],
|
||||
help: {
|
||||
link: "https://github.com/timothycrosley/isort"
|
||||
})
|
||||
.then(=>
|
||||
@readFile(tempFile)
|
||||
)
|
||||
else
|
||||
@readFile(tempFile)
|
||||
)
|
||||
|
|
|
@ -41,5 +41,9 @@ module.exports = {
|
|||
items:
|
||||
type: 'string'
|
||||
description: "do not fix these errors/warnings"
|
||||
sort_imports:
|
||||
type: 'boolean'
|
||||
default: false
|
||||
description: "sort imports (requires isort installed)"
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue