.prettierrc.json and .prettierrc.toml reject a leading UTF-8 BOM
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, node.js
Research direction
Start with the CLI entry point bin/prettier.cjs and reproduce the issue using the provided .prettierrc.json and .prettierrc.toml commands. Trace how these textual configuration files are read, then verify that a single leading UTF-8 BOM is ignored and example.js formats with the expected output.
Written by the indexing model from the issue text.
Description
Environments:
- Prettier Version: 3.10.0-dev (commit 1a153120)
- Running Prettier via: CLI
- Runtime: Node.js v25.6.0
- Operating System: Windows 11 64-bit
- Prettier plugins (if any): None
Steps to reproduce:
Create a JavaScript file:
// example.js
const message = "hello";
Create a .prettierrc.json file with a leading UTF-8 BOM:
node -e "require('node:fs').writeFileSync('.prettierrc.json', '\uFEFF{\"semi\":false}\n')"
Run Prettier:
node ./bin/prettier.cjs --config .prettierrc.json example.js
The same issue can be reproduced with TOML:
node -e "require('node:fs').writeFileSync('.prettierrc.toml', '\uFEFFsemi = false\n')"
node ./bin/prettier.cjs --config .prettierrc.toml example.js
For comparison, configuration files containing the same leading BOM work when using JSON5 or YAML.
Expected behavior:
Prettier should ignore a single leading UTF-8 BOM when reading textual configuration files and format the JavaScript file as:
const message = "hello"
This would make the behavior consistent across JSON, TOML, JSON5, and YAML configuration files.
RFC 8259 also allows JSON parsers to ignore a leading BOM for interoperability:
https://www.rfc-editor.org/rfc/rfc8259.html#section-8.1
Actual behavior:
The JSON configuration exits with status code 2:
Invalid configuration for file "example.js":
JSON Error in .prettierrc.json:
Unexpected token "" (\u{feff})
The TOML configuration also exits with status code 2:
Invalid configuration for file "example.js":
TOML Error in .prettierrc.toml:
Invalid TOML document: only letters, numbers, dashes and underscores are allowed in keys
1: semi = false
^
- Dominant language
- JavaScript
- Stars
- 52.3k
- Forks
- 5k
- Avg merge
- 20h 28m
- Merged PRs (30d)
- 112
Contributor guide
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 prettier/prettier
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Integrate AgentScan Opentype:infra
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
status:needs investigation
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
help wanted lang:typescript scope:external
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
lang:javascript status:needs discussion type:refactor
Difficulty 5/5 Over a week Newbie friendliness 35/100
All issues in prettier/prettier
Similar issues
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
optimization optimization:agents-md-curator
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
githubnext/gh-aw-cao#13143 ·
-
status: needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100