Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Bartek thindil Jasicki 2021-01-22 17:52:01 +01:00
commit 1ca780a08a
37 changed files with 725 additions and 118 deletions

23
.github/workflows/main.yml vendored Normal file
View File

@ -0,0 +1,23 @@
name: CI
on:
push:
branches: [ master ]
tags:
- /^v\d+\.\d+\.(x|\d+)$/
pull_request:
branches: [ master ]
jobs:
test_ale:
runs-on: ubuntu-latest
strategy:
matrix:
vim-version:
- '--vim-80-only'
- '--vim-81-only'
- '--neovim-only'
- '--linters-only'
steps:
- uses: actions/checkout@v2
- name: Run tests
run: ./run-tests -v ${{ matrix.vim-version }}

View File

@ -1,16 +0,0 @@
---
sudo: required
services:
- docker
language: generic
branches:
only:
- master
- /^v\d+\.\d+\.(x|\d+)$/
env:
- OPTIONS=--vim-80-only
- OPTIONS=--vim-81-only
- OPTIONS=--neovim-only
- OPTIONS=--linters-only
script: |
./run-tests -v $OPTIONS

View File

@ -0,0 +1,29 @@
" Author: Nelson Yeung <nelsyeung@gmail.com>
" Description: Check Dart files with dart analysis server LSP
call ale#Set('dart_analysis_server_executable', 'dart')
function! ale_linters#dart#analysis_server#GetProjectRoot(buffer) abort
" Note: pub only looks for pubspec.yaml, there's no point in adding
" support for pubspec.yml
let l:pubspec = ale#path#FindNearestFile(a:buffer, 'pubspec.yaml')
return !empty(l:pubspec) ? fnamemodify(l:pubspec, ':h:h') : '.'
endfunction
function! ale_linters#dart#analysis_server#GetCommand(buffer) abort
let l:executable = ale#Var(a:buffer, 'dart_analysis_server_executable')
let l:dart = resolve(exepath(l:executable))
return '%e '
\ . fnamemodify(l:dart, ':h') . '/snapshots/analysis_server.dart.snapshot'
\ . ' --lsp'
endfunction
call ale#linter#Define('dart', {
\ 'name': 'analysis_server',
\ 'lsp': 'stdio',
\ 'executable': {b -> ale#Var(b, 'dart_analysis_server_executable')},
\ 'command': function('ale_linters#dart#analysis_server#GetCommand'),
\ 'project_root': function('ale_linters#dart#analysis_server#GetProjectRoot'),
\})

View File

@ -1,26 +1,9 @@
" Author: Daniel Lupu <lupu.daniel.f@gmail.com>
" Description: xo for JavaScript files
call ale#Set('javascript_xo_executable', 'xo')
call ale#Set('javascript_xo_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('javascript_xo_options', '')
function! ale_linters#javascript#xo#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'javascript_xo', [
\ 'node_modules/.bin/xo',
\])
endfunction
function! ale_linters#javascript#xo#GetCommand(buffer) abort
return ale#Escape(ale_linters#javascript#xo#GetExecutable(a:buffer))
\ . ' ' . ale#Var(a:buffer, 'javascript_xo_options')
\ . ' --reporter json --stdin --stdin-filename %s'
endfunction
" xo uses eslint and the output format is the same
call ale#linter#Define('javascript', {
\ 'name': 'xo',
\ 'executable': function('ale_linters#javascript#xo#GetExecutable'),
\ 'command': function('ale_linters#javascript#xo#GetCommand'),
\ 'callback': 'ale#handlers#eslint#HandleJSON',
\ 'executable': function('ale#handlers#xo#GetExecutable'),
\ 'command': function('ale#handlers#xo#GetLintCommand'),
\ 'callback': 'ale#handlers#xo#HandleJSON',
\})

View File

@ -0,0 +1,58 @@
" Author: Horacio Sanson <hsanson@gmail.com>
call ale#Set('openapi_ibm_validator_executable', 'lint-openapi')
call ale#Set('openapi_ibm_validator_options', '')
function! ale_linters#openapi#ibm_validator#GetCommand(buffer) abort
return '%e' . ale#Pad(ale#Var(a:buffer, 'openapi_ibm_validator_options'))
\ . ' %t'
endfunction
function! ale_linters#openapi#ibm_validator#Handle(buffer, lines) abort
let l:output = []
let l:type = 'E'
let l:message = ''
let l:nr = -1
for l:line in a:lines
let l:match = matchlist(l:line, '^errors$')
if !empty(l:match)
let l:type = 'E'
endif
let l:match = matchlist(l:line, '^warnings$')
if !empty(l:match)
let l:type = 'W'
endif
let l:match = matchlist(l:line, '^ *Message : *\(.\+\)$')
if !empty(l:match)
let l:message = l:match[1]
endif
let l:match = matchlist(l:line, '^ *Line *: *\(\d\+\)$')
if !empty(l:match)
let l:nr = l:match[1]
call add(l:output, {
\ 'lnum': l:nr + 0,
\ 'col': 0,
\ 'text': l:message,
\ 'type': l:type,
\})
endif
endfor
return l:output
endfunction
call ale#linter#Define('openapi', {
\ 'name': 'ibm_validator',
\ 'executable': {b -> ale#Var(b, 'openapi_ibm_validator_executable')},
\ 'command': function('ale_linters#openapi#ibm_validator#GetCommand'),
\ 'callback': 'ale_linters#openapi#ibm_validator#Handle',
\})

View File

@ -0,0 +1,9 @@
call ale#Set('yaml_yamllint_executable', 'yamllint')
call ale#Set('yaml_yamllint_options', '')
call ale#linter#Define('openapi', {
\ 'name': 'yamllint',
\ 'executable': {b -> ale#Var(b, 'yaml_yamllint_executable')},
\ 'command': function('ale#handlers#yamllint#GetCommand'),
\ 'callback': 'ale#handlers#yamllint#Handle',
\})

View File

@ -1,23 +1,6 @@
call ale#Set('typescript_xo_executable', 'xo')
call ale#Set('typescript_xo_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('typescript_xo_options', '')
function! ale_linters#typescript#xo#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'typescript_xo', [
\ 'node_modules/.bin/xo',
\])
endfunction
function! ale_linters#typescript#xo#GetCommand(buffer) abort
return ale#Escape(ale_linters#typescript#xo#GetExecutable(a:buffer))
\ . ale#Pad(ale#Var(a:buffer, 'typescript_xo_options'))
\ . ' --reporter json --stdin --stdin-filename %s'
endfunction
" xo uses eslint and the output format is the same
call ale#linter#Define('typescript', {
\ 'name': 'xo',
\ 'executable': function('ale_linters#typescript#xo#GetExecutable'),
\ 'command': function('ale_linters#typescript#xo#GetCommand'),
\ 'callback': 'ale#handlers#eslint#HandleJSON',
\ 'executable': function('ale#handlers#xo#GetExecutable'),
\ 'command': function('ale#handlers#xo#GetLintCommand'),
\ 'callback': 'ale#handlers#xo#HandleJSON',
\})

View File

@ -0,0 +1,66 @@
" Author: Atsuya Takagi <asoftonight@gmail.com>
" Description: A linter for Vala using Vala-Lint.
call ale#Set('vala_vala_lint_config_filename', 'vala-lint.conf')
call ale#Set('vala_vala_lint_executable', 'io.elementary.vala-lint')
function! ale_linters#vala#vala_lint#GetExecutable(buffer) abort
return ale#Var(a:buffer, 'vala_vala_lint_executable')
endfunction
function! ale_linters#vala#vala_lint#GetCommand(buffer) abort
let l:command = ale_linters#vala#vala_lint#GetExecutable(a:buffer)
let l:config_filename = ale#Var(a:buffer, 'vala_vala_lint_config_filename')
let l:config_path = ale#path#FindNearestFile(a:buffer, l:config_filename)
if !empty(l:config_path)
let l:command .= ' -c ' . l:config_path
endif
return l:command . ' %s'
endfunction
function! ale_linters#vala#vala_lint#Handle(buffer, lines) abort
let l:pattern = '^\s*\(\d\+\)\.\(\d\+\)\s\+\(error\|warn\)\s\+\(.\+\)\s\([A-Za-z0-9_\-]\+\)'
let l:output = []
for l:line in a:lines
" remove color escape sequences since vala-lint doesn't support
" output without colors
let l:cleaned_line = substitute(l:line, '\e\[[0-9;]\+[mK]', '', 'g')
let l:match = matchlist(l:cleaned_line, l:pattern)
if len(l:match) == 0
continue
endif
let l:refined_type = l:match[3] is# 'warn' ? 'W' : 'E'
let l:cleaned_text = substitute(l:match[4], '^\s*\(.\{-}\)\s*$', '\1', '')
let l:lnum = l:match[1] + 0
let l:column = l:match[2] + 0
let l:type = l:refined_type
let l:text = l:cleaned_text
let l:code = l:match[5]
call add(l:output, {
\ 'lnum': l:lnum,
\ 'col': l:column,
\ 'text': l:text,
\ 'type': l:type,
\ 'code': l:code,
\})
endfor
return l:output
endfunction
call ale#linter#Define('vala', {
\ 'name': 'vala_lint',
\ 'output_stream': 'stdout',
\ 'executable': function('ale_linters#vala#vala_lint#GetExecutable'),
\ 'command': function('ale_linters#vala#vala_lint#GetCommand'),
\ 'callback': 'ale_linters#vala#vala_lint#Handle',
\ 'lint_file': 1,
\})

View File

@ -3,48 +3,9 @@
call ale#Set('yaml_yamllint_executable', 'yamllint')
call ale#Set('yaml_yamllint_options', '')
function! ale_linters#yaml#yamllint#GetCommand(buffer) abort
return '%e' . ale#Pad(ale#Var(a:buffer, 'yaml_yamllint_options'))
\ . ' -f parsable %t'
endfunction
function! ale_linters#yaml#yamllint#Handle(buffer, lines) abort
" Matches patterns line the following:
" something.yaml:1:1: [warning] missing document start "---" (document-start)
" something.yml:2:1: [error] syntax error: expected the node content, but found '<stream end>'
let l:pattern = '\v^.*:(\d+):(\d+): \[(error|warning)\] (.+)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:item = {
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'text': l:match[4],
\ 'type': l:match[3] is# 'error' ? 'E' : 'W',
\}
let l:code_match = matchlist(l:item.text, '\v^(.+) \(([^)]+)\)$')
if !empty(l:code_match)
if l:code_match[2] is# 'trailing-spaces'
\&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
" Skip warnings for trailing whitespace if the option is off.
continue
endif
let l:item.text = l:code_match[1]
let l:item.code = l:code_match[2]
endif
call add(l:output, l:item)
endfor
return l:output
endfunction
call ale#linter#Define('yaml', {
\ 'name': 'yamllint',
\ 'executable': {b -> ale#Var(b, 'yaml_yamllint_executable')},
\ 'command': function('ale_linters#yaml#yamllint#GetCommand'),
\ 'callback': 'ale_linters#yaml#yamllint#Handle',
\ 'command': function('ale#handlers#yamllint#GetCommand'),
\ 'callback': 'ale#handlers#yamllint#Handle',
\})

View File

@ -102,7 +102,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'],
\ 'suggested_filetypes': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'json5', 'graphql', 'markdown', 'vue', 'html', 'yaml', 'openapi'],
\ 'description': 'Apply prettier to a file.',
\ },
\ 'prettier_eslint': {

View File

@ -83,6 +83,7 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version) abort
\ 'markdown': 'markdown',
\ 'vue': 'vue',
\ 'yaml': 'yaml',
\ 'openapi': 'yaml',
\ 'html': 'html',
\}

View File

@ -1,23 +1,36 @@
" Author: Albert Marquez - https://github.com/a-marquez
" Description: Fixing files with XO.
call ale#Set('javascript_xo_executable', 'xo')
call ale#Set('javascript_xo_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('javascript_xo_options', '')
function! ale#fixers#xo#Fix(buffer) abort
let l:executable = ale#handlers#xo#GetExecutable(a:buffer)
let l:options = ale#handlers#xo#GetOptions(a:buffer)
function! ale#fixers#xo#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'javascript_xo', [
\ 'node_modules/xo/cli.js',
\ 'node_modules/.bin/xo',
\])
return ale#semver#RunWithVersionCheck(
\ a:buffer,
\ l:executable,
\ '%e --version',
\ {b, v -> ale#fixers#xo#ApplyFixForVersion(b, v, l:executable, l:options)}
\)
endfunction
function! ale#fixers#xo#Fix(buffer) abort
let l:executable = ale#fixers#xo#GetExecutable(a:buffer)
function! ale#fixers#xo#ApplyFixForVersion(buffer, version, executable, options) abort
let l:executable = ale#node#Executable(a:buffer, a:executable)
let l:options = ale#Pad(a:options)
" 0.30.0 is the first version with a working --stdin --fix
if ale#semver#GTE(a:version, [0, 30, 0])
return {
\ 'command': l:executable
\ . ' --stdin --stdin-filename %s'
\ . ' --fix'
\ . l:options,
\}
endif
return {
\ 'command': ale#node#Executable(a:buffer, l:executable)
\ . ' --fix %t',
\ 'command': l:executable
\ . ' --fix %t'
\ . l:options,
\ 'read_temporary_file': 1,
\}
endfunction

View File

@ -0,0 +1,44 @@
call ale#Set('javascript_xo_executable', 'xo')
call ale#Set('javascript_xo_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('javascript_xo_options', '')
call ale#Set('typescript_xo_executable', 'xo')
call ale#Set('typescript_xo_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('typescript_xo_options', '')
function! ale#handlers#xo#GetExecutable(buffer) abort
let l:type = ale#handlers#xo#GetType(a:buffer)
return ale#node#FindExecutable(a:buffer, l:type . '_xo', [
\ 'node_modules/xo/cli.js',
\ 'node_modules/.bin/xo',
\])
endfunction
function! ale#handlers#xo#GetLintCommand(buffer) abort
return ale#Escape(ale#handlers#xo#GetExecutable(a:buffer))
\ . ale#Pad(ale#handlers#xo#GetOptions(a:buffer))
\ . ' --reporter json --stdin --stdin-filename %s'
endfunction
function! ale#handlers#xo#GetOptions(buffer) abort
let l:type = ale#handlers#xo#GetType(a:buffer)
return ale#Var(a:buffer, l:type . '_xo_options')
endfunction
" xo uses eslint and the output format is the same
function! ale#handlers#xo#HandleJSON(buffer, lines) abort
return ale#handlers#eslint#HandleJSON(a:buffer, a:lines)
endfunction
function! ale#handlers#xo#GetType(buffer) abort
let l:filetype = getbufvar(a:buffer, '&filetype')
let l:type = 'javascript'
if l:filetype =~# 'typescript'
let l:type = 'typescript'
endif
return l:type
endfunction

View File

@ -0,0 +1,39 @@
function! ale#handlers#yamllint#GetCommand(buffer) abort
return '%e' . ale#Pad(ale#Var(a:buffer, 'yaml_yamllint_options'))
\ . ' -f parsable %t'
endfunction
function! ale#handlers#yamllint#Handle(buffer, lines) abort
" Matches patterns line the following:
" something.yaml:1:1: [warning] missing document start "---" (document-start)
" something.yml:2:1: [error] syntax error: expected the node content, but found '<stream end>'
let l:pattern = '\v^.*:(\d+):(\d+): \[(error|warning)\] (.+)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:item = {
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'text': l:match[4],
\ 'type': l:match[3] is# 'error' ? 'E' : 'W',
\}
let l:code_match = matchlist(l:item.text, '\v^(.+) \(([^)]+)\)$')
if !empty(l:code_match)
if l:code_match[2] is# 'trailing-spaces'
\&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
" Skip warnings for trailing whitespace if the option is off.
continue
endif
let l:item.text = l:code_match[1]
let l:item.code = l:code_match[2]
endif
call add(l:output, l:item)
endfor
return l:output
endfunction

View File

@ -2,6 +2,31 @@
ALE Dart Integration *ale-dart-options*
===============================================================================
analysis_server *ale-dart-analysis_server*
Installation
-------------------------------------------------------------------------------
Install Dart via whatever means. `analysis_server` will be included in the SDK.
In case that `dart` is not in your path, try to set the executable option to
its absolute path. : >
" Set the executable path for dart to the absolute path to it.
let g:ale_dart_analysis_server_executable = '/usr/local/bin/dart'
<
Options
-------------------------------------------------------------------------------
g:ale_dart_analysis_server_executable *g:ale_dart_analysis_server_executable*
*b:ale_dart_analysis_server_executable*
Type: |String|
Default: `'dart'`
This variable can be set to change the path of dart.
===============================================================================
dartanalyzer *ale-dart-dartanalyzer*

74
doc/ale-openapi.txt Normal file
View File

@ -0,0 +1,74 @@
===============================================================================
ALE OpenApi Integration *ale-openapi-options*
===============================================================================
ibm_validator *ale-openapi-ibm-validator*
Website: https://github.com/IBM/openapi-validator
Installation
-------------------------------------------------------------------------------
Install ibm-openapi-validator either globally or locally: >
npm install ibm-openapi-validator -g # global
npm install ibm-openapi-validator # local
<
Configuration
-------------------------------------------------------------------------------
OpenAPI files can be written in YAML or JSON so in order for ALE plugins to
work with these files we must set the buffer |filetype| to either |openapi.yaml|
or |openapi.json| respectively. This causes ALE to lint the file with linters
configured for openapi and yaml files or openapi and json files respectively.
For example setting filetype to |openapi.yaml| on a buffer and the following
|g:ale_linters| configuration will enable linting of openapi files using both
|ibm_validator| and |yamlint|:
>
let g:ale_linters = {
\ 'yaml': ['yamllint'],
\ 'openapi': ['ibm_validator']
\}
<
The following plugin will detect openapi files automatically and set the
filetype to |openapi.yaml| or |openapi.json|:
https://github.com/hsanson/vim-openapi
Options
-------------------------------------------------------------------------------
g:ale_openapi_ibm_validator_executable *g:ale_openapi_ibm_validator_executable*
*b:ale_openapi_ibm_validator_executable*
Type: |String|
Default: `'lint-openapi'`
This variable can be set to change the path to lint-openapi.
g:ale_openapi_ibm_validator_options *g:ale_openapi_ibm_validator_options*
*b:ale_openapi_ibm_validator_options*
Type: |String|
Default: `''`
This variable can be set to pass additional options to lint-openapi.
===============================================================================
prettier *ale-openapi-prettier*
See |ale-javascript-prettier| for information about the available options.
===============================================================================
yamllint *ale-openapi-yamllint*
See |ale-yaml-yamllint| for information about the available options.
===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:

View File

@ -117,6 +117,7 @@ Notes:
* Dafny
* `dafny`!!
* Dart
* `analysis_server`
* `dartanalyzer`!!
* `dartfmt`!!
* `language_server`
@ -323,6 +324,10 @@ Notes:
* `ocamlformat`
* `ocp-indent`
* `ols`
* OpenApi
* `ibm_validator`
* `prettier`
* `yamllint`
* Pawn
* `uncrustify`
* Perl
@ -502,6 +507,7 @@ Notes:
* `typecheck`
* VALA
* `uncrustify`
* `vala_lint`!!
* Verilog
* `hdl-checker`
* `iverilog`

View File

@ -138,5 +138,32 @@ g:ale_typescript_tsserver_use_global *g:ale_typescript_tsserver_use_global*
tsserver in node_modules.
===============================================================================
xo *ale-typescript-xo*
g:ale_typescript_xo_executable *g:ale_typescript_xo_executable*
*b:ale_typescript_xo_executable*
Type: |String|
Default: `'xo'`
See |ale-integrations-local-executables|
g:ale_typescript_xo_options *g:ale_typescript_xo_options*
*b:ale_typescript_xo_options*
Type: |String|
Default: `''`
This variable can be set to pass additional options to xo.
g:ale_typescript_xo_use_global *g:ale_typescript_xo_use_global*
*b:ale_typescript_xo_use_global*
Type: |Number|
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

@ -8,5 +8,26 @@ uncrustify *ale-vala-uncrustify*
See |ale-c-uncrustify| for information about the available options.
===============================================================================
Vala-Lint *ale-vala-vala-lint*
g:vala_vala_lint_executable *g:vala_vala_lint_executable*
*b:vala_vala_lint_executable*
Type: |String|
Default: `'io.elementary.vala-lint'`
This variable can be set to specify a Vala-Lint executable file.
g:vala_vala_lint_config_filename *g:vala_vala_lint_config_filename*
*b:vala_vala_lint_config_filename*
Type: |String|
Default: `'vala-lint.conf'`
This variable can be set to specify a Vala-Lint config filename. When a file
with the specified name was not found or this variable was set to empty,
Vala-Lint will be executed without specifying a config filename.
===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:

View File

@ -2665,6 +2665,7 @@ documented in additional help files.
dafny...................................|ale-dafny-options|
dafny.................................|ale-dafny-dafny|
dart....................................|ale-dart-options|
analysis_server.......................|ale-dart-analysis_server|
dartanalyzer..........................|ale-dart-dartanalyzer|
dartfmt...............................|ale-dart-dartfmt|
dhall...................................|ale-dhall-options|
@ -2836,6 +2837,10 @@ documented in additional help files.
ols...................................|ale-ocaml-ols|
ocamlformat...........................|ale-ocaml-ocamlformat|
ocp-indent............................|ale-ocaml-ocp-indent|
openapi.................................|ale-openapi-options|
ibm_validator.........................|ale-openapi-ibm-validator|
prettier..............................|ale-openapi-prettier|
yamllint..............................|ale-openapi-yamllint|
pawn....................................|ale-pawn-options|
uncrustify............................|ale-pawn-uncrustify|
perl....................................|ale-perl-options|
@ -2994,6 +2999,7 @@ documented in additional help files.
standard..............................|ale-typescript-standard|
tslint................................|ale-typescript-tslint|
tsserver..............................|ale-typescript-tsserver|
xo....................................|ale-typescript-xo|
vala....................................|ale-vala-options|
uncrustify............................|ale-vala-uncrustify|
verilog/systemverilog...................|ale-verilog-options|

