New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-custom-aliases

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-custom-aliases

ESLint plugin to detect and auto-fix useless long imports and suggest replacements using aliases. Developed by financesaucer for 0xos project.

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

eslint-plugin-detect-incorrect-imports

ESLint plugin to detect and auto-fix useless long imports and suggest replacements using aliases. Developed by financesaucer for 0xos project.

Installation

npm install eslint-plugin-custom-aliases --save-dev

or

yarn add eslint-plugin-custom-aliases --dev

Usage

In your ESLint configuration, add detect-incorrect-imports to the plugins section and configure the rule under rules.

{
  "plugins": ["custom-aliases"],
  "rules": {
    "custom-aliases/detect-incorrect-imports": [
         "error", 
         { "aliases":
          { /* Add your aliases here */ 
          "alias" : "pattern to replace",
          "alias" : ["patterns to replace"],

          } 
          } 
    ]
  }
}

Rule Details

This rule checks imports and suggests replacements using defined aliases. If an import matches an alias pattern, it recommends using the alias.

Options

aliases (required): An object where keys are aliases and values are corresponding patterns.

Examples

Suppose you have the following configuration:

in your .eslintrc:

{
  "plugins": ["custom-aliases"],
  rules: {
        'custom-aliases/detect-incorrect-imports':
      ['error', {
          aliases: {
              '@src': '../src/',
              '@components': ['../src/components/', '../components/'],
          // Add more aliases and patterns as needed
          // IE: 'alias' : 'pattern'
          // IE: 'alias' : ['pattern1', 'pattern2' ...]
          },
      }],
}

With the above configuration, the rule will suggest using the @src alias for imports from the ../src/ or ../../../src/ directory etc. It will also auto-fix the import paths when running eslint --fix

Contributing

  • Fork the repository and clone it to your local machine.
  • Create a new branch for your feature: git checkout -b my-feature.
  • Commit your changes: git commit -m 'Add my feature'.
  • Push to the branch: git push origin my-feature.
  • Open a pull request on GitHub.

License

This project is licensed under the MIT License - see the LICENSE file for details.

FAQs

Package last updated on 28 Sep 2023

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