Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Broken useImportType fix when "quickfix.biome": "explicit" is enabled #2268

Closed
1 of 3 tasks
vladkrasn opened this issue Apr 1, 2024 · 5 comments
Closed
1 of 3 tasks

Comments

@vladkrasn
Copy link

VS Code version

1.87.2

Extension version

2,2,2

Biome version

1.6.3

Operating system

  • Windows
  • macOS
  • Linux

Description

When there are many type imports, autofix on save in vscode can be buggy

Steps to reproduce

When useImportType rule is enabled, and vscode extension is configured with "quickfix.biome": "explicit", try to edit following code:

import fs, { BigIntOptions, ReadStream, lchownSync } from "fs";
import { Blob, File, Buffer} from "buffer"

const a: fs;
const b: BigIntOptions;
const c: lchownSync;
const d: Blob;
const e: File;

The result will be

import type fs from "fs";
import { type type BtIntOptions, ReadStream, type lchownSync } from "fs"
import { Blob, File, Buffer} from "buffer"

const a: fs;
const b: BigIntOptions;
const c: lchownSync;
const d: Blob;
const e: File;

You can continue pressing ctrl+s, and the code will become more and more broken. The issue seems to be exacerbated the more you mix imports that are supposed to be types and are not supposed to be them.

Expected behavior

Cli seems to be applying type to imports correctly. Vscode extension should behave like cli

Does this issue occur when using the CLI directly?

No

Logs

No response

@Sec-ant Sec-ant transferred this issue from biomejs/biome-vscode Apr 2, 2024
@Sec-ant
Copy link
Member

Sec-ant commented Apr 2, 2024

Duplicate of #1550 and #1570. I just tested your code and this will be fixed in #2237.

@Sec-ant Sec-ant closed this as not planned Won't fix, can't repro, duplicate, stale Apr 2, 2024
@vladkrasn
Copy link
Author

@Sec-ant , was it supposed to be fixed in 1.6.4? While it's certainly better now, the code above is still broken after format

import type fs from "fs";
import { type BigIntOptions, lchownSync }type  from "fs";
import { type Blob, type File, } from "buffer"

const a: fs;
const b: BigIntOptions;
const c: lchownSync;
const d: Blob;
const e: File;

@Sec-ant
Copy link
Member

Sec-ant commented Apr 3, 2024

@Sec-ant , was it supposed to be fixed in 1.6.4? While it's certainly better now, the code above is still broken after format

import type fs from "fs";
import { type BigIntOptions, lchownSync }type  from "fs";
import { type Blob, type File, } from "buffer"

const a: fs;
const b: BigIntOptions;
const c: lchownSync;
const d: Blob;
const e: File;

I added a demo to show this is fixed in #2237. I don't see any issues when quickfix.biome is enabled (see Test Plan), do you have other settings (maybe formatting) involved?

@Sec-ant
Copy link
Member

Sec-ant commented Apr 3, 2024

Wait, I can reproduce the issue... I don't know why it works well on that PR branch... please give me some time to debug. 😢

@vladkrasn
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants