verify the precedingNode type when handling import declaration comments (#5016)

master
Eric Sakmar 2018-08-27 22:02:40 -04:00 committed by Suchipi
parent 8779937a07
commit 93e8b15311
3 changed files with 26 additions and 0 deletions

View File

@ -660,6 +660,7 @@ function handleImportDeclarationComments(
) {
if (
precedingNode &&
precedingNode.type === "ImportSpecifier" &&
enclosingNode &&
enclosingNode.type === "ImportDeclaration" &&
privateUtil.hasNewline(text, options.locEnd(comment))

View File

@ -95,6 +95,11 @@ import {
SelectionSetNode,
/* tslint:enable */
} from 'graphql';
import x, {
// comment
y
} from 'z';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import {
//comment1
@ -139,6 +144,11 @@ import {
/* tslint:enable */
} from "graphql";
import x, {
// comment
y
} from "z";
`;
exports[`comments.js - flow-verify 2`] = `
@ -182,6 +192,11 @@ import {
SelectionSetNode,
/* tslint:enable */
} from 'graphql';
import x, {
// comment
y
} from 'z';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import {
//comment1
@ -226,6 +241,11 @@ import {
/* tslint:enable */
} from "graphql";
import x, {
// comment
y
} from "z";
`;
exports[`empty-import.js - flow-verify 1`] = `

View File

@ -38,3 +38,8 @@ import {
SelectionSetNode,
/* tslint:enable */
} from 'graphql';
import x, {
// comment
y
} from 'z';