Giter Club home page Giter Club logo

eslint-plugin-replace-relative-imports's Introduction

eslint-plugin-replace-relative-imports-fork

This plugin replaces relative parent imports with a defined alias and is meant to be used in conjunction with applications built with either webpack alias definitions or paths for typescript.

STATUS

Upstream repository seems not supported anymore, therefore this fork exist. This repo and package will be removed when upstream repository catch up with all bug fixes / improvements.

Usage

Add replace-relative-imports-fork to the plugins section of your eslint configuration.

{
  "plugins": ["replace-relative-imports-fork"]
}

Then add the replace imports rule:

{
  "rules": {
    "replace-relative-imports-fork/replace": ["error", {
      "aliases": [
        { "name": "app", "path": "./src" }
      ]
    }]
  }
}

Configuration

The aliases object is required in the configuration. You may define multiple aliases. If an alias is not found for a specific import, an error will be thrown for that import.

You may also specify blobs in the ignore array in order to ignore specific files.

You may also specify list of imports in the excludeImports array in order to ignore specific import paths.

Options:

name description default
alias (required) The list of aliases which will be matched for and replaced
method The type of replacement, either all relative paths (./ included) or only parent imports (importPath.startsWith('../')) "only-parent"
ignore List of blobs which this rule should ignore []
excludeImports List of import paths which should not be covered by this rule []

Example:

{
  "rules": {
    "replace-relative-imports-fork/replace": ["error", {
      "ignore": ["**/__tests__/*"],
      "excludeImports": [
        "@/utils/any",
        "./any",
        "../utils/any"
      ],
      "aliases": [
        { "name": "app", "path": "./src" }
      ]
    }]
  }
}

License

MIT

eslint-plugin-replace-relative-imports's People

Contributors

joshmadewell avatar levchak0910 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.