summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Buchan-Swanson <david.buchanswanson@gmail.com>2021-02-18 18:33:02 +1100
committerGitHub <noreply@github.com>2021-02-18 16:33:02 +0900
commit1ee7f6c97bb73bb6e12f00e527b664c5ea0df167 (patch)
tree69e70e0a329998492faece429cedee933d31f5a1
parent0b35c3a5b9d5f9d3bb1021d89c1bdb9dbbf8a958 (diff)
downloadale-1ee7f6c97bb73bb6e12f00e527b664c5ea0df167.zip
add support for prettier-ruby to prettier fixer (#3593)
it _does_ need an additional plugin, but when it has the plugin, it works as expected.
-rw-r--r--autoload/ale/fix/registry.vim2
-rw-r--r--autoload/ale/fixers/prettier.vim1
-rw-r--r--doc/ale-ruby.txt5
-rw-r--r--doc/ale-supported-languages-and-tools.txt1
-rw-r--r--doc/ale.txt1
-rw-r--r--supported-tools.md1
-rw-r--r--test/fixers/test_prettier_fixer_callback.vader14
7 files changed, 24 insertions, 1 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 23441ca5..8279fdb4 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -107,7 +107,7 @@ let s:default_registry = {
\ },
\ 'prettier': {
\ 'function': 'ale#fixers#prettier#Fix',
-\ 'suggested_filetypes': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'json5', 'graphql', 'markdown', 'vue', 'html', 'yaml', 'openapi'],
+\ 'suggested_filetypes': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'json5', 'graphql', 'markdown', 'vue', 'html', 'yaml', 'openapi', 'ruby'],
\ 'description': 'Apply prettier to a file.',
\ },
\ 'prettier_eslint': {
diff --git a/autoload/ale/fixers/prettier.vim b/autoload/ale/fixers/prettier.vim
index 12c018af..277f84c4 100644
--- a/autoload/ale/fixers/prettier.vim
+++ b/autoload/ale/fixers/prettier.vim
@@ -85,6 +85,7 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version) abort
\ 'yaml': 'yaml',
\ 'openapi': 'yaml',
\ 'html': 'html',
+ \ 'ruby': 'ruby',
\}
for l:filetype in l:filetypes
diff --git a/doc/ale-ruby.txt b/doc/ale-ruby.txt
index edc6144a..69c643a9 100644
--- a/doc/ale-ruby.txt
+++ b/doc/ale-ruby.txt
@@ -41,6 +41,11 @@ g:ale_ruby_debride_options *g:ale_ruby_debride_options*
This variable can be changed to modify flags given to debride.
+===============================================================================
+prettier *ale-ruby-prettier*
+
+See |ale-javascript-prettier| for information about the available options.
+
===============================================================================
rails_best_practices *ale-ruby-rails_best_practices*
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index 33771e49..cd99aaf4 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -431,6 +431,7 @@ Notes:
* Ruby
* `brakeman`
* `debride`
+ * `prettier`
* `rails_best_practices`!!
* `reek`
* `rubocop`
diff --git a/doc/ale.txt b/doc/ale.txt
index ad73eed2..247228a7 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -2931,6 +2931,7 @@ documented in additional help files.
ruby....................................|ale-ruby-options|
brakeman..............................|ale-ruby-brakeman|
debride...............................|ale-ruby-debride|
+ prettier..............................|ale-ruby-prettier|
rails_best_practices..................|ale-ruby-rails_best_practices|
reek..................................|ale-ruby-reek|
rubocop...............................|ale-ruby-rubocop|
diff --git a/supported-tools.md b/supported-tools.md
index acaad766..1779845d 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -440,6 +440,7 @@ formatting.
* Ruby
* [brakeman](http://brakemanscanner.org/) :floppy_disk:
* [debride](https://github.com/seattlerb/debride) :floppy_disk:
+ * [prettier](https://github.com/prettier/plugin-ruby)
* [rails_best_practices](https://github.com/flyerhzm/rails_best_practices) :floppy_disk:
* [reek](https://github.com/troessner/reek)
* [rubocop](https://github.com/bbatsov/rubocop)
diff --git a/test/fixers/test_prettier_fixer_callback.vader b/test/fixers/test_prettier_fixer_callback.vader
index fdd97df3..b999071f 100644
--- a/test/fixers/test_prettier_fixer_callback.vader
+++ b/test/fixers/test_prettier_fixer_callback.vader
@@ -269,6 +269,20 @@ Execute(Should set --parser based on filetype, HTML):
\ . ' --stdin-filepath %s --stdin',
\ }
+Execute(Should set --parser based on filetype, Ruby):
+ call ale#test#SetFilename('../prettier-test-files/testfile')
+
+ set filetype=ruby
+
+ GivenCommandOutput ['1.6.0']
+ AssertFixer
+ \ {
+ \ 'command': ale#path#CdString(expand('%:p:h'))
+ \ . ale#Escape(g:ale_javascript_prettier_executable)
+ \ . ' --parser ruby'
+ \ . ' --stdin-filepath %s --stdin',
+ \ }
+
Execute(Should set --parser based on first filetype of multiple filetypes):
call ale#test#SetFilename('../prettier-test-files/testfile')