Merge pull request #1192 from fvictorio/add-solhint-support
Add solhint support
This commit is contained in:
commit
c6fc9cdb7b
@ -145,7 +145,7 @@ formatting.
|
|||||||
| Scala | [scalac](http://scala-lang.org), [scalastyle](http://www.scalastyle.org) |
|
| Scala | [scalac](http://scala-lang.org), [scalastyle](http://www.scalastyle.org) |
|
||||||
| Slim | [slim-lint](https://github.com/sds/slim-lint) |
|
| Slim | [slim-lint](https://github.com/sds/slim-lint) |
|
||||||
| SML | [smlnj](http://www.smlnj.org/) |
|
| SML | [smlnj](http://www.smlnj.org/) |
|
||||||
| Solidity | [solium](https://github.com/duaraghav8/Solium) |
|
| Solidity | [solhint](https://github.com/protofire/solhint), [solium](https://github.com/duaraghav8/Solium) |
|
||||||
| Stylus | [stylelint](https://github.com/stylelint/stylelint) |
|
| Stylus | [stylelint](https://github.com/stylelint/stylelint) |
|
||||||
| SQL | [sqlint](https://github.com/purcell/sqlint) |
|
| SQL | [sqlint](https://github.com/purcell/sqlint) |
|
||||||
| Swift | [swiftlint](https://github.com/realm/SwiftLint), [swiftformat](https://github.com/nicklockwood/SwiftFormat) |
|
| Swift | [swiftlint](https://github.com/realm/SwiftLint), [swiftformat](https://github.com/nicklockwood/SwiftFormat) |
|
||||||
|
30
ale_linters/solidity/solhint.vim
Normal file
30
ale_linters/solidity/solhint.vim
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
" Author: Franco Victorio - https://github.com/fvictorio
|
||||||
|
" Description: Report errors in Solidity code with solhint
|
||||||
|
|
||||||
|
function! ale_linters#solidity#solhint#Handle(buffer, lines) abort
|
||||||
|
" Matches patterns like the following:
|
||||||
|
" /path/to/file/file.sol: line 1, col 10, Error - 'addOne' is defined but never used. (no-unused-vars)
|
||||||
|
|
||||||
|
let l:pattern = '\v^[^:]+: line (\d+), col (\d+), (Error|Warning) - (.*) \((.*)\)$'
|
||||||
|
let l:output = []
|
||||||
|
|
||||||
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
|
let l:isError = l:match[3] is? 'error'
|
||||||
|
call add(l:output, {
|
||||||
|
\ 'lnum': l:match[1] + 0,
|
||||||
|
\ 'col': l:match[2] + 0,
|
||||||
|
\ 'text': l:match[4],
|
||||||
|
\ 'code': l:match[5],
|
||||||
|
\ 'type': l:isError ? 'E' : 'W',
|
||||||
|
\})
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return l:output
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call ale#linter#Define('solidity', {
|
||||||
|
\ 'name': 'solhint',
|
||||||
|
\ 'executable': 'solhint',
|
||||||
|
\ 'command': 'solhint --formatter compact %t',
|
||||||
|
\ 'callback': 'ale_linters#solidity#solhint#Handle',
|
||||||
|
\})
|
@ -2,6 +2,14 @@
|
|||||||
ALE Solidity Integration *ale-solidity-options*
|
ALE Solidity Integration *ale-solidity-options*
|
||||||
|
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
solhint *ale-solidity-solhint*
|
||||||
|
|
||||||
|
Solhint should work out-of-the-box. You can further configure it using a
|
||||||
|
`.solihint.json` file. See https://github.com/protofire/solhint for more
|
||||||
|
information.
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
solium *ale-solidity-solium*
|
solium *ale-solidity-solium*
|
||||||
|
|
||||||
|
@ -193,6 +193,7 @@ CONTENTS *ale-contents*
|
|||||||
sml...................................|ale-sml-options|
|
sml...................................|ale-sml-options|
|
||||||
smlnj...............................|ale-sml-smlnj|
|
smlnj...............................|ale-sml-smlnj|
|
||||||
solidity..............................|ale-solidity-options|
|
solidity..............................|ale-solidity-options|
|
||||||
|
solhint.............................|ale-solidity-solhint|
|
||||||
solium..............................|ale-solidity-solium|
|
solium..............................|ale-solidity-solium|
|
||||||
spec..................................|ale-spec-options|
|
spec..................................|ale-spec-options|
|
||||||
rpmlint.............................|ale-spec-rpmlint|
|
rpmlint.............................|ale-spec-rpmlint|
|
||||||
@ -342,7 +343,7 @@ Notes:
|
|||||||
* Scala: `scalac`, `scalastyle`
|
* Scala: `scalac`, `scalastyle`
|
||||||
* Slim: `slim-lint`
|
* Slim: `slim-lint`
|
||||||
* SML: `smlnj`
|
* SML: `smlnj`
|
||||||
* Solidity: `solium`
|
* Solidity: `solhint, solium`
|
||||||
* Stylus: `stylelint`
|
* Stylus: `stylelint`
|
||||||
* SQL: `sqlint`
|
* SQL: `sqlint`
|
||||||
* Swift: `swiftlint`, `swiftformat`
|
* Swift: `swiftlint`, `swiftformat`
|
||||||
|
60
test/handler/test_solhint_handler.vader
Normal file
60
test/handler/test_solhint_handler.vader
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
Before:
|
||||||
|
runtime ale_linters/solidity/solhint.vim
|
||||||
|
|
||||||
|
After:
|
||||||
|
call ale#linter#Reset()
|
||||||
|
|
||||||
|
Execute(The vint handler should parse error messages correctly):
|
||||||
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ {
|
||||||
|
\ 'lnum': 1,
|
||||||
|
\ 'col': 17,
|
||||||
|
\ 'text': 'Compiler version must be fixed',
|
||||||
|
\ 'code': 'compiler-fixed',
|
||||||
|
\ 'type': 'W',
|
||||||
|
\ },
|
||||||
|
\ {
|
||||||
|
\ 'lnum': 4,
|
||||||
|
\ 'col': 8,
|
||||||
|
\ 'text': 'Use double quotes for string literals',
|
||||||
|
\ 'code': 'quotes',
|
||||||
|
\ 'type': 'E',
|
||||||
|
\ },
|
||||||
|
\ {
|
||||||
|
\ 'lnum': 5,
|
||||||
|
\ 'col': 8,
|
||||||
|
\ 'text': 'Use double quotes for string literals',
|
||||||
|
\ 'code': 'quotes',
|
||||||
|
\ 'type': 'E',
|
||||||
|
\ },
|
||||||
|
\ {
|
||||||
|
\ 'lnum': 13,
|
||||||
|
\ 'col': 3,
|
||||||
|
\ 'text': 'Expected indentation of 4 spaces but found 2',
|
||||||
|
\ 'code': 'indent',
|
||||||
|
\ 'type': 'E',
|
||||||
|
\ },
|
||||||
|
\ {
|
||||||
|
\ 'lnum': 14,
|
||||||
|
\ 'col': 3,
|
||||||
|
\ 'text': 'Expected indentation of 4 spaces but found 2',
|
||||||
|
\ 'code': 'indent',
|
||||||
|
\ 'type': 'E',
|
||||||
|
\ },
|
||||||
|
\ {
|
||||||
|
\ 'lnum': 47,
|
||||||
|
\ 'col': 3,
|
||||||
|
\ 'text': 'Function order is incorrect, public function can not go after internal function.',
|
||||||
|
\ 'code': 'func-order',
|
||||||
|
\ 'type': 'E',
|
||||||
|
\ },
|
||||||
|
\ ],
|
||||||
|
\ ale_linters#solidity#solhint#Handle(bufnr(''), [
|
||||||
|
\ 'contracts/Bounty.sol: line 1, col 17, Warning - Compiler version must be fixed (compiler-fixed)',
|
||||||
|
\ 'contracts/Bounty.sol: line 4, col 8, Error - Use double quotes for string literals (quotes)',
|
||||||
|
\ 'contracts/Bounty.sol: line 5, col 8, Error - Use double quotes for string literals (quotes)',
|
||||||
|
\ 'contracts/Bounty.sol: line 13, col 3, Error - Expected indentation of 4 spaces but found 2 (indent)',
|
||||||
|
\ 'contracts/Bounty.sol: line 14, col 3, Error - Expected indentation of 4 spaces but found 2 (indent)',
|
||||||
|
\ 'contracts/Bounty.sol: line 47, col 3, Error - Function order is incorrect, public function can not go after internal function. (func-order)',
|
||||||
|
\ ])
|
Loading…
Reference in New Issue
Block a user