mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-09 21:12:31 +08:00
Add Apple's swift-format as a linter
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('swift', 'swiftformat')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(Should use default command when not in a swift package):
|
||||
call ale#test#SetFilename('../swift-test-files/non-swift-package-project/src/folder/dummy.swift')
|
||||
|
||||
AssertLinter 'swift-format',
|
||||
\ ale#Escape('swift-format') . ' --mode lint %t'
|
||||
|
||||
Execute(Should use swift run when in a swift package):
|
||||
call ale#test#SetFilename('../swift-test-files/swift-package-project/src/folder/dummy.swift')
|
||||
|
||||
AssertLinter 'swift',
|
||||
\ ale#Escape('swift') . ' run swift-format --mode lint %t'
|
||||
|
||||
Execute(Should let users configure a global executable and override local paths):
|
||||
call ale#test#SetFilename('../swift-test-files/swift-package-project/src/folder/dummy.swift')
|
||||
|
||||
let g:ale_swift_swiftformat_executable = '/path/to/custom/swift-format'
|
||||
|
||||
AssertLinter '/path/to/custom/swift-format',
|
||||
\ ale#Escape('/path/to/custom/swift-format') . ' --mode lint %t'
|
||||
28
test/handler/test_swiftformat_handler.vader
Normal file
28
test/handler/test_swiftformat_handler.vader
Normal file
@@ -0,0 +1,28 @@
|
||||
Before:
|
||||
runtime ale_linters/swift/swiftformat.vim
|
||||
|
||||
After:
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(The swiftformat handler should parse lines correctly):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 4,
|
||||
\ 'col': 21,
|
||||
\ 'type': 'W',
|
||||
\ 'code': 'DoNotUseSemicolons',
|
||||
\ 'text': 'remove '';'' and move the next statement to the new line',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 3,
|
||||
\ 'col': 12,
|
||||
\ 'type': 'W',
|
||||
\ 'code': 'Spacing',
|
||||
\ 'text': 'remove 1 space'
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#swift#swiftformat#Handle(bufnr(''), [
|
||||
\ 'Sources/main.swift:4:21: warning: [DoNotUseSemicolons]: remove '';'' and move the next statement to the new line',
|
||||
\ 'Sources/main.swift:3:12: warning: [Spacing]: remove 1 space',
|
||||
\ ])
|
||||
Reference in New Issue
Block a user