jose-elias-alvarez / nvim-lsp-ts-utils

Utilities to improve the TypeScript development experience for Neovim's built-in LSP client.
The Unlicense
438 stars 18 forks source link

[FEATURE REQUEST] Disable ESLint if no config file found #57

Closed roginfarrer closed 3 years ago

roginfarrer commented 3 years ago

Issues

Feature description

I move between projects that use ESLint and those that don't. For the repos that don't, I never want ESLint to run since that project doesn't have a config. And because there isn't a config, I get extraneous errors like The keyword 'import' is reserved.

I think there should be some way to check if a config file exists in the project (using package.json or .git/ as a project root), and if not, disable ESLint. But I'm not sure how to go about that.

Help

Yes, but I don't know how to start. I would need guidance

Implementation help

No response

jose-elias-alvarez commented 3 years ago

This is definitely possible to implement, and in fact the plugin already checks to see if an ESLint config file exists at the project root. I originally wanted to make this the default behavior, but what stopped me is that ESLint configuration can live inside package.json, and since that can be a large file, parsing it to check if it has the right config key seemed aggressive. It might also have some issues in monorepos, from what I understand.

Still, I can implement this as an opt-in setting if that makes sense to you.

roginfarrer commented 3 years ago

Ya opt-in makes sense to me, especially if it adds any runtime overhead. In my experience for monorepos, every package needs to have its own eslint config, so maybe that makes this simpler (at least this is what I experience with work).

Thanks for this package! It's a must have for anyone working with JS/TS

jose-elias-alvarez commented 3 years ago

Thank you for the kind words! I added this option in 81573beadcf4a916d5ac5907742318531f4bf50c as eslint_disable_if_no_config. Let me know if that works for you.

jose-elias-alvarez commented 3 years ago

Update: 02ea3e319fb4894ed974b4ddf001417f1e25c4db removes the option but allows setting up the requested behavior via eslint_opts, as described in #65.