# eslint-import-resolver-localalias

> A simple Node behavior import resolution plugin for eslint-plugin-import, supporting module alias with local project modules and node_modules.

Latest version **2.0.9-1** (published 2018-06-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install eslint-import-resolver-localalias
pnpm add eslint-import-resolver-localalias
yarn add eslint-import-resolver-localalias
bun add eslint-import-resolver-localalias
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.9-1 |
| Published | 2018-06-20 |
| First published | 2018-06-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 6 |
| Dependencies | 0 |
| Unpacked size | 8.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mikhail Privalov |
| Maintainers | moodpulse |
| Keywords | eslint, eslintplugin, modules, alias, eslint-plugin-import, import-resolver |

## Links

- npm: https://www.npmjs.com/package/eslint-import-resolver-localalias
- Repository: https://github.com/moodpulse/eslint-import-resolver-localalias
- Homepage: https://github.com/moodpulse/eslint-import-resolver-localalias#readme
- Issues: https://github.com/moodpulse/eslint-import-resolver-localalias/issues
- npm.io page: https://npm.io/package/eslint-import-resolver-localalias

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@inrupt/eslint-config-base](https://npm.io/package/@inrupt/eslint-config-base.md) — 4.5K weekly downloads

## Recent versions

- 2.0.9-1 (latest) — 2018-06-20
- 2.0.9 — 2018-06-20
- 2.0.8 — 2018-06-20
- 2.0.7 — 2018-06-20
- 2.0.6 — 2018-06-20
- 2.0.5 — 2018-06-20
- 2.0.4 — 2018-06-20
- 2.0.3 — 2018-06-20
- 2.0.2 — 2018-06-20

## README

# eslint-import-resolver-localalias

[![Version npm][version]](http://browsenpm.org/package/eslint-import-resolver-localalias)
[![Build Status][build]](https://travis-ci.org/moodpulse/eslint-import-resolver-localalias)
[![Download][download]](https://www.npmjs.com/package/eslint-import-resolver-localalias)
[![Dependencies][david]](https://david-dm.org/moodpulse/eslint-import-resolver-localalias)
[![Coverage Status][cover]](https://coveralls.io/github/moodpulse/eslint-import-resolver-localalias?branch=master)
[![License][license]](https://opensource.org/licenses/MIT)

[version]: http://img.shields.io/npm/v/eslint-import-resolver-localalias.svg?style=flat-square
[build]: http://img.shields.io/travis/moodpulse/eslint-import-resolver-localalias/master.svg?style=flat-square
[download]: https://img.shields.io/npm/dm/eslint-import-resolver-localalias.svg?style=flat-square
[david]: https://img.shields.io/david/moodpulse/eslint-import-resolver-localalias.svg?style=flat-square
[cover]: http://img.shields.io/coveralls/moodpulse/eslint-import-resolver-localalias/master.svg?style=flat-square
[license]: https://img.shields.io/badge/License-MIT-brightgreen.svg?style=flat-square


This is a simple Node.js module import resolution plugin for [`eslint-plugin-import`](https://www.npmjs.com/package/eslint-plugin-import), which supports native Node.js module resolution, module alias and custom file extensions. Also supports aliases for project modules.


## Installation

Prerequisites: Node.js >=6.x and corresponding version of npm.

```shell
npm install eslint-plugin-import eslint-import-resolver-localalias --save-dev
```


## Usage

Pass this resolver and its parameters to `eslint-plugin-import` using your `eslint` config file, `.eslintrc` or `.eslintrc.js`.

```js
// .eslintrc.js
module.exports = {
  settings: {
    'import/resolver': {
      localalias: {
        map: [
          ['babel-polyfill', 'babel-polyfill/dist/polyfill.min.js'],
          ['helper', './utils/helper'],
          ['material-ui/DatePicker', '../custom/DatePicker'],
          ['material-ui', 'material-ui-ie10'],
          ['@project-module', 'module/path/'],
          ['project-module2', 'module2']
        ],
        extensions: ['.ts', '.js', '.jsx', '.json']
      }
    }
  }
};
```

Note:

- The alias config object contains two properties, `map` and `extensions`, both of which are array types
- The item of `map` array is also array type which contains 2 string
    + The first string represents the mapped module name or path
    + The second string represents the module alias, the actual module path or name
- The `map` item `['helper', './utils/helper']` means that the module `helper/*` will be resolved to `./utils/helper/*`. See [#3](https://github.com/moodpulse/eslint-import-resolver-localalias/issues/3)
- The order of 'material-ui/DatePicker' and 'material-ui' cannot be reversed, otherwise the alias rule 'material-ui/DatePicker' does not work
- The default value of `extensions` property is `['.js', '.json', '.node']` if it is assigned to an empty array or not specified.

*If the `extensions` property is not specified, the config object can be simplified to the `map` array.*

```js
// .eslintrc.js
module.exports = {
  settings: {
    'import/resolver': {
      localalias: [
        ['babel-polyfill', 'babel-polyfill/dist/polyfill.min.js'],
        ['helper', './utils/helper'],
        ['material-ui/DatePicker', '../custom/DatePicker'],
        ['material-ui', 'material-ui-ie10'],
        ['@project-module', 'module/path/'],
        ['project-module2', 'module2']
      ]
    }
  }
};
```

When the config is not a valid object (such as `true`), the resolver falls back to native Node.js module resolution.

```js
// .eslintrc.js
module.exports = {
  settings: {
    'import/resolver': {
      alias: true
    }
  }
};
```

---
_Source: https://npm.io/package/eslint-import-resolver-localalias · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
