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

🐛 fix of lint/nursery/noUnusedImports does not work correctly #688

Closed
1 task done
atheck opened this issue Nov 8, 2023 · 11 comments · Fixed by #2237
Closed
1 task done

🐛 fix of lint/nursery/noUnusedImports does not work correctly #688

atheck opened this issue Nov 8, 2023 · 11 comments · Fixed by #2237
Assignees
Labels
A-Analyzer Area: analyzer L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug S-Help-wanted Status: you're familiar with the code base and want to help the project

Comments

@atheck
Copy link

atheck commented Nov 8, 2023

Environment information

CLI:
  Version:                      1.3.3
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           windows

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         unset
  JS_RUNTIME_VERSION:           "v20.9.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "npm/10.2.3"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 true

Workspace:
  Open Documents:               0

What happened?

I have unused imports in my file. Here, ToolbarAction and createOverflowMenuAction are not used.

import { Patterns, ToolbarAction, createOverflowMenuAction } from "@lib/Patterns";

When saving this file with the settings:

"editor.codeActionsOnSave": {
  "quickfix.biome": true,
  "source.organizeImports.biome": true
},

the result is:

import { Patterns, createOverflowMtterns";

Expected result

The result should be:

import { Patterns } from "@lib/Patterns";

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@ematipico ematipico added L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug A-Analyzer Area: analyzer labels Nov 8, 2023
@TaKO8Ki
Copy link
Contributor

TaKO8Ki commented Nov 12, 2023

Can I work on this issue?

@nissy-dev
Copy link
Contributor

@TaKO8Ki Yes! I assigned.

@Conaclos
Copy link
Member

@TaKO8Ki Are you still interest in? Otherwise, I would like to fix the issue :)

@TaKO8Ki
Copy link
Contributor

TaKO8Ki commented Dec 13, 2023

@Conaclos I have already identified the cause and just need to make the correction, but I haven't had time to work on it recently and have left it unattended. Could I have another 2-3 days? The issue is with the consecutive application of autofix. For example, when applying an autofix consecutively to remove the spans of ToolbarAction and createOverflowMenuAction from:

import { Patterns, ToolbarAction, createOverflowMenuAction } from "@lib/Patterns";

The createOverflowMenuAction span for the second autofix shifts because the first autofix for ToolbarAction has already been applied. This needs to be resolved.

@Conaclos
Copy link
Member

No urgencies, take your time :) All yours :)

@almeidx
Copy link

almeidx commented Jan 4, 2024

Not sure if this is the same issue, but something similar also happens with separate imports:

import { func1 } from "./func1";
import { func2 } from "./func2";
import { func3 } from "./func3";
import { func4 } from "./func4";

func2();

is auto fixed to

import { func2 } from "./func2";
import { func3 } from "./func3";
import { 

@Conaclos
Copy link
Member

#1015 could be related to the current issue.

@ematipico
Copy link
Member

@TaKO8Ki are you still interested?

@TaKO8Ki
Copy link
Contributor

TaKO8Ki commented Jan 23, 2024

@ematipico I will push my WIP implementation later!

@ematipico ematipico added the S-Help-wanted Status: you're familiar with the code base and want to help the project label Feb 2, 2024
@mdm317
Copy link
Contributor

mdm317 commented Feb 9, 2024

When i try below two case

import { Patterns, ToolbarAction, createOverflowMenuAction } from "@lib/Patterns";

and

import { func1 } from "./func1";
import { func2 } from "./func2";
import { func3 } from "./func3";
import { func4 } from "./func4";

func2();

This two case work fine

but this issue case could lead to the deletion of a large amount of code during formatting.
this is simple example code

import { foo } from 'mod'
const b = {
foo()

How about disabling noUnusedImports when the syntax is invalid?
If you agree with my opinion, may I handle this issue?

@atheck
Copy link
Author

atheck commented Feb 10, 2024

Isn't there a biome setting to disable formatting with errors?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Analyzer Area: analyzer L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug S-Help-wanted Status: you're familiar with the code base and want to help the project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants