Skip to content

Commit

Permalink
Disable it for dangling comments
Browse files Browse the repository at this point in the history
  • Loading branch information
thorn0 committed Sep 8, 2022
1 parent b92433f commit 666c538
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/language-js/print/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ function printIndentableBlockComment(path) {

const isNestled =
Boolean(previousComment) &&
// Disable nestling for dangling comments for now
(comment.leading || comment.trailing) &&
isBlockComment(previousComment) &&
isIndentableBlockComment(previousComment) &&
locEnd(previousComment) === locStart(comment);
Expand Down
89 changes: 89 additions & 0 deletions tests/format/js/comments/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3182,6 +3182,95 @@ function value(type, value) {
================================================================================
`;
exports[`jsdoc-nestled-dangling.js - {"semi":false} format 1`] = `
====================================options=====================================
parsers: ["babel", "flow", "typescript"]
printWidth: 80
semi: false
| printWidth
=====================================input======================================
{{{{{{{
o={
/**
* A
*//**
* B
*/
}
}}}}}}}
=====================================output=====================================
{
{
{
{
{
{
{
o = {
/**
* A
*/
/**
* B
*/
}
}
}
}
}
}
}
}
================================================================================
`;
exports[`jsdoc-nestled-dangling.js format 1`] = `
====================================options=====================================
parsers: ["babel", "flow", "typescript"]
printWidth: 80
| printWidth
=====================================input======================================
{{{{{{{
o={
/**
* A
*//**
* B
*/
}
}}}}}}}
=====================================output=====================================
{
{
{
{
{
{
{
o = {
/**
* A
*/
/**
* B
*/
};
}
}
}
}
}
}
}
================================================================================
`;
exports[`jsx.js - {"semi":false} format 1`] = `
====================================options=====================================
parsers: ["babel", "flow", "typescript"]
Expand Down
10 changes: 10 additions & 0 deletions tests/format/js/comments/jsdoc-nestled-dangling.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{{{{{{
o={
/**
* A
*//**
* B
*/

}
}}}}}}}

0 comments on commit 666c538

Please sign in to comment.