Prevent "over-indenting" class properties values (#4085)

master
Lucas Duailibe 2018-03-02 11:28:27 -03:00 committed by GitHub
parent a02094961a
commit 41098a06b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 102 additions and 2 deletions

View File

@ -436,6 +436,9 @@ function printPathNoParens(path, options, print, args) {
const shouldIndentIfInlining =
parent.type === "AssignmentExpression" ||
parent.type === "VariableDeclarator" ||
parent.type === "ClassProperty" ||
parent.type === "TSAbstractClassProperty" ||
parent.type === "ClassPrivateProperty" ||
parent.type === "ObjectProperty" ||
parent.type === "Property";

View File

@ -91,8 +91,8 @@ class X {
TEMPLATE =
// tab index is needed so we can focus, which is needed for keyboard events
'<div class="ag-large-text" tabindex="0">' +
'<div class="ag-large-textarea"></div>' +
"</div>";
'<div class="ag-large-textarea"></div>' +
"</div>";
}
export class SnapshotLogger {

View File

@ -161,6 +161,25 @@ class C {
`;
exports[`property.js 1`] = `
class A {
foobar =
// comment to break
1 +
// comment to break again
2;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class A {
foobar =
// comment to break
1 +
// comment to break again
2;
}
`;
exports[`ternary.js 1`] = `
if (1) (class {}) ? 1 : 2;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -0,0 +1,7 @@
class A {
foobar =
// comment to break
1 +
// comment to break again
2;
}

View File

@ -173,3 +173,41 @@ class Point {
}
`;
exports[`with_comments.js 1`] = `
class A {
#foobar =
// comment to break
1 +
// comment to break again
2;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class A {
#foobar =
// comment to break
1 +
// comment to break again
2;
}
`;
exports[`with_comments.js 2`] = `
class A {
#foobar =
// comment to break
1 +
// comment to break again
2;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class A {
#foobar =
// comment to break
1 +
// comment to break again
2
}
`;

View File

@ -0,0 +1,7 @@
class A {
#foobar =
// comment to break
1 +
// comment to break again
2;
}

View File

@ -61,3 +61,22 @@ abstract class Foo {
}
`;
exports[`abstractPropertiesWithBreaks.ts 1`] = `
abstract class Foo {
abstract private foobar =
// comment to break
1 +
// another comment to break
2;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
abstract class Foo {
private abstract foobar =
// comment to break
1 +
// another comment to break
2;
}
`;

View File

@ -0,0 +1,7 @@
abstract class Foo {
abstract private foobar =
// comment to break
1 +
// another comment to break
2;
}