Open kourylape opened 10 months ago
I believe the issue is with stdin and lua/lint/linters/phpcs.lua. I can create a PR, but not sure if I'm heading down the right path.
I was able to match the functionality between running phpcs locally and using the linter in nvim.
I made the following changes to phpcs.lua
.
parser = function(output, bufnr)
-- other unmodified code
local filename = vim.fn.fnamemodify(vim.fn.bufname(bufnr), ":p")
local files = decoded["files"]
local messages = {}
if files["STDIN"] == nil then
if files[filename] == nil then
return {}
end
messages = files[filename]["messages"]
else
messages = files["STDIN"]["messages"]
end
-- other unmodified code
end,
And customized the linter in my config to be:
local lint = require("lint")
-- PHP
local phpcs = lint.linters.phpcs
phpcs.cmd = "vendor/bin/phpcs"
phpcs.stdin = false
phpcs.args = {
"--report=json",
"-q",
}
This does work, but is this something worth submitting?
I'm new to nvim-lint and php is not my primary language, but I noticed an inconsistency between running phpcs locally versus inside neovim.
.phpcs.xml
plugins.lua
plugins/linter.lua
Scenario 1: Inside neovim
When running
:lua require('lint').try_lint()
onapp/test.php
, I see WordPress related errors.When running
:lua require('lint').try_lint()
onblog/wp-config.php
, I see PSR12 related errors.Scenario 2: Running phpcs
When running
vendor/bin/phpcs app/test.php
, I see only PSR12 related errors.When running
vendor/bin/phpcs blog/wp-config.php
, I only see WordPress related errors.