Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-unused-imports

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-unused-imports

Report and remove unused es6 modules

  • 4.1.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is eslint-plugin-unused-imports?

The eslint-plugin-unused-imports npm package is designed to help developers identify and remove unused imports in their JavaScript or TypeScript code. This can help to keep codebases clean and reduce the size of the final bundle by eliminating unnecessary code.

What are eslint-plugin-unused-imports's main functionalities?

Removing unused variables

This feature automatically detects and removes variables that are imported but never used in the code. The code sample shows how an unused import would be identified.

/* eslint-disable no-unused-vars */
import { usedFunction, unusedFunction } from 'my-module';
usedFunction();

Removing unused imports

This feature detects and suggests the removal of entire import statements when none of the imported bindings are used. In the code sample, 'useState' would be identified as an unused import.

import React, { useState } from 'react';
const MyComponent = () => {
  return <div>Hello World</div>;
};
export default MyComponent;

Auto-fixing on save

The plugin can be configured to automatically fix issues on save, removing unused imports without manual intervention. The code sample shows the ESLint configuration to enable this feature.

// .eslintrc.js
module.exports = {
  plugins: ['unused-imports'],
  rules: {
    'unused-imports/no-unused-imports': 'error',
  },
};

Other packages similar to eslint-plugin-unused-imports

Keywords

FAQs

Package last updated on 13 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc