Skip to content

Commit c706824

Browse files
committed
fix(oxlint): don't attempt to find oxlint section in package.json
Problem: The Oxlint LSP configuration checks `package.json` for an "oxlint" section in its `root_dir` function. However, Oxlint has never supported configuration via `package.json`. Solution: Specify ".oxlintrc.json" in a `root_markers` table instead.
1 parent e2bc436 commit c706824

1 file changed

Lines changed: 1 addition & 11 deletions

File tree

lsp/oxlint.lua

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
--- can be used to fix all fixable diagnostics. See the `eslint` config entry for
1919
--- an example of how to use this to automatically fix all errors on write.
2020

21-
local util = require 'lspconfig.util'
22-
2321
local function oxlint_conf_mentions_typescript(root_dir)
2422
local fn = vim.fs.joinpath(root_dir, '.oxlintrc.json')
2523
for line in io.lines(fn) do
@@ -44,6 +42,7 @@ return {
4442
'svelte',
4543
'astro',
4644
},
45+
root_markers = { '.oxlintrc.json' },
4746
workspace_required = true,
4847
on_attach = function(client, bufnr)
4948
vim.api.nvim_buf_create_user_command(bufnr, 'LspOxlintFixAll', function()
@@ -56,15 +55,6 @@ return {
5655
desc = 'Apply Oxlint automatic fixes',
5756
})
5857
end,
59-
root_dir = function(bufnr, on_dir)
60-
local fname = vim.api.nvim_buf_get_name(bufnr)
61-
62-
-- Oxlint resolves configuration by walking upward and using the nearest config file
63-
-- to the file being processed. We therefore compute the root directory by locating
64-
-- the closest `.oxlintrc.json` (or `package.json` fallback) above the buffer.
65-
local root_markers = util.insert_package_json({ '.oxlintrc.json' }, 'oxlint', fname)[1]
66-
on_dir(vim.fs.dirname(vim.fs.find(root_markers, { path = fname, upward = true })[1]))
67-
end,
6858
settings = {
6959
-- run = 'onType',
7060
-- configPath = nil,

0 commit comments

Comments
 (0)