View File

@ -126,6 +126,7 @@ formatting.
* Dafny
* [dafny](https://rise4fun.com/Dafny) :floppy_disk:
* Dart
* [analysis_server](https://github.com/dart-lang/sdk/tree/master/pkg/analysis_server)
* [dartanalyzer](https://github.com/dart-lang/sdk/tree/master/pkg/analyzer_cli) :floppy_disk:
* [dartfmt](https://github.com/dart-lang/sdk/tree/master/utils/dartfmt)
* [language_server](https://github.com/natebosch/dart_language_server)
@ -332,6 +333,10 @@ formatting.
* [ocamlformat](https://github.com/ocaml-ppx/ocamlformat)
* [ocp-indent](https://github.com/OCamlPro/ocp-indent)
* [ols](https://github.com/freebroccolo/ocaml-language-server)
* OpenApi
* [ibm_validator](https://github.com/IBM/openapi-validator)
* [prettier](https://github.com/prettier/prettier)
* [yamllint](https://yamllint.readthedocs.io/)
* Pawn
* [uncrustify](https://github.com/uncrustify/uncrustify)
* Perl
@ -511,6 +516,7 @@ formatting.
* typecheck
* VALA
* [uncrustify](https://github.com/uncrustify/uncrustify)
* [vala_lint](https://github.com/vala-lang/vala-lint) :floppy_disk:
* Verilog
* [hdl-checker](https://pypi.org/project/hdl-checker)
* [iverilog](https://github.com/steveicarus/iverilog)

View File

@ -0,0 +1,15 @@
Before:
call ale#assert#SetUpLinterTest('dart', 'analysis_server')
After:
call ale#assert#TearDownLinterTest()
Execute(The default command should be correct):
AssertLinter 'dart', ale#Escape('dart')
\ . ' ./snapshots/analysis_server.dart.snapshot --lsp'
Execute(The executable should be configurable):
let g:ale_dart_analysis_server_executable = 'foobar'
AssertLinter 'foobar', ale#Escape('foobar')
\ . ' ./snapshots/analysis_server.dart.snapshot --lsp'

View File

@ -0,0 +1,15 @@
Before:
call ale#assert#SetUpLinterTest('openapi', 'ibm_validator')
After:
call ale#assert#TearDownLinterTest()
Execute(The yaml ibm-openapi-validator command callback should return the correct default string):
AssertLinter 'lint-openapi', ale#Escape('lint-openapi') . ' %t'
Execute(The yaml ibm-openapi-validator command callback should be configurable):
let g:ale_openapi_ibm_validator_executable = '~/.local/bin/lint-openapi'
let g:ale_openapi_ibm_validator_options = '-c ~/.config'
AssertLinter '~/.local/bin/lint-openapi', ale#Escape('~/.local/bin/lint-openapi')
\ . ' -c ~/.config %t'

View File

@ -1,8 +1,11 @@
Before:
call ale#assert#SetUpLinterTest('typescript', 'xo')
call ale#test#SetFilename('testfile.ts')
call ale#assert#SetUpLinterTest('javascript', 'xo')
call ale#test#SetFilename('testfile.jsx')
unlet! b:executable
set filetype=javascriptreact
runtime autoload/ale/handlers/xo.vim
After:
call ale#assert#TearDownLinterTest()
@ -10,11 +13,11 @@ Execute(The XO executable should be called):
AssertLinter 'xo', ale#Escape('xo') . ' --reporter json --stdin --stdin-filename %s'
Execute(The XO executable should be configurable):
let b:ale_typescript_xo_executable = 'foobar'
let b:ale_javascript_xo_executable = 'foobar'
AssertLinter 'foobar', ale#Escape('foobar') . ' --reporter json --stdin --stdin-filename %s'
Execute(The XO options should be configurable):
let b:ale_typescript_xo_options = '--wat'
let b:ale_javascript_xo_options = '--wat'
AssertLinter 'xo', ale#Escape('xo') . ' --wat --reporter json --stdin --stdin-filename %s'

View File

@ -0,0 +1,23 @@
Before:
call ale#assert#SetUpLinterTest('typescript', 'xo')
call ale#test#SetFilename('testfile.tsx')
unlet! b:executable
set filetype=typescriptreact
runtime autoload/ale/handlers/xo.vim
After:
call ale#assert#TearDownLinterTest()
Execute(The XO executable should be called):
AssertLinter 'xo', ale#Escape('xo') . ' --reporter json --stdin --stdin-filename %s'
Execute(The XO executable should be configurable):
let b:ale_typescript_xo_executable = 'foobar'
AssertLinter 'foobar', ale#Escape('foobar') . ' --reporter json --stdin --stdin-filename %s'
Execute(The XO options should be configurable):
let b:ale_typescript_xo_options = '--wat'
AssertLinter 'xo', ale#Escape('xo') . ' --wat --reporter json --stdin --stdin-filename %s'

View File

View File

@ -0,0 +1,45 @@
Before:
call ale#assert#SetUpFixerTest('javascript', 'xo')
runtime autoload/ale/handlers/xo.vim
set filetype=javascript
After:
call ale#assert#TearDownFixerTest()
Execute(The xo callback should return the correct default values):
call ale#test#SetFilename('../xo-test-files/monorepo/packages/a/index.js')
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'command': (has('win32') ? 'node.exe ' : '')
\ . ale#Escape(ale#path#Simplify(g:dir . '/../xo-test-files/monorepo/node_modules/xo/cli.js'))
\ . ' --fix %t',
\ }
Execute(The xo callback should include custom xo options):
let g:ale_javascript_xo_options = '--space'
call ale#test#SetFilename('../xo-test-files/monorepo/packages/a/index.js')
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'command': (has('win32') ? 'node.exe ' : '')
\ . ale#Escape(ale#path#Simplify(g:dir . '/../xo-test-files/monorepo/node_modules/xo/cli.js'))
\ . ' --fix %t'
\ . ' --space',
\ }
Execute(--stdin should be used when xo is new enough):
let g:ale_javascript_xo_options = '--space'
call ale#test#SetFilename('../xo-test-files/monorepo/packages/a/index.js')
GivenCommandOutput ['0.30.0']
AssertFixer
\ {
\ 'command': (has('win32') ? 'node.exe ' : '')
\ . ale#Escape(ale#path#Simplify(g:dir . '/../xo-test-files/monorepo/node_modules/xo/cli.js'))
\ . ' --stdin --stdin-filename %s'
\ . ' --fix'
\ . ' --space',
\ }

View File

@ -0,0 +1,45 @@
Before:
call ale#assert#SetUpFixerTest('typescript', 'xo')
runtime autoload/ale/handlers/xo.vim
set filetype=typescript
After:
call ale#assert#TearDownFixerTest()
Execute(The xo callback should return the correct default values):
call ale#test#SetFilename('../xo-test-files/monorepo/packages/a/index.ts')
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'command': (has('win32') ? 'node.exe ' : '')
\ . ale#Escape(ale#path#Simplify(g:dir . '/../xo-test-files/monorepo/node_modules/xo/cli.js'))
\ . ' --fix %t',
\ }
Execute(The xo callback should include custom xo options):
let g:ale_typescript_xo_options = '--space'
call ale#test#SetFilename('../xo-test-files/monorepo/packages/a/index.ts')
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'command': (has('win32') ? 'node.exe ' : '')
\ . ale#Escape(ale#path#Simplify(g:dir . '/../xo-test-files/monorepo/node_modules/xo/cli.js'))
\ . ' --fix %t'
\ . ' --space',
\ }
Execute(--stdin should be used when xo is new enough):
let g:ale_typescript_xo_options = '--space'
call ale#test#SetFilename('../xo-test-files/monorepo/packages/a/index.ts')
GivenCommandOutput ['0.30.0']
AssertFixer
\ {
\ 'command': (has('win32') ? 'node.exe ' : '')
\ . ale#Escape(ale#path#Simplify(g:dir . '/../xo-test-files/monorepo/node_modules/xo/cli.js'))
\ . ' --stdin --stdin-filename %s'
\ . ' --fix'
\ . ' --space',
\ }

View File

@ -0,0 +1,49 @@
Before:
runtime! ale_linters/openapi/ibm_validator.vim
After:
call ale#linter#Reset()
Execute(Problems should be parsed correctly for openapi-ibm-validator):
AssertEqual
\ [
\ {
\ 'lnum': 54,
\ 'col': 0,
\ 'type': 'E',
\ 'text': 'Items with a description must have content in it.',
\ },
\ {
\ 'lnum': 24,
\ 'col': 0,
\ 'type': 'W',
\ 'text': 'Operations must have a non-empty `operationId`.',
\ },
\ {
\ 'lnum': 40,
\ 'col': 0,
\ 'type': 'W',
\ 'text': 'operationIds must follow case convention: lower_snake_case',
\ },
\ ],
\ ale_linters#openapi#ibm_validator#Handle(bufnr(''), [
\ '',
\ '[Warning] No .validaterc file found. The validator will run in default mode.',
\ 'To configure the validator, create a .validaterc file.',
\ '',
\ 'errors',
\ '',
\ ' Message : Items with a description must have content in it.',
\ ' Path : paths./settings.patch.description',
\ ' Line : 54',
\ '',
\ 'warnings',
\ '',
\ ' Message : Operations must have a non-empty `operationId`.',
\ ' Path : paths./stats.get.operationId',
\ ' Line : 24',
\ '',
\ ' Message : operationIds must follow case convention: lower_snake_case',
\ ' Path : paths./settings.get.operationId',
\ ' Line : 40'
\ ])

View File

@ -0,0 +1,54 @@
Before:
runtime ale_linters/vala/vala_lint.vim
After:
call ale#linter#Reset()
Execute(The Vala-Lint handler should parse lines correctly):
AssertEqual
\ [
\ {
\ 'lnum': 18,
\ 'col': 18,
\ 'text': 'Expected space before paren',
\ 'code': 'space-before-paren',
\ 'type': 'E',
\ },
\ {
\ 'lnum': 64,
\ 'col': 37,
\ 'text': 'Expected space before paren',
\ 'code': 'space-before-paren',
\ 'type': 'W',
\ },
\ {
\ 'lnum': 73,
\ 'col': 37,
\ 'text': 'Expected space before paren',
\ 'code': 'space-before-paren',
\ 'type': 'E',
\ },
\ ],
\ ale_linters#vala#vala_lint#Handle(bufnr(''), [
\ 'Application.vala',
\ ' 18.18 error Expected space before paren space-before-paren',
\ ' 64.37 warn Expected space before paren space-before-paren',
\ ' 73.37 error Expected space before paren space-before-paren',
\ ])
Execute(The Vala-Lint handler should ignore unknown error types):
AssertEqual
\ [
\ {
\ 'lnum': 73,
\ 'col': 37,
\ 'text': 'Expected space before paren',
\ 'code': 'space-before-paren',
\ 'type': 'E',
\ },
\ ],
\ ale_linters#vala#vala_lint#Handle(bufnr(''), [
\ 'Application.vala',
\ ' 18.18 test Expected space before paren space-before-paren',
\ ' 73.37 error Expected space before paren space-before-paren',
\ ])

View File

@ -3,7 +3,7 @@ Before:
let g:ale_warn_about_trailing_whitespace = 1
runtime! ale_linters/yaml/yamllint.vim
runtime! ale/handlers/yamllint.vim
After:
Restore
@ -29,7 +29,7 @@ Execute(Problems should be parsed correctly for yamllint):
\ 'text': 'syntax error: expected the node content, but found ''<stream end>''',
\ },
\ ],
\ ale_linters#yaml#yamllint#Handle(bufnr(''), [
\ ale#handlers#yamllint#Handle(bufnr(''), [
\ 'something.yaml:1:1: [warning] missing document start "---" (document-start)',
\ 'something.yml:2:1: [error] syntax error: expected the node content, but found ''<stream end>''',
\ ])
@ -45,7 +45,7 @@ Execute(The yamllint handler should respect ale_warn_about_trailing_whitespace):
\ 'code': 'trailing-spaces',
\ },
\ ],
\ ale_linters#yaml#yamllint#Handle(bufnr(''), [
\ ale#handlers#yamllint#Handle(bufnr(''), [
\ 'something.yml:5:18: [error] trailing spaces (trailing-spaces)',
\ ])
@ -54,6 +54,6 @@ Execute(The yamllint handler should respect ale_warn_about_trailing_whitespace):
AssertEqual
\ [
\ ],
\ ale_linters#yaml#yamllint#Handle(bufnr(''), [
\ ale#handlers#yamllint#Handle(bufnr(''), [
\ 'something.yml:5:18: [error] trailing spaces (trailing-spaces)',
\ ])

0
test/xo-test-files/monorepo/node_modules/xo/cli.js generated vendored Normal file
View File

View File