fix wordpress linter/formatter mismatch

This commit is contained in:
Ray Elliott 2026-01-05 22:10:39 +00:00
commit a0926e273e
2 changed files with 28 additions and 23 deletions

View file

@ -59,15 +59,20 @@ return {
command = find_executable({ "phpcbf" }),
prefer_local = "vendor/bin",
-- Respects phpcs.xml in project root or uses WordPress standard
extra_args = function()
local phpcs_xml = vim.fn.findfile("phpcs.xml", ".;")
if phpcs_xml == "" then
phpcs_xml = vim.fn.findfile("phpcs.xml.dist", ".;")
extra_args = function(params)
local root = params.root or vim.fn.getcwd()
-- Check for project ruleset
local has_project_ruleset =
vim.loop.fs_stat(root .. "/phpcs.xml")
or vim.loop.fs_stat(root .. "/phpcs.xml.dist")
if has_project_ruleset then
return {} -- Let project ruleset control standard
end
if phpcs_xml == "" then
return { "--standard=WordPress" }
end
return {}
-- No project ruleset: use WordPress to match nvim-lint
return { "--standard=WordPress" }
end,
}),