Skip to content

Commit e322fbb

Browse files
committed
chore: remove diagnostic suppressions after tidying nits
1 parent 9d27c9e commit e322fbb

File tree

8 files changed

+24
-40
lines changed

8 files changed

+24
-40
lines changed

Diff for: .luarc.json

-9
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,6 @@
44
"diagnostics": {
55
"globals": [
66
"vim"
7-
],
8-
"disable": [
9-
"cast-local-type",
10-
"lowercase-global",
11-
"missing-parameter",
12-
"missing-return",
13-
"missing-return-value",
14-
"need-check-nil",
15-
"param-type-mismatch"
167
]
178
}
189
}

Diff for: lua/nvim-tree/actions/reloaders/reloaders.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ function M.reload_node_status(parent_node, projects)
3030
end
3131

3232
local event_running = false
33-
---@param _ table unused node passed by action
34-
---@param unloaded_bufnr number optional bufnr recently unloaded via BufUnload event
33+
---@param _ table|nil unused node passed by action
34+
---@param unloaded_bufnr number|nil optional bufnr recently unloaded via BufUnload event
3535
function M.reload_explorer(_, unloaded_bufnr)
3636
if event_running or not core.get_explorer() or vim.v.exiting ~= vim.NIL then
3737
return

Diff for: lua/nvim-tree/explorer/filters.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ local function custom(path)
9191
end
9292

9393
---Prepare arguments for should_filter. This is done prior to should_filter for efficiency reasons.
94-
---@param git_status table results of git.load_project_status(...)
95-
---@param unloaded_bufnr number optional bufnr recently unloaded via BufUnload event
94+
---@param git_status table|nil optional results of git.load_project_status(...)
95+
---@param unloaded_bufnr number|nil optional bufnr recently unloaded via BufUnload event
9696
---@return table
9797
--- git_status: reference
9898
--- unloaded_bufnr: copy

Diff for: lua/nvim-tree/git/runner.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function Runner:_handle_incoming_data(prev_output, incoming)
4545
self._parse_status_output(line)
4646
end
4747

48-
return nil
48+
return ""
4949
end
5050

5151
function Runner:_getopts(stdout_handle, stderr_handle)

Diff for: lua/nvim-tree/legacy.lua

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ local function refactored(opts)
1414
end
1515

1616
-- 2022/06/20
17-
utils.move_missing_val(opts, "update_focused_file", "update_cwd", opts, "update_focused_file", "update_root")
18-
utils.move_missing_val(opts, "", "update_cwd", opts, "", "sync_root_with_cwd")
17+
utils.move_missing_val(opts, "update_focused_file", "update_cwd", opts, "update_focused_file", "update_root", true)
18+
utils.move_missing_val(opts, "", "update_cwd", opts, "", "sync_root_with_cwd", true)
1919

2020
-- 2022/11/07
2121
utils.move_missing_val(opts, "", "open_on_tab", opts, "tab.sync", "open", false)
22-
utils.move_missing_val(opts, "", "open_on_tab", opts, "tab.sync", "close")
23-
utils.move_missing_val(opts, "", "ignore_buf_on_tab_change", opts, "tab.sync", "ignore")
22+
utils.move_missing_val(opts, "", "open_on_tab", opts, "tab.sync", "close", true)
23+
utils.move_missing_val(opts, "", "ignore_buf_on_tab_change", opts, "tab.sync", "ignore", true)
2424

2525
-- 2022/11/22
26-
utils.move_missing_val(opts, "renderer", "root_folder_modifier", opts, "renderer", "root_folder_label")
26+
utils.move_missing_val(opts, "renderer", "root_folder_modifier", opts, "renderer", "root_folder_label", true)
2727
end
2828

2929
local function removed(opts)

Diff for: lua/nvim-tree/log.lua

+6-4
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,19 @@ function M.raw(typ, fmt, ...)
1414

1515
local line = string.format(fmt, ...)
1616
local file = io.open(M.path, "a")
17-
io.output(file)
18-
io.write(line)
19-
io.close(file)
17+
if file then
18+
io.output(file)
19+
io.write(line)
20+
io.close(file)
21+
end
2022
end
2123

2224
--- Write to log file via M.line
2325
--- START is prefixed
2426
--- @return number nanos to pass to profile_end
2527
function M.profile_start(fmt, ...)
2628
if not M.path or not M.config.types.profile and not M.config.types.all then
27-
return
29+
return 0
2830
end
2931
M.line("profile", "START " .. (fmt or "???"), ...)
3032
return vim.loop.hrtime()

Diff for: lua/nvim-tree/utils.lua

+4-13
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,8 @@ end
197197
-- Create empty sub-tables if not present
198198
-- @param tbl to create empty inside of
199199
-- @param path dot separated string of sub-tables
200-
-- @return deepest sub-table
200+
-- @return table deepest sub-table
201201
function M.table_create_missing(tbl, path)
202-
if tbl == nil then
203-
return nil
204-
end
205-
206202
local t = tbl
207203
for s in string.gmatch(path, "([^%.]+)%.*") do
208204
if t[s] == nil then
@@ -222,12 +218,8 @@ end
222218
--- @param dst table to copy to
223219
--- @param dst_path string dot separated string of sub-tables, created when missing
224220
--- @param dst_pos string value pos
225-
--- @param remove boolean default true
221+
--- @param remove boolean
226222
function M.move_missing_val(src, src_path, src_pos, dst, dst_path, dst_pos, remove)
227-
if remove == nil then
228-
remove = true
229-
end
230-
231223
local ok, err = pcall(vim.validate, {
232224
src = { src, "table" },
233225
src_path = { src_path, "string" },
@@ -246,11 +238,10 @@ function M.move_missing_val(src, src_path, src_pos, dst, dst_path, dst_pos, remo
246238
if src[pos] and type(src[pos]) == "table" then
247239
src = src[pos]
248240
else
249-
src = nil
250-
break
241+
return
251242
end
252243
end
253-
local src_val = src and src[src_pos]
244+
local src_val = src[src_pos]
254245
if src_val == nil then
255246
return
256247
end

Diff for: lua/nvim-tree/view.lua

+4-4
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,8 @@ function M.restore_tab_state()
389389
end
390390

391391
--- Returns the window number for nvim-tree within the tabpage specified
392-
---@param tabpage number: (optional) the number of the chosen tabpage. Defaults to current tabpage.
393-
---@return number
392+
---@param tabpage number|nil (optional) the number of the chosen tabpage. Defaults to current tabpage.
393+
---@return number|nil
394394
function M.get_winnr(tabpage)
395395
tabpage = tabpage or vim.api.nvim_get_current_tabpage()
396396
local tabinfo = M.View.tabpages[tabpage]
@@ -406,8 +406,8 @@ function M.get_bufnr()
406406
end
407407

408408
--- Checks if nvim-tree is displaying the help ui within the tabpage specified
409-
---@param tabpage number: (optional) the number of the chosen tabpage. Defaults to current tabpage.
410-
---@return number
409+
---@param tabpage number|nil (optional) the number of the chosen tabpage. Defaults to current tabpage.
410+
---@return number|nil
411411
function M.is_help_ui(tabpage)
412412
tabpage = tabpage or vim.api.nvim_get_current_tabpage()
413413
local tabinfo = M.View.tabpages[tabpage]

0 commit comments

Comments
 (0)