bug: prettier error being written to buffer
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
Reproduce the issue in Neovim using the provided Prettier configuration, an SCSS buffer, and a missing bracket. Start by tracing how the formatter handles stderr and the configured exit_codes; done means an exit code of 2 leaves the buffer unchanged. The payload names no repository file or test path.
Written by the indexing model from the issue text.
Description
Neovim version (nvim -v)
0.10.2
Operating system/version
macos 15
Read debugging tips
- I have read through the debugging tips.
Add the debug logs
- I have set
log_level = vim.log.levels.DEBUGand pasted the log contents below.
Log file
... filepath
[error] 1 |
[error] > 2 | <input css 1>
[error] | ^
[error] 3 | 13:5 ✖ Unknown word CssSyntaxError
[error] 4 |
[error] 5 | 1 problem (1 error, 0 warnings)
Describe the bug
When theres a syntax error, the error gets written to the buffer despite the exit code being 2 and me specifying 0,1.
What is the severity of this bug?
breaking (some functionality is broken)
Steps To Reproduce
open this as scss
nav {
ul {
margin: 0;
padding: 0;
list-style: none;
}
li { display: inline-block; }
a {
display: block;
padding: 6px 12px;
text-decoration: none;
}
}
then delete a bracket. Then try to format, the error gets written into the buffer
Expected Behavior
It should not modify the buffer because the exit code was 2.
Minimal example file
prettier = {
command = format_utils.from_node_modules("prettier"),
args = function(self, ctx)
local args = { "--stdin-filepath", "$FILENAME" }
-- Get the current buffer's shiftwidth
local shiftwidth = vim.bo.shiftwidth
-- Determine if tabs or spaces are being used
local use_tabs = vim.bo.expandtab == false
-- Add indentation options
table.insert(args, "--use-tabs")
table.insert(args, tostring(use_tabs))
table.insert(args, "--tab-width")
table.insert(args, tostring(shiftwidth))
-- Add config path if specified
local config_path = format_utils.find_config_file("prettier", prettier_config_patterns, ctx)
if config_path then
table.insert(args, "--config")
table.insert(args, config_path)
end
return args
end,
stdin = true,
exit_codes = { 0, 1 },
cwd = function()
return file_utils.find_closest_node_modules_to_current_file()
end,
condition = function(_, ctx)
return format_utils.formatter_condition("prettier", prettier_config_patterns, ctx)
end,
},
Minimal init.lua
No response
Additional context
No response
- Dominant language
- Lua
- Stars
- 5.3k
- Forks
- 311
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from stevearc/conform.nvim
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
stevearc/conform.nvim#887 ·
-
update zigfmt Open
Difficulty 1/5 Under an hour Newbie friendliness 78/100
stevearc/conform.nvim#879 ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 68/100
stevearc/conform.nvim#891 · 1 comment · 1 reaction ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
stevearc/conform.nvim#878 ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 72/100
stevearc/conform.nvim#877 ·
All issues in stevearc/conform.nvim
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
[Eco] Egg Config Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
pterodactyl/game-eggs#634 ·
-
Feature Request
Difficulty 1/5 Under an hour Newbie friendliness 72/100
Questie/QuestieTrace#33 ·