Skip to content

Commit

Permalink
whoops: forgot to validate success and data
Browse files Browse the repository at this point in the history
  • Loading branch information
pavkam authored Oct 14, 2023
1 parent e9a5e2c commit e994602
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions lua/lint/linters/eslint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,24 @@ return require('lint.util').inject_cmd_exe({
local success, data = pcall(vim.json.decode, output)
local diagnostics = {}

for _, item in ipairs(data) do
local current_file = vim.api.nvim_buf_get_name(buffer)
local linted_file = item.filePath

if current_file == linted_file then
for _, diagnostic in ipairs(item.messages or {}) do
table.insert(diagnostics, {
source = "eslint",
lnum = diagnostic.line - 1,
col = diagnostic.column - 1,
end_lnum = diagnostic.endLine - 1,
end_col = diagnostic.endColumn - 1,
severity = severities[diagnostic.severity],
message = diagnostic.message,
code = diagnostic.ruleId
})
if success and data ~= nil then
for _, item in ipairs(data) do
local current_file = vim.api.nvim_buf_get_name(buffer)
local linted_file = item.filePath

if current_file == linted_file then
for _, diagnostic in ipairs(item.messages or {}) do
table.insert(diagnostics, {
source = "eslint",
lnum = diagnostic.line - 1,
col = diagnostic.column - 1,
end_lnum = diagnostic.endLine - 1,
end_col = diagnostic.endColumn - 1,
severity = severities[diagnostic.severity],
message = diagnostic.message,
code = diagnostic.ruleId
})
end
end
end
end
Expand Down

0 comments on commit e994602

Please sign in to comment.