happylinks / gqlint

GraphQL (Schema) Linter
MIT License
41 stars 4 forks source link

Consider modifying ALE integration to use FindExecutable #14

Open oatkiller opened 5 years ago

oatkiller commented 5 years ago

Thanks for making this tool I'm using gqlint with a local installation (in my current JS project) ALE is not able to find the executable, as the ALE integration expects gqlint to be available on the path. Would you consider allowing a change to the ALE integration to use ale#node#FindExecutable Other linters that are installed using npm frequently do this. Here are a few links showing configurations using ale#node#FindExecutable

And here is the relevant source code: https://github.com/w0rp/ale/blob/master/autoload/ale/node.vim#L10

In the mean time, I'm going to try modifying the plugin locally w/ that code to see if it works as I expect. Thanks

oatkiller commented 5 years ago

I tried locally replacing this file: "https://github.com/w0rp/ale/blob/883978ece93bd19250d6d7e8b9659b48f23522e2/ale_linters/graphql/gqlint.vim" w/ the below:

" Author: Michiel Westerbeek <happylinks@gmail.com>
" Description: Linter for GraphQL Schemas

call ale#Set('graphql_gqlint_executable', 'gqlint')
call ale#Set('graphql_gqlint_use_global', get(g:, 'ale_use_global_executables', 0))

function! ale_linters#graphql#gqlint#GetCommand(buffer) abort
    return ale#path#BufferCdString(a:buffer)
    \   . '%e'
    \   . ' --reporter=simple %t'
endfunction

call ale#linter#Define('graphql', {
\   'name': 'gqlint',
\   'executable': {b -> ale#node#FindExecutable(b, 'graphql_gqlint', [
\       'node_modules/.bin/gqlint',
\   ])},
\   'command': function('ale_linters#graphql#gqlint#GetCommand'),
\   'callback': 'ale#handlers#unix#HandleAsWarning',
\})

That worked for my use case

happylinks commented 5 years ago

Hey, thanks for investigating! Feel free to create a PR and I’ll test it and merge it :)

Also, curious what rules you are using with gqlint! Is it working nicely for your project?

aphecetche commented 4 years ago

@oatkiller @happylinks I realize this is an old issue but I'm facing the same one. I'd be ready to make a pull request, but I'm not so sure exactly how/where : to this repo or to ale directly ? How are linters imported into ale repo ? Thanks,

happylinks commented 4 years ago

Probably both repo's, the file in this repo is mostly just to keep track of the latest code in the ale repo. To be honest, I don't use this repo anymore (not using graphql for my current project). But I can merge and test any PRs.

aphecetche commented 4 years ago

ok, just for the record, in the end I won't actually make any PR as I moved from ALE to CoC and so far I'm happy with it. Thanks anyway