fix: inserted imports must come after a shebang if present

This commit is contained in:
Jeremy Banks 2022-06-15 19:42:16 +00:00 committed by GitHub
parent f32ad8362f
commit c32f133236

View file

@ -403,7 +403,8 @@ fn insert_use_(
.take_while(|child| match child {
NodeOrToken::Node(node) => is_inner_attribute(node.clone()),
NodeOrToken::Token(token) => {
[SyntaxKind::WHITESPACE, SyntaxKind::COMMENT].contains(&token.kind())
[SyntaxKind::WHITESPACE, SyntaxKind::COMMENT, SyntaxKind::SHEBANG]
.contains(&token.kind())
}
})
.filter(|child| child.as_token().map_or(true, |t| t.kind() != SyntaxKind::WHITESPACE))