add prettier fixer support for 'less' filetype

This commit is contained in:
Zack Kourouma 2017-10-20 18:29:57 -07:00
parent 346c91fb6b
commit e023e7a2fe
4 changed files with 18 additions and 2 deletions

View file

@ -39,7 +39,7 @@ let s:default_registry = {
\ },
\ 'prettier': {
\ 'function': 'ale#fixers#prettier#Fix',
\ 'suggested_filetypes': ['javascript', 'typescript', 'json', 'css', 'scss'],
\ 'suggested_filetypes': ['javascript', 'typescript', 'json', 'css', 'scss', 'less'],
\ 'description': 'Apply prettier to a file.',
\ },
\ 'prettier_eslint': {

View file

@ -49,7 +49,7 @@ function! ale#fixers#prettier#Fix(buffer) abort
if match(l:options, '--parser') == -1
if l:filetype is# 'typescript'
let l:parser = 'typescript'
elseif l:filetype =~# 'css\|scss'
elseif l:filetype =~# 'css\|scss\|less'
let l:parser = 'postcss'
elseif l:filetype is# 'json'
let l:parser = 'json'

View file

@ -95,6 +95,8 @@ CONTENTS *ale-contents*
kotlin................................|ale-kotlin-options|
kotlinc.............................|ale-kotlin-kotlinc|
ktlint..............................|ale-kotlin-ktlint|
less..................................|ale-less-options|
prettier............................|ale-less-prettier|
llvm..................................|ale-llvm-options|
llc.................................|ale-llvm-llc|
lua...................................|ale-lua-options|

View file

@ -114,3 +114,17 @@ Execute(Append '--parser postcss' for filetype=css):
\ . ' --write',
\ },
\ ale#fixers#prettier#Fix(bufnr(''))
Execute(Append '--parser postcss' for filetype=less):
set filetype=less
call ale#test#SetFilename('../prettier-test-files/testfile.less')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' %t'
\ . ' --parser postcss'
\ . ' --write',
\ },
\ ale#fixers#prettier#Fix(bufnr(''))