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.
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:
Output:
Expected behavior:
The
// no changecomment shouldn't move. It should stay next to the line where I put it.