Skip to content

Commit

Permalink
feature: @putout/printer: ObjectPattern: improve indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Apr 16, 2024
1 parent 1d9ba3f commit 5ac7b7b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,14 @@ const [name, {
match,
declare,
scan,
}] = maybeEntries(plugin);
}] = maybeEntries(plugin);

function x() {
const [name, {
report,
find,
traverse,
include,
exclude,
}] = maybeEntries(plugin);
}
7 changes: 5 additions & 2 deletions lib/tokenize/expressions/object-pattern/object-pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ function isIndent(path) {
module.exports.ObjectPattern = {
print: maybeTypeAnnotation((path, {print, maybe}, semantics) => {
const {maxPropertiesInOneLine} = semantics;

const shouldIndent = isIndent(path);

maybe.indent.inc(shouldIndent);
print('{');

Expand Down Expand Up @@ -93,7 +93,10 @@ module.exports.ObjectPattern = {
}

maybe.indent.dec(shouldIndent);
maybe.indent(is && shouldIndent);

maybe.indent.dec(!shouldIndent);
maybe.indent(is);
maybe.indent.inc(!shouldIndent);
print('}');
}),
afterIf(path) {
Expand Down

0 comments on commit 5ac7b7b

Please sign in to comment.