-
-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Revert "Fix parsing regression in eslint(d) (#416)" This reverts commit 7ac6307. * Revert "Add end_col to results of eslint/eslintd (#409)" This reverts commit 001eb1e.
- Loading branch information
1 parent
7ac6307
commit 749e895
Showing
3 changed files
with
39 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,27 @@ | ||
local severities = { | ||
vim.diagnostic.severity.WARN, | ||
vim.diagnostic.severity.ERROR, | ||
local pattern = [[%s*(%d+):(%d+)%s+(%w+)%s+(.+%S)%s+(%S+)]] | ||
local groups = { 'lnum', 'col', 'severity', 'message', 'code' } | ||
local severity_map = { | ||
['error'] = vim.diagnostic.severity.ERROR, | ||
['warn'] = vim.diagnostic.severity.WARN, | ||
['warning'] = vim.diagnostic.severity.WARN, | ||
} | ||
|
||
return require('lint.util').inject_cmd_exe({ | ||
cmd = function() | ||
local local_eslint = vim.fn.fnamemodify('./node_modules/.bin/eslint', ':p') | ||
local stat = vim.loop.fs_stat(local_eslint) | ||
|
||
if stat then | ||
return local_eslint | ||
end | ||
|
||
return 'eslint' | ||
end, | ||
args = { | ||
'--format', | ||
'json', | ||
'--stdin', | ||
'--stdin-filename', | ||
function() return vim.api.nvim_buf_get_name(0) end, | ||
}, | ||
stdin = true, | ||
stream = 'stdout', | ||
ignore_exitcode = true, | ||
parser = function(output) | ||
local success, decodedData = pcall( | ||
vim.json.decode, output, | ||
{ luanil = { object = true, array = true } } | ||
) | ||
local messages = decodedData and decodedData[1] and decodedData[1].messages or {} | ||
|
||
local diagnostics = {} | ||
if success and #messages > 0 then | ||
for _, diagnostic in ipairs(messages or {}) do | ||
table.insert(diagnostics, { | ||
source = "eslint", | ||
lnum = diagnostic.line - 1, | ||
col = diagnostic.column - 1, | ||
end_lnum = (diagnostic.endLine or diagnostic.line) - 1, | ||
end_col = (diagnostic.endColumn or diagnostic.column) - 1, | ||
severity = severities[diagnostic.severity], | ||
message = diagnostic.message, | ||
code = diagnostic.ruleId | ||
}) | ||
end | ||
end | ||
|
||
return diagnostics | ||
end | ||
parser = require('lint.parser').from_pattern(pattern, groups, severity_map, { ['source'] = 'eslint' }), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,27 @@ | ||
local severities = { | ||
vim.diagnostic.severity.WARN, | ||
vim.diagnostic.severity.ERROR, | ||
local pattern = [[%s*(%d+):(%d+)%s+(%w+)%s+(.+%S)%s+(%S+)]] | ||
local groups = { 'lnum', 'col', 'severity', 'message', 'code' } | ||
local severity_map = { | ||
['error'] = vim.diagnostic.severity.ERROR, | ||
['warn'] = vim.diagnostic.severity.WARN, | ||
['warning'] = vim.diagnostic.severity.WARN, | ||
} | ||
|
||
return require('lint.util').inject_cmd_exe({ | ||
cmd = function() | ||
local local_eslint_d = vim.fn.fnamemodify('./node_modules/.bin/eslint_d', ':p') | ||
local stat = vim.loop.fs_stat(local_eslint_d) | ||
|
||
local local_eslintd = vim.fn.fnamemodify('./node_modules/.bin/eslint_d', ':p') | ||
local stat = vim.loop.fs_stat(local_eslintd) | ||
if stat then | ||
return local_eslint_d | ||
return local_eslintd | ||
end | ||
|
||
return 'eslint_d' | ||
end, | ||
args = { | ||
'--format', | ||
'json', | ||
'--stdin', | ||
'--stdin-filename', | ||
function() return vim.api.nvim_buf_get_name(0) end, | ||
}, | ||
stdin = true, | ||
stream = 'stdout', | ||
ignore_exitcode = true, | ||
parser = function(output) | ||
local success, decodedData = pcall( | ||
vim.json.decode, output, | ||
{ luanil = { object = true, array = true } } | ||
) | ||
local messages = decodedData and decodedData[1] and decodedData[1].messages or {} | ||
|
||
local diagnostics = {} | ||
if success and #messages > 0 then | ||
for _, diagnostic in ipairs(messages or {}) do | ||
table.insert(diagnostics, { | ||
source = "eslint_d", | ||
lnum = diagnostic.line - 1, | ||
col = diagnostic.column - 1, | ||
end_lnum = (diagnostic.endLine or diagnostic.line) - 1, | ||
end_col = (diagnostic.endColumn or diagnostic.column) - 1, | ||
severity = severities[diagnostic.severity], | ||
message = diagnostic.message, | ||
code = diagnostic.ruleId | ||
}) | ||
end | ||
end | ||
|
||
return diagnostics | ||
end | ||
parser = require('lint.parser').from_pattern(pattern, groups, severity_map, { ['source'] = 'eslint_d' }), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters