This commit is contained in:
1 parent
794ca266a9
commit
121d0d3dd9
9 files changed
+44
-18
No files matched your search
@@ -1092,6 +1092,9 @@ function handleParenthesizedExpressionTrailingComment({
|
||||
enclosingNode.init === precedingNode) ||
|
||||
(enclosingNode.type === "ReturnStatement" &&
|
||||
enclosingNode.argument === precedingNode) ||
|
||||
(isSequence &&
|
||||
enclosingNode.type === "ExpressionStatement" &&
|
||||
enclosingNode.expression === precedingNode) ||
|
||||
(isSequence &&
|
||||
enclosingNode.type === "AssignmentExpression" &&
|
||||
enclosingNode.right === precedingNode)) &&
|
||||
|
||||
@@ -27,6 +27,7 @@ const overrideBreakOrContinueEnd =
|
||||
const getContentEnd = (node) => node.__contentEnd ?? locEndWithFullText(node);
|
||||
|
||||
const nodeTypesWithContentEnd = /** @type {const} */ ([
|
||||
"ExpressionStatement",
|
||||
"Directive",
|
||||
"ImportDeclaration",
|
||||
"ExportDefaultDeclaration",
|
||||
@@ -45,8 +46,6 @@ const overrides =
|
||||
["DebuggerStatement", (node) => locStart(node) + DEBUGGER_KEYWORD_LENGTH],
|
||||
// @ts-expect-error -- ignore
|
||||
["VariableDeclaration", (node) => locEnd(node.declarations.at(-1))],
|
||||
// @ts-expect-error -- ignore
|
||||
["ExpressionStatement", (node) => locEnd(node.expression)],
|
||||
...nodeTypesWithContentEnd.map((type) => [type, getContentEnd]),
|
||||
]);
|
||||
|
||||
@@ -63,8 +62,7 @@ const shouldIgnoredNodePrintSemicolon = (node) => {
|
||||
type === "BreakStatement" ||
|
||||
type === "ContinueStatement" ||
|
||||
type === "DebuggerStatement" ||
|
||||
type === "VariableDeclaration" ||
|
||||
type === "ExpressionStatement"
|
||||
type === "VariableDeclaration"
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -4,8 +4,10 @@ import { FORMAT_TEST_DIRECTORY } from "./constants.js";
|
||||
// TODO: these test files need fix
|
||||
const unstableTests = new Map(
|
||||
[
|
||||
"js/ignore/semi/class-expression-decorator.js",
|
||||
["js/identifier/parentheses/let.js", (options) => options.semi === false],
|
||||
[
|
||||
"js/ignore/semi/class-expression-decorator.js",
|
||||
(options) => options.semi === false,
|
||||
],
|
||||
["js/ignore/semi/head-ignored.js", (options) => options.semi === false],
|
||||
"js/comments/return-statement.js",
|
||||
"js/comments/tagged-template-literal.js",
|
||||
|
||||
@@ -317,7 +317,7 @@ function HelloWorld(x) {
|
||||
// eslint-disable-next-line
|
||||
x.a |
|
||||
x.b
|
||||
).call(null);
|
||||
).call(null)
|
||||
}
|
||||
|
||||
================================================================================
|
||||
@@ -401,3 +401,18 @@ let y =
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`parenthesized-expression.js format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel", "flow", "typescript"]
|
||||
printWidth: 80 (default) |
|
||||
=====================================input======================================
|
||||
// prettier-ignore
|
||||
(a = 1);
|
||||
|
||||
=====================================output=====================================
|
||||
// prettier-ignore
|
||||
(a = 1);
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
@@ -0,0 +1,2 @@
|
||||
// prettier-ignore
|
||||
(a = 1);
|
||||
@@ -136,7 +136,7 @@ const x1 = (a, b, c /* comment */);
|
||||
const x2 = (a = c /* comment */);
|
||||
|
||||
(a, b, c /* comment */);
|
||||
(a = c /* comment */);
|
||||
// (a = c /* comment */);
|
||||
|
||||
assigned = (a, b, c /* comment */);
|
||||
// assigned = (a = c /* comment */);
|
||||
@@ -150,8 +150,8 @@ function f() {
|
||||
const x1 = (a, b, c /* comment */);
|
||||
const x2 = (a = c /* comment */);
|
||||
|
||||
(a, b, c); /* comment */
|
||||
a = c; /* comment */
|
||||
(a, b, c /* comment */);
|
||||
// (a = c /* comment */);
|
||||
|
||||
assigned = (a, b, c /* comment */);
|
||||
// assigned = (a = c /* comment */);
|
||||
@@ -169,12 +169,16 @@ exports[`parenthesized-trailing-comment-unstable.js format 1`] = `
|
||||
parsers: ["babel", "flow", "typescript"]
|
||||
printWidth: 80 (default) |
|
||||
=====================================input======================================
|
||||
// TODO: Enable test in parenthesized-trailing-comment.js when it's stable
|
||||
// TODO: Enable tests in parenthesized-trailing-comment.js when they are stable
|
||||
|
||||
(a = c /* comment */);
|
||||
|
||||
assigned = (a = c /* comment */);
|
||||
|
||||
=====================================output=====================================
|
||||
// TODO: Enable test in parenthesized-trailing-comment.js when it's stable
|
||||
// TODO: Enable tests in parenthesized-trailing-comment.js when they are stable
|
||||
|
||||
a = c /* comment */;
|
||||
|
||||
assigned = a = c /* comment */;
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// TODO: Enable test in parenthesized-trailing-comment.js when it's stable
|
||||
// TODO: Enable tests in parenthesized-trailing-comment.js when they are stable
|
||||
|
||||
(a = c /* comment */);
|
||||
|
||||
assigned = (a = c /* comment */);
|
||||
@@ -2,7 +2,7 @@ const x1 = (a, b, c /* comment */);
|
||||
const x2 = (a = c /* comment */);
|
||||
|
||||
(a, b, c /* comment */);
|
||||
(a = c /* comment */);
|
||||
// (a = c /* comment */);
|
||||
|
||||
assigned = (a, b, c /* comment */);
|
||||
// assigned = (a = c /* comment */);
|
||||
|
||||
@@ -1530,7 +1530,7 @@ matrix(
|
||||
1, 0, 0,
|
||||
0, 1, 0,
|
||||
0, 0, 1
|
||||
);
|
||||
)
|
||||
\`\`\`
|
||||
|
||||
will be transformed to:
|
||||
@@ -1543,7 +1543,7 @@ matrix(
|
||||
1, 0, 0,
|
||||
0, 1, 0,
|
||||
0, 0, 1
|
||||
);
|
||||
)
|
||||
\`\`\`
|
||||
|
||||
## Options
|
||||
@@ -3501,7 +3501,7 @@ matrix(
|
||||
1, 0, 0,
|
||||
0, 1, 0,
|
||||
0, 0, 1
|
||||
);
|
||||
)
|
||||
\`\`\`
|
||||
|
||||
will be transformed to:
|
||||
@@ -3514,7 +3514,7 @@ matrix(
|
||||
1, 0, 0,
|
||||
0, 1, 0,
|
||||
0, 0, 1
|
||||
);
|
||||
)
|
||||
\`\`\`
|
||||
|
||||
## Options
|
||||
|
||||
Reference in new issue
Block a user