You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It happened a lot of times to me when I refactor multi-component modules to single-components. I guess it has to to with removing unused types & imports at the same time.
When I remove the components, I save & format with Biome and the result is a wrongly formatted file. It removes parts of import lines which break the rest of the formatting.
Steps to reproduce
Take this snippet
import{FieldasHeadlessField,typeFieldPropsasHeadlessFieldProps,RadioasHeadlessRadio,// unusedRadioGroupasHeadlessRadioGroup,// unusedtypeRadioGroupPropsasHeadlessRadioGroupProps,// unusedtypeRadioPropsasHeadlessRadioProps,// unused}from"@headlessui/react";importtype{VariantProps}from"class-variance-authority";// unusedimport{classNames}from"../../utils/classNames";import{radioVariants}from"./variants";// unusedexportfunctionRadioField({ className, ...props}: HeadlessFieldProps){return(<HeadlessFielddata-slot="field"{...props}className={classNames(className,// Base layout"grid grid-cols-[1.125rem_1fr] items-center gap-x-4 gap-y-1 sm:grid-cols-[1rem_1fr]",// Control layout"[&>[data-slot=control]]:col-start-1 [&>[data-slot=control]]:row-start-1 [&>[data-slot=control]]:justify-self-center",// Label layout"[&>[data-slot=label]]:col-start-2 [&>[data-slot=label]]:row-start-1 [&>[data-slot=label]]:justify-self-start",// Description layout"[&>[data-slot=description]]:col-start-2 [&>[data-slot=description]]:row-start-2",// With description"[&_[data-slot=label]]:has-[[data-slot=description]]:font-medium",)}/>);}
Save & Format with VS Code
Here's the result
import{FieldasHeadlessField,typeFieldPropsasHeadlessFieldProps,RadioGroupasHeadlessRadioGroup,typeRadioPropsasHeadlessRadioProps,}fromtype{VariantProps}from"class-variance-authority";import{radioVariants}from"./variants";exportn(<HeadlessField{...props}className={classNames(className,// Base layout"grid grid-cols-[1.125rem_1fr] items-center gap-x-4 gap-y-1 sm:grid-cols-[1rem_1fr]",// Control layout"[&>[data-slot=control]]:col-start-1 [&>[data-slot=control]]:row-start-1 [&>[data-slot=control]]:justify-self-center",// Label layout"[&>[data-slot=label]]:col-start-2 [&>[data-slot=label]]:row-start-1 [&>[data-slot=label]]:justify-self-start",// Description layout"[&>[data-slot=description]]:col-start-2 [&>[data-slot=description]]:row-start-2",// With description"[&_[data-slot=label]]:has-[[data-slot=description]]:font-medium",)}/>);}
Expected behavior
When I run with Biome's CLI, it properly format the module :
import{FieldasHeadlessField,typeFieldPropsasHeadlessFieldProps,}from"@headlessui/react";import{classNames}from"../../utils/classNames";exportfunctionRadioField({ className, ...props}: HeadlessFieldProps){return(<HeadlessFielddata-slot="field"{...props}className={classNames(className,// Base layout"grid grid-cols-[1.125rem_1fr] items-center gap-x-4 gap-y-1 sm:grid-cols-[1rem_1fr]",// Control layout"[&>[data-slot=control]]:col-start-1 [&>[data-slot=control]]:row-start-1 [&>[data-slot=control]]:justify-self-center",// Label layout"[&>[data-slot=label]]:col-start-2 [&>[data-slot=label]]:row-start-1 [&>[data-slot=label]]:justify-self-start",// Description layout"[&>[data-slot=description]]:col-start-2 [&>[data-slot=description]]:row-start-2",// With description"[&_[data-slot=label]]:has-[[data-slot=description]]:font-medium",)}/>);}
It also works correctly if I Quick Fix: "Delete all unused imports".
Does this issue occur when using the CLI directly?
No
Logs
Nothing in the Biome Trace output.
In Biome output:
[Warn - 09:56:30] Code formatting aborted due to parsing errors. To format code with errors, enable the 'formatter.formatWithErrors' option.
The text was updated successfully, but these errors were encountered:
VS Code version
1.87.2
Extension version
2.2.2
Biome version
1.6.1
Operating system
Description
It happened a lot of times to me when I refactor multi-component modules to single-components. I guess it has to to with removing unused types & imports at the same time.
When I remove the components, I save & format with Biome and the result is a wrongly formatted file. It removes parts of
import
lines which break the rest of the formatting.Steps to reproduce
Expected behavior
When I run with Biome's CLI, it properly format the module :
It also works correctly if I Quick Fix: "Delete all unused imports".
VS Code Settings :
Does this issue occur when using the CLI directly?
No
Logs
The text was updated successfully, but these errors were encountered: