1

I'm using ALE for linting my programming code, and I have following configuration part to specify lint tool for JavaScript.

let g:ale_linters = {
\   'javascript': ['eslint'],
\}

let g:ale_fixers = {
\   'javascript': ['eslint'],
\}

It works pretty well if eslint could find there is a .eslintrc or .eslintrc.json under current project directory. However I wonder what if I just want to use Vim to edit an arbitrary JavaScript file, it will pop up a lint error message which says aslant configuration error due to lack of the eslint configuration file.

So I wonder if there is a way to specify a default lint configuration file if there is no eslint configuration file could be found under current project folder.

3

From the eslint documentation we can read

Note: If you have a personal configuration file in your home directory (~/.eslintrc), it will only be used if no other configuration files are found. Since a personal configuration would apply to everything inside of a user’s directory, including third-party code, this could cause problems when running ESLint.

By default, ESLint will look for configuration files in all parent folders up to the root directory. This can be useful if you want all of your projects to follow a certain convention, but can sometimes lead to unexpected results. To limit ESLint to a specific project, place "root": true inside the eslintConfig field of the package.json file or in the .eslintrc.* file at your project’s root level. ESLint will stop looking in parent folders once it finds a configuration with "root": true.

So I didn't test it but you should be able to put a .eslintrc file in your home directory to create a default configuration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.