Bad interaction with semicolon, comments, and parentheses
Author: cpreciosoCreated Oct 26, 2023Updated Sep 16, 2026
Labelsarea:commentslang:javascriptarea:idempotency
Prettier 3.0.3 Playground link
--parser babel
Input:
const AUTHORIZATION_TOKEN_VALIDITY =
(24 * hours /* docs */) - (1 * hours /* buffer */)
Output:
const AUTHORIZATION_TOKEN_VALIDITY =
24 * hours /* docs */ - 1 * hours /* buffer */;
Second Output:
const AUTHORIZATION_TOKEN_VALIDITY =
24 * hours /* docs */ - 1 * hours; /* buffer */
Expected behavior: First and second output are the same
Source: prettier/prettier