Skip to content

Commit

Permalink
fix(eslint): useFlatConfig is not experimental anymore (#3183)
Browse files Browse the repository at this point in the history
As [Support for the new ESLint flat config files has improved](https://github.com/microsoft/vscode-eslint?tab=readme-ov-file#version-305---pre-release)
  • Loading branch information
saifulapm authored May 30, 2024
1 parent 38de86f commit aa7fe10
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lua/lspconfig/server_configurations/eslint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ return {
validate = 'on',
packageManager = nil,
useESLintClass = false,
experimental = {
useFlatConfig = false,
},
useFlatConfig = false,
codeActionOnSave = {
enable = false,
mode = 'all',
Expand Down Expand Up @@ -119,7 +117,7 @@ return {
or vim.fn.filereadable(new_root_dir .. '/eslint.config.mts') == 1
or vim.fn.filereadable(new_root_dir .. '/eslint.config.cts') == 1
then
config.settings.experimental.useFlatConfig = true
config.settings.useFlatConfig = true
end

-- Support Yarn2 (PnP) projects
Expand Down

6 comments on commit aa7fe10

@akcharlie24
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something broke in eslint after this commit , do check out this thread LazyVim/LazyVim#3383 (comment)

@damianveltkamp
Copy link

@damianveltkamp damianveltkamp commented on aa7fe10 May 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After updating nvim-lspconfig to this commit I am getting errors regarding useFlatConfig, seem like this is also already mentioned in Lazy nvim
image

@akcharlie24
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After updating nvim-lspconfig to this commit I am getting errors regarding useFlatConfig, seem like this is also already mentioned in Lazy nvim image

Refer to the link i mentioned, it states u need to downgrade your eslint to 4.5.0
Running :MasonInstall this will help

@damianveltkamp
Copy link

@damianveltkamp damianveltkamp commented on aa7fe10 May 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Downgrading eslint-lsp to 4.5.0 indeed removes this error, however I am no longer getting any diagnostics from eslint and EslintFixAll no longer works.

@kesor
Copy link
Contributor

@kesor kesor commented on aa7fe10 May 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The VSCode ESLint Language Server is throwing an exception because it can no longer find .experimental
https://github.com/microsoft/vscode-eslint/blob/main/server/src/eslint.ts#L912-L922

This "fix" must be rolled back at least until the most commonly used server for eslint is fixed.

(burned two days of my life)

A workaround for this right now, for those who find this PR, would be something like this snippet. Everyone else who upgraded lspconfig is just going to suffer.

  lspconfig.eslint.setup({
    // ...
    settings = {
      useFlatConfig = true,
      experimental = {
        useFlatConfig = true,
      }
    }
  })

@stove-jeebs
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still no fix?

Please sign in to comment.