Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nvim none-ls] No ESLint configuration found #311

Open
piersolenski opened this issue Aug 13, 2024 · 5 comments
Open

[nvim none-ls] No ESLint configuration found #311

piersolenski opened this issue Aug 13, 2024 · 5 comments

Comments

@piersolenski
Copy link

I've recently switched a project to the new eslint.config.js format. When using eslint, it works perfectly (albeit slow!), when I switch to eslint_d I get the following error:

Error: No ESLint configuration found in /Users/...

I am using the following version

eslint_d: v14.0.3, bundled eslint: v9.8.0

The tickets below suggest that it should be working with this version:

I'm using eslint_d with Neovim and https://github.com/nvimtools/none-ls.nvim. My config looks like this:

-- Diagnostics, code actions, formatting, etc
return {
	"nvimtools/none-ls.nvim",
	lazy = false,
	dependencies = {
		"gbprod/none-ls-shellcheck.nvim",
		"jay-babu/mason-null-ls.nvim",
		"nvimtools/none-ls-extras.nvim",
		"williamboman/mason.nvim",
	},
	config = function()
		local null_ls = require("null-ls")
		local mason_null_ls = require("mason-null-ls")

		local formatting = null_ls.builtins.formatting
		local diagnostics = null_ls.builtins.diagnostics

		-- Helper to conditionally register eslint handlers only if eslint is
		-- config. If eslint is not configured for a project, it just fails.
		local function has_eslint_config(utils)
			return utils.root_has_file({
				".eslintrc",
				".eslintrc.cjs",
				".eslintrc.js",
				".eslintrc.json",
				"eslint.config.cjs",
				"eslint.config.js",
				"eslint.config.mjs",
			})
		end

		null_ls.setup({
			sources = {
				diagnostics.pylint,
				diagnostics.zsh,
				diagnostics.zsh,
				formatting.black,
				formatting.markdownlint,
				formatting.prettierd,
				formatting.shfmt,
				formatting.stylua,
				require("none-ls-shellcheck.code_actions"),
				require("none-ls-shellcheck.diagnostics"),
				require("none-ls.code_actions.eslint_d").with({ condition = has_eslint_config }),
				require("none-ls.diagnostics.eslint_d").with({ condition = has_eslint_config }),
				require("none-ls.formatting.eslint_d").with({ condition = has_eslint_config }),
				require("none-ls.formatting.jq"),
				require("none-ls.formatting.jq"),
			},
		})

		mason_null_ls.setup({
			ensure_installed = nil,
			automatic_installation = true,
			automatic_setup = false,
		})
	end,
}

(When switching eslint_d to eslint in the above config, everything works!)

Thanks for the awesome plugin!

@mantoni
Copy link
Owner

mantoni commented Aug 16, 2024

eslint_d: v14.0.3, bundled eslint: v9.8.0

This means that no local eslint was resolved and it falls back to the bundled version. Is there something wrong with the current working directory?

Also, do you have the same problem on the command line when running eslint_d <some-file>?

@piersolenski
Copy link
Author

It does indeed seem to work with the command line, I guess the problem is coming via my Neovim setup, although it was working before 9, and doesn't include anything crazy?

I've also noticed if I change my eslint config to include an incorrect setting, using eslint via none-ls will offer a suggestion of how to fix it:

Oops! Something went wrong! :(ESLint: 9.9.0Configuration for rule "semi" is invalid. Expected severity of "off", 0, "warn", 1, "error", or 2.You passed '"never"'.See https://eslint.org/docs/latest/use/configure/rules#using-configuration-files for configuring rules. 1:1:14 eslint

eslint_d via none-ls just crashes:

failed to decode json: Expected value but found invalid token at character 1 1:1:3 eslint_d 

For anyone else experiencing issues with Neovim, for now I've switched to the eslint lsp and it seems pretty speedy:

require 'lspconfig'.eslint.setup({
  settings = {
    packageManager = 'yarn'
  },
  on_attach = function(client, bufnr)
    vim.api.nvim_create_autocmd("BufWritePre", {
      buffer = bufnr,
      command = "EslintFixAll",
    })
  end,
})

@mantoni mantoni changed the title No ESLint configuration found [nvim none-ls] No ESLint configuration found Aug 19, 2024
@L2jLiga
Copy link
Contributor

L2jLiga commented Sep 4, 2024

Hi there, could you share your nvim start command and what is cwd?

I'm also using latest eslint_d via none-ls, but without any issues

@piersolenski
Copy link
Author

It was simply nvim and whatever project I was working in.

@L2jLiga
Copy link
Contributor

L2jLiga commented Sep 5, 2024

This is minimal config which is working fine on my end
https://github.com/L2jLiga/nvim-none-ls-eslint_d

Tested with Windows 11 23H2 and Fedora 40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants