40 examples
Unused import
Imported module never utilized, causing unnecessary dependencies.
[ FAQ1 ]
What is an unused import?
An unused import occurs when a file or module imports dependencies that aren't referenced or utilized anywhere within that file's logic. Such unnecessary imports clutter the codebase, reduce readability, and can lead to slower build or compilation times. Unused imports are commonly introduced during development or refactoring and can be automatically detected by static analysis tools and linters such as ESLint, which flag these imports as unnecessary or "dead."
[ FAQ2 ]
How to remove unused imports
To remove unused imports, regularly run static analysis or linting tools like ESLint to automatically identify and highlight these redundant dependencies. Utilize automated code formatters or IDE plugins that can quickly detect and remove unused imports during file saving or code review. Perform periodic manual reviews and refactoring sessions to maintain a clean, efficient codebase. Keeping imports minimal and relevant helps enhance readability, simplifies maintenance, and improves build performance.
diff block
greptile
logic: Hardcoding Prettier options instead of using prettierConfigPath removes configuration flexibility and makes the unused import on line 17 dead code
suggested fix
+ const options = require(prettierConfigPath);
diff block
greptile
style: Most query nodes are commented out but still imported and referenced in the code. Consider removing unused imports if these nodes will remain disabled.
suggested fix
+ graph.add_node("building_requirements_node", building_requirements_node)
+ graph.add_node("combine_results_node", combine_results_node)
diff block
greptile
style: Optional import is not used anywhere in the code
suggested fix
+from typing import Optional # Remove unused import
diff block
greptile
style: Authentication setup only includes VoidAuth and HttpBearerAuth, but imports unused HttpBasicAuth, ApiKeyAuth, and OAuth. Consider removing unused imports.
diff block
greptile
style: Both definePreview and definePreviewAddon are imported but only definePreviewAddon is used. Remove unused import.
suggested fix
import { definePreviewAddon } from 'storybook/internal/csf';
diff block
greptile
logic: Hardcoding Prettier options instead of using prettierConfigPath removes configuration flexibility and makes the unused import on line 17 dead code
suggested fix
+ const options = require(prettierConfigPath);
diff block
greptile
logic: Hardcoding Prettier options instead of using prettierConfigPath removes configuration flexibility and makes the unused import on line 17 redundant
diff block
greptile
style: All these imports are commented out but referenced in the commented render code below. Either implement the render functionality or remove unused imports.
diff block
greptile
logic: Hardcoding prettier options instead of using prettierConfigPath removes configurability and makes the unused import on line 17 dead code
suggested fix
+ const options = require(prettierConfigPath);
diff block
greptile
style: Remove unused imports: useEffect, useRef, useState.
suggested fix
+import { addons } from '../addons';
diff block
greptile
logic: Hardcoding prettier options instead of using prettierConfigPath removes flexibility and makes the unused import on line 17 dead code
suggested fix
+ const options = require(prettierConfigPath);
diff block
greptile
logic: Hardcoding Prettier options instead of using prettierConfigPath removes configuration flexibility and makes the unused import on line 17 dead code
diff block
greptile
style: Optional is imported but never used in the code
suggested fix
+from typing import Optional # Remove unused import
diff block
greptile
useNavigation hook imported but never used - push is destructured but not utilized
suggested fix
+ // const { push } = useNavigation(); // Removing unused import
diff block
greptile
logic: Hardcoding prettier options instead of using prettierConfigPath removes flexibility and makes the unused import on line 17 dead code
suggested fix
+ const options = require(prettierConfigPath);
diff block
greptile
logic: Hardcoding prettier options instead of using prettierConfigPath removes configurability and makes the unused import on line 17 dead code
suggested fix
+ const options = require(prettierConfigPath);
diff block
greptile
style: react-toastify is imported but never used in the examples. Consider removing this unused import.
suggested fix
diff block
greptile
style: 'Remove unused imports' appears to be duplicated from the Minor Changes section and doesn't fit in the testing checklist
suggested fix
> - Cancelling navigation cancels requests
diff block
greptile
logic: Hardcoding Prettier options instead of using prettierConfigPath removes configuration flexibility and makes the unused import on line 17 dead code
suggested fix
+ const options = require(prettierConfigPath);
diff block
greptile
logic: 'Remove unused imports' is duplicated in the testing checklist but doesn't belong there as it's not something to test
suggested fix
> - Cancelling navigation cancels requests
diff block
greptile
logic: 'Remove unused imports' is misplaced in the testing checklist - it belongs in development tasks, not testing steps
diff block
greptile
style: Several mock imports are unused (patch, mock_open, MagicMock, call, Mock). Remove unused imports.
suggested fix
+from unittest.mock import Mock
diff block
greptile
style: Remove commented out unused imports
suggested fix
diff block
greptile
style: The i18next library and translation keys are imported but not used anywhere in this file. Consider either implementing translations where needed or removing these unused imports.
suggested fix
diff block
greptile
logic: The i18next library is imported but not used anywhere in the component. This creates unused imports which should be removed or utilized.
suggested fix
+import { FiCheck, FiChevronDown, FiXCircle } from "react-icons/fi";
diff block
greptile
logic: i18n is imported but not used anywhere in this component. Consider either implementing the translations or removing the unused import.
suggested fix
diff block
greptile
logic: The i18next and translation keys are imported but never used in the component. This creates unused imports which should either be utilized or removed.
suggested fix
diff block
greptile
logic: Hardcoding prettier options instead of using prettierConfigPath removes configuration flexibility and makes the unused import on line 17 dead code
suggested fix
+ const options = require(prettierConfigPath);
diff block
greptile
logic: Hardcoding Prettier options instead of using prettierConfigPath removes configuration flexibility and makes the unused import on line 17 dead code
diff block
greptile
syntax: Remove unused import 'Info'.
suggested fix
+import { ArrowLeft, Settings } from 'lucide-react';
diff block
greptile
style: Hardcoding Prettier options instead of using prettierConfigPath removes configuration flexibility and makes the unused import on line 17 dead code
suggested fix
+ const options = require(prettierConfigPath);
diff block
greptile
style: Remove commented out unused import
suggested fix
diff block
greptile
logic: Hardcoding Prettier options instead of using prettierConfigPath removes configuration flexibility and makes the unused import on line 17 dead code
suggested fix
+ const options = require(prettierConfigPath);
diff block
greptile
style: Remove unused imports (useEffect, useRef, useState) to clean up the code.
suggested fix
+import { addons } from '../addons';
Want to avoid this bug in your codebase? Try Greptile.
Avoid this bug!