Fix JSDoc multiline type cast alignment in assignment (#19180)
This commit is contained in:
1 parent
c3556d9d5c
commit
6ae5fecd46
5 files changed
+66
-8
No files matched your search
@@ -0,0 +1,20 @@
|
||||
#### Fix multiline JSDoc-style comment alignment in assignments (#19180 by @kovsu)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
const foo = /**
|
||||
* comment
|
||||
*/ bar;
|
||||
|
||||
// Prettier stable
|
||||
const foo = /**
|
||||
* comment
|
||||
*/ bar;
|
||||
|
||||
// Prettier main
|
||||
const foo =
|
||||
/**
|
||||
* comment
|
||||
*/ bar;
|
||||
```
|
||||
@@ -11,7 +11,9 @@ import {
|
||||
import getStringWidth from "../../utilities/get-string-width.js";
|
||||
import isNonEmptyArray from "../../utilities/is-non-empty-array.js";
|
||||
import { getCallArguments } from "../utilities/call-arguments.js";
|
||||
import { CommentCheckFlags, hasComment } from "../utilities/comments.js";
|
||||
import { hasLeadingOwnLineComment } from "../utilities/has-leading-own-line-comment.js";
|
||||
import { isIndentableBlockComment } from "../utilities/indentable-block-comment.js";
|
||||
import { isLoneShortArgument } from "../utilities/is-lone-short-argument.js";
|
||||
import { isObjectProperty } from "../utilities/is-object-property.js";
|
||||
import {
|
||||
@@ -138,7 +140,8 @@ function chooseLayout(path, options, print, leftDoc, rightPropertyName) {
|
||||
if (
|
||||
isHeadOfLongChain ||
|
||||
(isUnionType(rightNode) && !shouldHugUnionType(rightNode)) ||
|
||||
hasLeadingOwnLineComment(options.originalText, rightNode)
|
||||
hasLeadingOwnLineComment(options.originalText, rightNode) ||
|
||||
hasComment(rightNode, CommentCheckFlags.Leading, isIndentableBlockComment)
|
||||
) {
|
||||
return "break-after-operator";
|
||||
}
|
||||
|
||||
@@ -192,6 +192,33 @@ const bifornCringerMoshedPerplexSawder = // !!!
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`indentable-block-comment.js format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel", "flow", "typescript"]
|
||||
printWidth: 80 (default) |
|
||||
=====================================input======================================
|
||||
fnString = /**
|
||||
* multi-line
|
||||
*/ value;
|
||||
|
||||
var fnString = /**
|
||||
* multi-line
|
||||
*/ value;
|
||||
|
||||
=====================================output=====================================
|
||||
fnString =
|
||||
/**
|
||||
* multi-line
|
||||
*/ value;
|
||||
|
||||
var fnString =
|
||||
/**
|
||||
* multi-line
|
||||
*/ value;
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`number.js format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel", "flow", "typescript"]
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
fnString = /**
|
||||
* multi-line
|
||||
*/ value;
|
||||
|
||||
var fnString = /**
|
||||
* multi-line
|
||||
*/ value;
|
||||
@@ -173,13 +173,14 @@ const style = /** @type {{
|
||||
...margins,
|
||||
});
|
||||
|
||||
const style2 = /**
|
||||
* @type {{
|
||||
* width: number,
|
||||
* }}
|
||||
*/ ({
|
||||
width,
|
||||
});
|
||||
const style2 =
|
||||
/**
|
||||
* @type {{
|
||||
* width: number,
|
||||
* }}
|
||||
*/ ({
|
||||
width,
|
||||
});
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
Reference in new issue
Block a user