add spectral support for json

This commit is contained in:
tatsuya 2021-01-06 13:25:52 +09:00
parent 997dd7f8fe
commit 66b3e768db
5 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,14 @@
" Author: t2h5 <https://github.com/t2h5>
" Description: Integration of Stoplight Spectral CLI with ALE.
call ale#Set('json_spectral_executable', 'spectral')
call ale#Set('json_spectral_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#linter#Define('json', {
\ 'name': 'spectral',
\ 'executable': {b -> ale#node#FindExecutable(b, 'json_spectral', [
\ 'node_modules/.bin/spectral',
\ ])},
\ 'command': '%e lint --ignore-unknown-format -q -f text %t',
\ 'callback': 'ale#handlers#spectral#HandleSpectralOutput'
\})

View File

@ -101,5 +101,37 @@ prettier *ale-json-prettier*
See |ale-javascript-prettier| for information about the available options.
===============================================================================
spectral *ale-json-spectral*
Website: https://github.com/stoplightio/spectral
Installation
-------------------------------------------------------------------------------
Install spectral either globally or locally: >
npm install @stoplight/spectral -g # global
npm install @stoplight/spectral # local
<
Options
-------------------------------------------------------------------------------
g:ale_json_spectral_executable *g:ale_json_spectral_executable*
*b:ale_json_spectral_executable*
Type: |String|
Default: `'spectral'`
This variable can be set to change the path to spectral.
g:ale_json_spectral_use_global *g:ale_json_spectral_use_global*
*b:ale_json_spectral_use_global*
Type: |String|
Default: `get(g:, 'ale_use_global_executables', 0)`
See |ale-integrations-local-executables|
===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:

View File

@ -248,6 +248,7 @@ Notes:
* `jq`
* `jsonlint`
* `prettier`
* `spectral`
* Julia
* `languageserver`
* Kotlin

View File

@ -2785,6 +2785,7 @@ documented in additional help files.
jsonlint..............................|ale-json-jsonlint|
jq....................................|ale-json-jq|
prettier..............................|ale-json-prettier|
spectral..............................|ale-json-spectral|
julia...................................|ale-julia-options|
languageserver........................|ale-julia-languageserver|
kotlin..................................|ale-kotlin-options|

View File

@ -257,6 +257,7 @@ formatting.
* [jq](https://stedolan.github.io/jq/)
* [jsonlint](http://zaa.ch/jsonlint/)
* [prettier](https://github.com/prettier/prettier)
* [spectral](https://github.com/stoplightio/spectral)
* Julia
* [languageserver](https://github.com/JuliaEditorSupport/LanguageServer.jl)
* Kotlin