From c96ec574eacfff8ad8dd4bdb6e96a1b3dbd268fd Mon Sep 17 00:00:00 2001 From: Fernando Gómez Date: Thu, 10 Nov 2022 00:49:23 -0600 Subject: 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` --- lua/lspconfig/server_configurations/eslint.lua | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'lua') 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 { -- cgit v1.2.3-70-g09d2