how to disable no eslint configuration error?
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 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 tried but not working
@frixaco tried but not working
It should work, or you have linting calls somewhere else, pcall is the equivalent of a try catch block
See https://github.com/mfussenegger/nvim-lint/issues/685