diff options
| author | Fernando Gómez <gomezhyuuga@gmail.com> | 2022-11-10 00:49:23 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-10 14:49:23 +0800 |
| commit | c96ec574eacfff8ad8dd4bdb6e96a1b3dbd268fd (patch) | |
| tree | 4a0fb8feb0dc69c0c17da4b4404b7975ecdda1d3 /lua | |
| parent | docs: update server_configurations.md (diff) | |
| download | nvim-lspconfig-c96ec574eacfff8ad8dd4bdb6e96a1b3dbd268fd.tar nvim-lspconfig-c96ec574eacfff8ad8dd4bdb6e96a1b3dbd268fd.tar.gz nvim-lspconfig-c96ec574eacfff8ad8dd4bdb6e96a1b3dbd268fd.tar.bz2 nvim-lspconfig-c96ec574eacfff8ad8dd4bdb6e96a1b3dbd268fd.tar.lz nvim-lspconfig-c96ec574eacfff8ad8dd4bdb6e96a1b3dbd268fd.tar.xz nvim-lspconfig-c96ec574eacfff8ad8dd4bdb6e96a1b3dbd268fd.tar.zst nvim-lspconfig-c96ec574eacfff8ad8dd4bdb6e96a1b3dbd268fd.zip | |
fix(eslint): root dir not found if using package.json config (#2234)
ESLint server would not find root directory when config is set in
`package.json`
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/lspconfig/server_configurations/eslint.lua | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/lua/lspconfig/server_configurations/eslint.lua b/lua/lspconfig/server_configurations/eslint.lua index 6ebe65ee..feb82c63 100644 --- a/lua/lspconfig/server_configurations/eslint.lua +++ b/lua/lspconfig/server_configurations/eslint.lua @@ -48,25 +48,19 @@ local root_file = { '.eslintrc.yml', '.eslintrc.json', 'eslint.config.js', - 'package.json', } local root_with_package = util.find_package_json_ancestor(vim.fn.expand '%:p:h') if root_with_package then - local must_remove = false + -- only add package.json if it contains eslintConfig field local path_sep = is_windows and '\\' or '/' for line in io.lines(root_with_package .. path_sep .. 'package.json') do if line:find 'eslintConfig' then - must_remove = false - else - must_remove = true + table.insert(root_file, 'package.json') + break end end - - if must_remove then - table.remove(root_file, #root_file) - end end return { |
