-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Labels
area:commentsIssues with how Prettier prints commentsIssues with how Prettier prints commentslang:javascriptIssues affecting JSIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.
Description
Discovered this after attempting to upgrade from 2.5.1 to 2.6.0.
Prettier 2.6.0
Playground link
{
"arrowParens": "always",
"bracketSameLine": false,
"bracketSpacing": true,
"embeddedLanguageFormatting": "auto",
"htmlWhitespaceSensitivity": "strict",
"insertPragma": false,
"jsxSingleQuote": false,
"printWidth": 80,
"proseWrap": "never",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false,
"vueIndentScriptAndStyle": false
}
Input:
function test() {
switch (state) {
case fieldStates.READONLY:
result = fieldStates.ENABLED;
break;
case fieldStates.ACTIVE_READONLY:
result = fieldStates.ACTIVE;
break;
case fieldStates.ERROR_READONLY:
result = fieldStates.ERROR;
break;
case fieldStates.ERROR_ACTIVE_READONLY:
result = fieldStates.ERROR_ACTIVE;
break;
default:
result = state; // no change
break;
}
}
Output:
function test() {
switch (state) {
case fieldStates.READONLY:
result = fieldStates.ENABLED;
break;
case fieldStates.ACTIVE_READONLY:
result = fieldStates.ACTIVE;
break;
case fieldStates.ERROR_READONLY:
result = fieldStates.ERROR;
break;
case fieldStates.ERROR_ACTIVE_READONLY:
result = fieldStates.ERROR_ACTIVE;
break;
default: // no change
result = state;
break;
}
}
Expected behavior:
The // no change
comment shouldn't move. It should stay next to the line where I put it.
LukeNotable, nelsonsbrian and alfaproject
Metadata
Metadata
Assignees
Labels
area:commentsIssues with how Prettier prints commentsIssues with how Prettier prints commentslang:javascriptIssues affecting JSIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.