languages: apply workaround for eslint_d errors
Some checks are pending
Set up binary cache / cachix (default) (push) Waiting to run
Set up binary cache / cachix (maximal) (push) Waiting to run
Set up binary cache / cachix (nix) (push) Waiting to run
Validate flake & check formatting / Validate Flake (push) Waiting to run
Validate flake & check formatting / Formatting via Alejandra (push) Waiting to run
Build and deploy documentation / Check latest commit (push) Waiting to run
Build and deploy documentation / publish (push) Blocked by required conditions
Check for typos in the source tree / check-typos (push) Waiting to run

Skip attaching to buffer to get diagnostics if the eslint config is missing.
This commit is contained in:
raf 2025-03-17 11:51:35 +03:00
parent bc978c4fad
commit 02ee4ccb96
No known key found for this signature in database
GPG key ID: 29D95B64378DB4BF
4 changed files with 42 additions and 0 deletions

View file

@ -72,6 +72,17 @@
ls_sources,
null_ls.builtins.diagnostics.eslint_d.with({
command = "${getExe pkg}",
condition = function()
return has_eslint_config({
".eslintrc",
".eslintrc.cjs",
".eslintrc.js",
".eslintrc.json",
"eslint.config.cjs",
"eslint.config.js",
"eslint.config.mjs",
})
end,
})
)
'';

View file

@ -72,6 +72,17 @@
ls_sources,
null_ls.builtins.diagnostics.eslint_d.with({
command = "${getExe pkg}",
condition = function()
return has_eslint_config({
".eslintrc",
".eslintrc.cjs",
".eslintrc.js",
".eslintrc.json",
"eslint.config.cjs",
"eslint.config.js",
"eslint.config.mjs",
})
end,
})
)
'';

View file

@ -123,6 +123,17 @@
ls_sources,
null_ls.builtins.diagnostics.eslint_d.with({
command = "${getExe pkg}",
condition = function()
return has_eslint_config({
".eslintrc",
".eslintrc.cjs",
".eslintrc.js",
".eslintrc.json",
"eslint.config.cjs",
"eslint.config.js",
"eslint.config.mjs",
})
end,
})
)
'';

View file

@ -28,7 +28,16 @@ in {
local null_ls = require("null-ls")
local null_helpers = require("null-ls.helpers")
local null_methods = require("null-ls.methods")
local null_utils = require("null-ls.utils")
local ls_sources = {}
-- HACK: provide an obscure, but useful helper function for some null-ls
-- builtins to start *conditionally* if the plugin can find a config file
-- for the relevant diagnostics service. This should not be provided here
-- haphazardly, but null-ls is candidate for removal anyway.
local function has_eslint_config(files)
return null_utils.root_has_file(files)
end
'';
# null-ls setup