LSP: ESLint language server does not find root .eslintrc.js file

I have a react monorepo project with a number of aliases (typescript paths) setup which makes importing files easier without the need to use relative paths everywhere.

For example if I have a component in src/components/Sidebar/Toggle.jsx and I want to import that anywhere in the application I can just do import {Toggle} from '@company/components/Sidebar/Toggle' and there’s no need to do any relative path importing like ../../../Toggle.

Company is just an example alias to the src directory setup in tsconfig.json like:

"paths": {
   "@company/*": ["./src/*"]

This works fine in vscode but in neovim (I’m using nvim-lspconfig with eslint) all exported functions which are imported using the alias have a warning

Exported declaration not used within other modules

even though they are.

If I import them using relative paths it works without warning.

Does anyone have a suggestion as what config I need to change so that neovim can see that these functions are in fact used in other files?

I’ve tried adding config in .eslintrc.json like this as suggested by eslint-import-resolver-typescript - npm but this did not solve it.

settings: {
   'import/resolver': {
      typescript: {
         project: ['packages/*/tsconfig.json'],

I should also note that running eslint directly on the file with my current configuration works fine with no errors so this is somehow related to the neovim plugin

After debugging some more I can see that the language server picks up the first .eslintrc.js that it sees (which is in the current directory) and sets that as the root directory. The issues is that this is not the main .eslintrc.js because this lives higher up in the directory tree

1 Like