Support for Zlint as Zig linter (#4923)

* feat: Add Zig zlint linter and handler for ALE
* docs: Add zlint documentation to ALE Zig integration guide
* docs: Updating docs for zlint support
* tests: Adding tests for checking zlint executable and command
* refactor: Move zlint configuration test to separate test file
This commit is contained in:
Enrique Miguel Mora Meza
2025-03-18 16:30:05 +04:00
committed by GitHub
parent c4cedeea3f
commit 59c996c5b8
7 changed files with 114 additions and 1 deletions

View File

@@ -0,0 +1,44 @@
Before:
runtime ale_linters/zig/zlint.vim
After:
call ale#linter#Reset()
Execute(The zlint handler should parse GitHub Actions format correctly):
" Create a temporary buffer
let buffer = bufnr('')
" Define input lines
let input_lines = [
\ '::warning file=test.zig,line=61,col=47,title=unsafe-undefined::`undefined` is missing a safety comment',
\ '',
\ '::error file=test2.zig,line=4,col=33,title=no-unresolved::Unresolved import to ''test3.zig''',
\ '',
\ ]
" Define expected output
let expected_output = [
\ {
\ 'filename': 'test.zig',
\ 'lnum': 61,
\ 'col': 47,
\ 'text': '`undefined` is missing a safety comment',
\ 'type': 'W',
\ 'code': 'unsafe-undefined'
\ },
\ {
\ 'filename': 'test2.zig',
\ 'lnum': 4,
\ 'col': 33,
\ 'text': 'Unresolved import to ''test3.zig''',
\ 'type': 'E',
\ 'code': 'no-unresolved'
\ },
\ ]
" Get actual output
let actual_output = ale_linters#zig#zlint#Handle(buffer, input_lines)
" Assert equality
AssertEqual expected_output, actual_output

View File

@@ -0,0 +1,19 @@
Before:
call ale#assert#SetUpLinterTest('zig', 'zlint')
After:
call ale#assert#TearDownLinterTest()
Execute(The zlint executable and command should be configured correctly):
" Set a custom executable path
let g:ale_zig_zlint_executable = '/custom/path/to/zlint'
" Create a buffer with Zig filetype
call ale#test#SetFilename('test.zig')
" Check the executable
AssertEqual '/custom/path/to/zlint', ale#Var(bufnr(''), 'zig_zlint_executable')
" Check the command
let cmd = ale_linters#zig#zlint#GetCommand(bufnr(''))
AssertEqual ale#Escape('/custom/path/to/zlint') . ' %s -f gh', cmd