Hidden Assumptions in prettier

10 assumptions this code never checks · 3 critical · spanning Resource, Environment, Contract, Temporal, Ordering, Scale, Domain

Every codebase relies on things it never checks. Most of them are routine. CodeSea looked at prettier/prettier and picked out the few most likely to cause trouble. The full list is just below.

Most of what this code assumes is routine. These 3 are the ones most likely to cause trouble here. The rest are minor; they're under "Show everything".

Worth your attention first

Silent failures or EACCES errors when trying to read .prettierrc files in protected directories or network-mounted filesystems with restrictive permissions

Worth your attention first

Array.at() calls with negative indices return undefined when stack is shorter than expected, causing cascading null reference errors in printer functions that rely on parent/grandparent navigation

Worth your attention first

printDocToString() processes malformed Doc objects without validation, leading to incorrect formatting output or runtime errors when accessing expected properties

Show everything (7 more)
Temporal

EditorConfig files remain unchanged between cache entries, and the cache never becomes stale during long-running processes or file watching scenarios

If this fails: Outdated formatting rules applied when .editorconfig files are modified after initial load, requiring manual cache clearing or process restart to pick up changes

src/config/editorconfig/index.js:editorconfigCache
Ordering

Built-in plugins are always loaded before user plugins in the Promise.all array, and plugin precedence follows the flat() array order

If this fails: Plugin conflicts resolved unexpectedly if user plugins override built-in parsers/printers, potentially causing wrong language detection or formatting behavior

src/index.js:withPlugins function
Scale

File contents fit in Node.js memory limits and fs.readFile can handle the entire file synchronously without streaming

If this fails: ENOMEM errors or blocking event loop when serving large JavaScript/HTML files that exceed available RAM, especially in memory-constrained environments

tests/config/browser-prettier/server.js:getContent
Domain

HTML node structures follow standard DOM patterns with expected property names (kind, children, isSelfClosing, endSourceSpan) and Vue-specific nodes are properly identified by isVueNonHtmlBlock

If this fails: Incorrectly preserved or formatted content when processing HTML from different parsers or non-standard markup structures that don't match the expected node shape

src/language-html/utilities/index.js:shouldPreserveContent
Environment

File paths are accessible and readable by the Node.js process, and glob patterns in ignore files resolve without filesystem permission errors

If this fails: getFileInfo returns incorrect 'ignored: false' status for files that should be ignored when .prettierignore files cannot be read or glob matching fails due to permissions

src/common/get-file-info.js:isIgnored call
Contract

All location utility functions receive AST nodes that conform to the expected location schema with loc, start, end properties as used by Babel/TypeScript parsers

If this fails: Location comparison and manipulation functions fail silently or return wrong results when processing AST nodes from different parsers that use alternative location formats

src/language-js/location/index.js:exports
Resource

Input text size is reasonable for string manipulation operations and the outdent template literal processing doesn't exceed stack limits

If this fails: Stack overflow or performance degradation when processing very large TOML files with deeply nested template literal operations

tests/config/prettier-plugins/prettier-plugin-dummy-toml/index.js:print function

See the full structural analysis of prettier: the pipeline, data models, and system behavior that put these assumptions in context.

Full analysis of prettier/prettier →

Compare prettier

Frequently Asked Questions

What does prettier assume that could break in production?

The one most likely to cause trouble: Node.js file system operations have sufficient permissions to read config files in the resolved path, and the process has access to traverse directory structures during config search If this fails, Silent failures or EACCES errors when trying to read .prettierrc files in protected directories or network-mounted filesystems with restrictive permissions

How many hidden assumptions does prettier have?

CodeSea found 10 assumptions prettier relies on but never validates, 3 of them critical, spanning Resource, Environment, Contract, Temporal, Ordering, Scale, Domain. Most are routine — the analysis flags the two or three most likely to actually bite.

What is a hidden assumption?

Something the code depends on but never checks: a data shape, an ordering, an environment condition, a scale limit, or a contract with another service. It holds until the world it runs in changes, then fails silently.