fixes eslint config
This commit is contained in:
parent
0190a1e79a
commit
c853dd6f99
2 changed files with 79 additions and 0 deletions
|
|
@ -11,6 +11,7 @@
|
|||
outputs.nixosModules.macos
|
||||
outputs.nixosModules.homebrew
|
||||
outputs.nixosModules.aerospace
|
||||
outputs.nixosModules.direnv
|
||||
];
|
||||
|
||||
# Device & user-specific settings
|
||||
|
|
|
|||
|
|
@ -36,6 +36,84 @@
|
|||
enable = true;
|
||||
package = pkgs.vscode-langservers-extracted;
|
||||
packageFallback = true;
|
||||
config = {
|
||||
root_markers = [
|
||||
".eslintrc"
|
||||
".eslintrc.js"
|
||||
".eslintrc.cjs"
|
||||
".eslintrc.yaml"
|
||||
".eslintrc.yml"
|
||||
".eslintrc.json"
|
||||
"eslint.config.js"
|
||||
"eslint.config.mjs"
|
||||
"eslint.config.cjs"
|
||||
"eslint.config.ts"
|
||||
"eslint.config.mts"
|
||||
"eslint.config.cts"
|
||||
];
|
||||
before_init = /* lua */ ''
|
||||
function(_, config)
|
||||
local eslint_config_files = {
|
||||
".eslintrc",
|
||||
".eslintrc.js",
|
||||
".eslintrc.cjs",
|
||||
".eslintrc.yaml",
|
||||
".eslintrc.yml",
|
||||
".eslintrc.json",
|
||||
"eslint.config.js",
|
||||
"eslint.config.mjs",
|
||||
"eslint.config.cjs",
|
||||
"eslint.config.ts",
|
||||
"eslint.config.mts",
|
||||
"eslint.config.cts",
|
||||
}
|
||||
-- The "workspaceFolder" is a VSCode concept. It limits how far the
|
||||
-- server will traverse the file system when locating the ESLint config
|
||||
-- file (e.g., .eslintrc).
|
||||
local root_dir = config.root_dir
|
||||
|
||||
if root_dir then
|
||||
config.settings = config.settings or {}
|
||||
config.settings.workspaceFolder = {
|
||||
uri = root_dir,
|
||||
name = vim.fn.fnamemodify(root_dir, ":t"),
|
||||
}
|
||||
|
||||
-- Support flat config files
|
||||
-- They contain 'config' in the file name
|
||||
local flat_config_files = vim.tbl_filter(function(file)
|
||||
return file:match("config")
|
||||
end, eslint_config_files)
|
||||
|
||||
for _, file in ipairs(flat_config_files) do
|
||||
local found_files = vim.fn.globpath(root_dir, file, true, true)
|
||||
|
||||
-- Filter out files inside node_modules
|
||||
local filtered_files = {}
|
||||
for _, found_file in ipairs(found_files) do
|
||||
if string.find(found_file, "[/\\]node_modules[/\\]") == nil then
|
||||
table.insert(filtered_files, found_file)
|
||||
end
|
||||
end
|
||||
|
||||
if #filtered_files > 0 then
|
||||
config.settings.experimental = config.settings.experimental or {}
|
||||
config.settings.experimental.useFlatConfig = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- Support Yarn2 (PnP) projects
|
||||
local pnp_cjs = root_dir .. "/.pnp.cjs"
|
||||
local pnp_js = root_dir .. "/.pnp.js"
|
||||
if vim.uv.fs_stat(pnp_cjs) or vim.uv.fs_stat(pnp_js) then
|
||||
local cmd = config.cmd
|
||||
config.cmd = vim.list_extend({ "yarn", "exec" }, cmd)
|
||||
end
|
||||
end
|
||||
end
|
||||
'';
|
||||
};
|
||||
};
|
||||
biome = {
|
||||
enable = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue