Do not indent for switch case with `;` (#1687)
The indentation detection didn't discard empty statementsmaster
parent
bcc3eb9272
commit
47d9686402
|
@ -3,3 +3,4 @@
|
|||
/tests/**/*.js
|
||||
!/tests/**/jsfmt.spec.js
|
||||
!/**/.eslintrc.js
|
||||
/test.js
|
||||
|
|
|
@ -1423,8 +1423,13 @@ function genericPrintNoParens(path, options, print, args) {
|
|||
.filter(e => e !== null)
|
||||
);
|
||||
}, "consequent");
|
||||
|
||||
const consequent = n.consequent.filter(
|
||||
node => node.type !== "EmptyStatement"
|
||||
);
|
||||
|
||||
parts.push(
|
||||
n.consequent.length === 1 && n.consequent[0].type === "BlockStatement"
|
||||
consequent.length === 1 && consequent[0].type === "BlockStatement"
|
||||
? concat([" ", cons])
|
||||
: indent(concat([hardline, cons]))
|
||||
);
|
||||
|
|
|
@ -143,6 +143,24 @@ switch (a) {
|
|||
|
||||
`;
|
||||
|
||||
exports[`empty_statement.js 1`] = `
|
||||
switch (error.code) {
|
||||
case ConfigurationEditingErrorCode.ERROR_INVALID_CONFIGURATION: {
|
||||
nls.localize('errorInvalidConfiguration', "Unable to write into settings. Correct errors/warnings in the file and try again.");
|
||||
};
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
switch (error.code) {
|
||||
case ConfigurationEditingErrorCode.ERROR_INVALID_CONFIGURATION: {
|
||||
nls.localize(
|
||||
"errorInvalidConfiguration",
|
||||
"Unable to write into settings. Correct errors/warnings in the file and try again."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
`;
|
||||
|
||||
exports[`empty_switch.js 1`] = `
|
||||
switch (1) { default:; }
|
||||
switch (1) {}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
switch (error.code) {
|
||||
case ConfigurationEditingErrorCode.ERROR_INVALID_CONFIGURATION: {
|
||||
nls.localize('errorInvalidConfiguration', "Unable to write into settings. Correct errors/warnings in the file and try again.");
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue