nvim-lint icon indicating copy to clipboard operation
nvim-lint copied to clipboard

how to disable no eslint configuration error?

Open AlejandroSanchez90 opened this issue 1 year ago • 3 comments

Hello, would like to know how can i disable the error when there is no eslint configuration? sometimes i work on apps that dosent havent eslint file, so i get this error on each file that i open this is my config

return {
	"mfussenegger/nvim-lint",
	event = { "BufReadPre", "BufNewFile" },
	config = function()
		local lint = require("lint")

		lint.linters_by_ft = {
			javascript = { "eslint_d" },
			typescript = { "eslint_d" },
			javascriptreact = { "eslint_d" },
			typescriptreact = { "eslint_d" },
			svelte = { "eslint_d" },
			python = { "pylint" },
		}

		local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })

		vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
			group = lint_augroup,
			callback = function()
				lint.try_lint()
			end,
		})

		vim.keymap.set("n", "<leader>l", function()
			lint.try_lint()
		end, { desc = "Trigger linting for current file" })
	end,
}

AlejandroSanchez90 avatar Oct 07 '24 19:10 AlejandroSanchez90

@AlejandroSanchez90 You can try wrapping the try_lint call with pcall. For example:

vim.api.nvim_create_autocmd({ 'BufWritePost' }, {
  callback = function()
    pcall(require, 'lint.try_lint') -- instead of require("lint").try_lint() as docs mention
  end,
 })

In your case, you probably should do pcall(lint, "try_lint") instead of lint.try_lint()

frixaco avatar Oct 08 '24 20:10 frixaco

@frixaco tried but not working

zLinz avatar Oct 10 '24 08:10 zLinz

@frixaco tried but not working

It should work, or you have linting calls somewhere else, pcall is the equivalent of a try catch block

AlejandroSanchez90 avatar Oct 10 '24 10:10 AlejandroSanchez90

See https://github.com/mfussenegger/nvim-lint/issues/685

mfussenegger avatar Oct 24 '24 09:10 mfussenegger