vim-syntastic / syntastic

Syntax checking hacks for vim
Do What The F*ck You Want To Public License
11.3k stars 1.14k forks source link

Choose checker(s) for file by conditions of file's path (ie git repo it belongs to) #2339

Closed darcyparker closed 3 years ago

darcyparker commented 3 years ago

As an example, many repos with javascript and typescript use different linters. But it is not intended to use all possible linters.

Today I can do something like:

let g:syntastic_javascript_checkers=['xo', 'eslint']

and it runs each of the checkers listed. But the problem is that I get errors from eslint that do not apply to projects configured with xo and vice versa...

Projects that use xo have configuration files such as .xo-config.json, .xo-config.js or xo.config.js, or xo property in package.json. In this case, I only want to use xo and NOT eslint (unless for some reason there was an eslint configuration file in the root dir of repo). (Yes xo is based on eslint, but it hides the configuration... and if you run eslint it does not find its configuration results and you get inappropriate validation errors.)

Similarly, projects with eslint configuration files I want to use eslint.

I'd like to configure checkers using:

Perhaps this can be done already today, and I just need a pointer to some documentation/examples? If not, it would be great if the option could be something like (I am open to other ideas too...):

let g:syntastic_javascript_checkersLookup=['lookupCheckersScript.sh']
darcyparker commented 3 years ago

I know there is a related pattern of using

let g:syntastic_javascript_eslint_exec = 'eslintLocal.sh'

to choose which eslint executable to use... and there is also plugins like https://github.com/jaawerth/nrun.vim

The solution I am looking for is similar, but doesn't just choose the executable, but the list of checkers to use based on the script.

lcd047 commented 3 years ago

I take it this is a feature request. Now, syntastic is a framework for linting. Changing variables / settings / whatever based on repository is an exercise in general Vim scripting (f.i. you can achieve this with a single autocmd). If you can think of a nice user interface for it, it might make an interesting idea for a separate plugin. But as it is it has nothing to do with syntastic or its scope, sorry.

darcyparker commented 3 years ago

@lcd047 - Yes it was a feature request. Thanks for the suggestion of trying this with a single autocmd; that helps and I think I can figure that out.