Skip to content

Conversation

@charliecreates
Copy link

@charliecreates charliecreates bot commented May 1, 2025

This pull request enables the automatic detection and removal of unused imports when running ESLint in fix mode, addressing linter and code cleanliness requirements.

Key changes:

  • Adds and configures the eslint-plugin-unused-imports plugin for ESLint in config/eslint.js.
  • Sets the unused-imports/no-unused-imports and unused-imports/no-unused-vars rules to ERROR and configures them to ignore underscores, ensuring unused imports and variables are removed during linting with --fix.
  • Disables the core no-unused-vars rule that would conflict with the new plugin.
  • Adds eslint-plugin-unused-imports as a dependency in the package.json file.

With this configuration, running eslint --fix or the relevant fix command removes unused import statements automatically, improving code hygiene with no manual intervention.

Resolves #2.

…in-unused-imports

Add `eslint-plugin-unused-imports` to dependencies and ESLint configuration to automatically detect and remove unused imports via `eslint --fix`. Updated config to import the plugin and set `'unused-imports/no-unused-imports'` and `'unused-imports/no-unused-vars'` as new rules, superseding the default `no-unused-vars`. This improves code cleanliness and reduces manual effort in managing imports. Existing `no-unused-vars` remains off to avoid conflicts.
@charliecreates charliecreates bot requested a review from CharlieHelps May 1, 2025 15:57
Copy link
Author

@charliecreates charliecreates bot left a comment

Choose a reason for hiding this comment

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

No obvious issues detected; the new plugin is imported and configured correctly, and the core no-unused-vars rule is disabled to prevent conflicts.

Summary of changes

ESLint Configuration Update

  • Added eslint-plugin-unused-imports to the ESLint plugins section via dynamic import.
  • Enabled two rules from the new plugin:
    • unused-imports/no-unused-imports: set to ERROR for automatic removal of unused imports.
    • unused-imports/no-unused-vars: set to ERROR with patterns to ignore variables and arguments prefixed with _.
  • Disabled the core no-unused-vars rule to avoid conflicts.

Dependency Update

  • Added eslint-plugin-unused-imports version ^3.1.1 to package.json dependencies.

@charliecreates charliecreates bot removed the request for review from CharlieHelps May 1, 2025 15:58
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

Successfully merging this pull request may close these issues.

Automatically remove unused imports

2 participants