Skip to content

Turn on unused-imports/no-unused-imports#54953

Merged
bl-nero merged 3 commits intomasterfrom
bl-nero/delete-unused-imports
May 27, 2025
Merged

Turn on unused-imports/no-unused-imports#54953
bl-nero merged 3 commits intomasterfrom
bl-nero/delete-unused-imports

Conversation

@bl-nero
Copy link
Copy Markdown
Contributor

@bl-nero bl-nero commented May 20, 2025

This allows removing unused imports automatically when executing pnpm lint-fix.

Requires https://github.com/gravitational/teleport.e/pull/6548

This is a final PR of a 3-PR train. Since I don't want to babysit 9 PRs + e/ updates just for that, I'll prepare backports separately.

@bl-nero bl-nero added the no-changelog Indicates that a PR does not require a changelog entry label May 20, 2025
Copy link
Copy Markdown
Member

@ravicious ravicious left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking care of this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a small issue but it has more to do with my editor rather than the ESLint plugin. I'm posting this in case other people run into this problem.

I run both Prettier and ESLint autofix on save. Prettier seems to run first, which doesn't seem to make sense, given that ESLint is able to modify the file after Prettier finishes. Which is exactly what happens in certain scenarios.

For example, if I append AgentCompatibilityError to the list of imported values here…

import { useConnectMyComputerContext } from '../connectMyComputerContext';

…what ends up happening is that Prettier first transforms the import statement into a multi-line statement and then the ESLint plugin removes the import of AgentCompatibilityError. On the next save, the import statement is transformed back into a single-line statement. But the first save results in a file that's considered by Prettier to not be formatted.

@bl-nero
Copy link
Copy Markdown
Contributor Author

bl-nero commented May 20, 2025

Note: I'll need to split this PR in two, because otherwise, there's no other way to include necessary changes to e/ without breaking the build.

This allows removing unused imports automatically when executing `pnpm lint-fix`.
@bl-nero bl-nero force-pushed the bl-nero/delete-unused-imports branch from 0a8b9a0 to 96cdd93 Compare May 20, 2025 13:28
@bl-nero bl-nero marked this pull request as ready for review May 20, 2025 13:31
@bl-nero bl-nero requested review from avatus and gzdunek as code owners May 20, 2025 13:31
@bl-nero bl-nero changed the title Add eslint-plugin-unused-imports Turn on unused-imports/no-unused-imports May 20, 2025
@public-teleport-github-review-bot public-teleport-github-review-bot bot removed the request for review from flyinghermit May 20, 2025 13:37
@bl-nero bl-nero changed the base branch from master to bl-nero/add-unused-imports-plugin May 20, 2025 14:05
@public-teleport-github-review-bot public-teleport-github-review-bot bot removed the request for review from avatus May 20, 2025 14:05
Base automatically changed from bl-nero/add-unused-imports-plugin to master May 20, 2025 14:19
@bl-nero bl-nero enabled auto-merge May 27, 2025 06:13
@bl-nero bl-nero added this pull request to the merge queue May 27, 2025
Merged via the queue into master with commit ad0734f May 27, 2025
40 checks passed
@bl-nero bl-nero deleted the bl-nero/delete-unused-imports branch May 27, 2025 06:32
bl-nero added a commit that referenced this pull request May 28, 2025
* Add eslint-plugin-unused-imports

* Turn on unused-imports/no-unused-imports

This allows removing unused imports automatically when executing `pnpm lint-fix`.
smallinsky pushed a commit that referenced this pull request May 29, 2025
* Add eslint-plugin-unused-imports

* Turn on unused-imports/no-unused-imports

This allows removing unused imports automatically when executing `pnpm lint-fix`.
github-merge-queue bot pushed a commit that referenced this pull request Jun 6, 2025
* Add eslint-plugin-unused-imports (#54955)

* Turn on unused-imports/no-unused-imports (#54953)

* Add eslint-plugin-unused-imports

* Turn on unused-imports/no-unused-imports

This allows removing unused imports automatically when executing `pnpm lint-fix`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog Indicates that a PR does not require a changelog entry size/sm ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants