fix wordpress linter/formatter mismatch
This commit is contained in:
parent
6db3669bdb
commit
a0926e273e
|
|
@ -59,15 +59,20 @@ return {
|
||||||
command = find_executable({ "phpcbf" }),
|
command = find_executable({ "phpcbf" }),
|
||||||
prefer_local = "vendor/bin",
|
prefer_local = "vendor/bin",
|
||||||
-- Respects phpcs.xml in project root or uses WordPress standard
|
-- Respects phpcs.xml in project root or uses WordPress standard
|
||||||
extra_args = function()
|
extra_args = function(params)
|
||||||
local phpcs_xml = vim.fn.findfile("phpcs.xml", ".;")
|
local root = params.root or vim.fn.getcwd()
|
||||||
if phpcs_xml == "" then
|
|
||||||
phpcs_xml = vim.fn.findfile("phpcs.xml.dist", ".;")
|
-- 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
|
end
|
||||||
if phpcs_xml == "" then
|
|
||||||
return { "--standard=WordPress" }
|
-- No project ruleset: use WordPress to match nvim-lint
|
||||||
end
|
return { "--standard=WordPress" }
|
||||||
return {}
|
|
||||||
end,
|
end,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,21 +47,21 @@ return {
|
||||||
|
|
||||||
-- Configure phpcs for WordPress standards
|
-- Configure phpcs for WordPress standards
|
||||||
lint.linters.phpcs.cmd = find_executable({ "phpcs" }) or "phpcs"
|
lint.linters.phpcs.cmd = find_executable({ "phpcs" }) or "phpcs"
|
||||||
lint.linters.phpcs.args = {
|
|
||||||
"-q",
|
-- Build args dynamically based on project ruleset presence
|
||||||
"--report=json",
|
-- Note: This runs once at config load, checks cwd for phpcs.xml
|
||||||
function()
|
local cwd = vim.fn.getcwd()
|
||||||
local phpcs_xml = vim.fn.findfile("phpcs.xml", ".;")
|
local has_project_ruleset =
|
||||||
if phpcs_xml == "" then
|
vim.loop.fs_stat(cwd .. "/phpcs.xml")
|
||||||
phpcs_xml = vim.fn.findfile("phpcs.xml.dist", ".;")
|
or vim.loop.fs_stat(cwd .. "/phpcs.xml.dist")
|
||||||
end
|
|
||||||
if phpcs_xml == "" then
|
local phpcs_args = { "-q", "--report=json" }
|
||||||
return "--standard=WordPress"
|
if not has_project_ruleset then
|
||||||
end
|
table.insert(phpcs_args, "--standard=WordPress")
|
||||||
return nil
|
end
|
||||||
end,
|
table.insert(phpcs_args, "-") -- stdin
|
||||||
"-", -- stdin
|
|
||||||
}
|
lint.linters.phpcs.args = phpcs_args
|
||||||
|
|
||||||
-- Configure eslint_d to use project-local first
|
-- Configure eslint_d to use project-local first
|
||||||
lint.linters.eslint_d.cmd = find_executable({ "eslint_d", "eslint" }) or "eslint_d"
|
lint.linters.eslint_d.cmd = find_executable({ "eslint_d", "eslint" }) or "eslint_d"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue