mirror of
https://github.com/dense-analysis/ale.git
synced 2026-05-13 10:08:32 +08:00
@@ -207,6 +207,11 @@ let s:default_registry = {
|
|||||||
\ 'suggested_filetypes': ['puppet'],
|
\ 'suggested_filetypes': ['puppet'],
|
||||||
\ 'description': 'Run puppet-lint -f on a file.',
|
\ 'description': 'Run puppet-lint -f on a file.',
|
||||||
\ },
|
\ },
|
||||||
|
\ 'replace_emdash': {
|
||||||
|
\ 'function': 'ale#fixers#generic#ReplaceEmDash',
|
||||||
|
\ 'suggested_filetypes': [],
|
||||||
|
\ 'description': 'Replace em dash with -- ASCII characters.',
|
||||||
|
\ },
|
||||||
\ 'remove_trailing_lines': {
|
\ 'remove_trailing_lines': {
|
||||||
\ 'function': 'ale#fixers#generic#RemoveTrailingBlankLines',
|
\ 'function': 'ale#fixers#generic#RemoveTrailingBlankLines',
|
||||||
\ 'suggested_filetypes': [],
|
\ 'suggested_filetypes': [],
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
" Author: w0rp <devw0rp@gmail.com>
|
" Author: w0rp <devw0rp@gmail.com>
|
||||||
" Description: Generic functions for fixing files with.
|
" Description: Generic functions for fixing files with.
|
||||||
|
|
||||||
|
function! ale#fixers#generic#ReplaceEmDash(buffer, lines) abort
|
||||||
|
return map(copy(a:lines), {_, line -> substitute(line, "\u2014", '--', 'g')})
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! ale#fixers#generic#RemoveTrailingBlankLines(buffer, lines) abort
|
function! ale#fixers#generic#RemoveTrailingBlankLines(buffer, lines) abort
|
||||||
let l:end_index = len(a:lines) - 1
|
let l:end_index = len(a:lines) - 1
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
Execute(ReplaceEmDash should not change existing dashes):
|
||||||
|
AssertEqual
|
||||||
|
\ ['foo - bar', 'baz -- qux -- end'],
|
||||||
|
\ ale#fixers#generic#ReplaceEmDash(bufnr(''), ["foo - bar", "baz -- qux \u2014 end"])
|
||||||
|
|
||||||
|
Execute(ReplaceEmDash should replace em dashes with double hyphens):
|
||||||
|
AssertEqual
|
||||||
|
\ ['foo -- bar', 'baz -- qux -- end'],
|
||||||
|
\ ale#fixers#generic#ReplaceEmDash(bufnr(''), ["foo \u2014 bar", "baz \u2014 qux \u2014 end"])
|
||||||
|
|
||||||
|
Execute(ReplaceEmDash should handle lines without em dashes):
|
||||||
|
AssertEqual
|
||||||
|
\ ['no dashes here', 'just -- normal'],
|
||||||
|
\ ale#fixers#generic#ReplaceEmDash(bufnr(''), ['no dashes here', 'just -- normal'])
|
||||||
|
|
||||||
|
Execute(ReplaceEmDash should handle empty input):
|
||||||
|
AssertEqual
|
||||||
|
\ [],
|
||||||
|
\ ale#fixers#generic#ReplaceEmDash(bufnr(''), [])
|
||||||
|
|
||||||
|
Execute(RemoveTrailingBlankLines should remove trailing empty lines):
|
||||||
|
AssertEqual
|
||||||
|
\ ['foo', 'bar'],
|
||||||
|
\ ale#fixers#generic#RemoveTrailingBlankLines(bufnr(''), ['foo', 'bar', '', ''])
|
||||||
|
|
||||||
|
Execute(RemoveTrailingBlankLines should preserve content when no trailing blanks):
|
||||||
|
AssertEqual
|
||||||
|
\ ['foo', 'bar'],
|
||||||
|
\ ale#fixers#generic#RemoveTrailingBlankLines(bufnr(''), ['foo', 'bar'])
|
||||||
Reference in New Issue
Block a user