Fix last comment of import (#1677)
We used to use isBlock as a heuristic but the real thing we want is to know if the comment is on its own line. Now it works with both :)master
parent
19486bdd17
commit
069df25475
|
@ -173,6 +173,7 @@ function attach(comments, ast, text) {
|
|||
) ||
|
||||
handleOnlyComments(enclosingNode, ast, comment, isLastComment) ||
|
||||
handleImportDeclarationComments(
|
||||
text,
|
||||
enclosingNode,
|
||||
precedingNode,
|
||||
comment
|
||||
|
@ -726,6 +727,7 @@ function handleForComments(enclosingNode, precedingNode, comment) {
|
|||
}
|
||||
|
||||
function handleImportDeclarationComments(
|
||||
text,
|
||||
enclosingNode,
|
||||
precedingNode,
|
||||
comment
|
||||
|
@ -734,7 +736,7 @@ function handleImportDeclarationComments(
|
|||
precedingNode &&
|
||||
enclosingNode &&
|
||||
enclosingNode.type === "ImportDeclaration" &&
|
||||
!util.isBlockComment(comment)
|
||||
util.hasNewline(text, util.locEnd(comment))
|
||||
) {
|
||||
addTrailingComment(precedingNode, comment);
|
||||
return true;
|
||||
|
|
|
@ -87,6 +87,14 @@ import {
|
|||
// FN4,
|
||||
// FN5
|
||||
} from "./module";
|
||||
|
||||
import {
|
||||
ExecutionResult,
|
||||
DocumentNode,
|
||||
/* tslint:disable */
|
||||
SelectionSetNode,
|
||||
/* tslint:enable */
|
||||
} from 'graphql';
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
import {
|
||||
//comment1
|
||||
|
@ -123,6 +131,14 @@ import {
|
|||
// FN5
|
||||
} from "./module";
|
||||
|
||||
import {
|
||||
ExecutionResult,
|
||||
DocumentNode,
|
||||
/* tslint:disable */
|
||||
SelectionSetNode
|
||||
/* tslint:enable */
|
||||
} from "graphql";
|
||||
|
||||
`;
|
||||
|
||||
exports[`comments.js 2`] = `
|
||||
|
@ -158,6 +174,14 @@ import {
|
|||
// FN4,
|
||||
// FN5
|
||||
} from "./module";
|
||||
|
||||
import {
|
||||
ExecutionResult,
|
||||
DocumentNode,
|
||||
/* tslint:disable */
|
||||
SelectionSetNode,
|
||||
/* tslint:enable */
|
||||
} from 'graphql';
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
import {
|
||||
//comment1
|
||||
|
@ -194,6 +218,14 @@ import {
|
|||
// FN5
|
||||
} from "./module";
|
||||
|
||||
import {
|
||||
ExecutionResult,
|
||||
DocumentNode,
|
||||
/* tslint:disable */
|
||||
SelectionSetNode
|
||||
/* tslint:enable */
|
||||
} from "graphql";
|
||||
|
||||
`;
|
||||
|
||||
exports[`long-line.js 1`] = `
|
||||
|
|
|
@ -30,3 +30,11 @@ import {
|
|||
// FN4,
|
||||
// FN5
|
||||
} from "./module";
|
||||
|
||||
import {
|
||||
ExecutionResult,
|
||||
DocumentNode,
|
||||
/* tslint:disable */
|
||||
SelectionSetNode,
|
||||
/* tslint:enable */
|
||||
} from 'graphql';
|
||||
|
|
Loading…
Reference in New Issue