UNPKG

2.24 kBMarkdownView Raw
1# eslint-import-resolver-babel-module
2[![npm][npm-version-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coverage Status][coverage-image]][coverage-url]
3
4A [babel-plugin-module-resolver][babel-plugin-module-resolver] resolver for [eslint-plugin-import][eslint-plugin-import]
5
6## Installation
7
8```sh
9npm install --save-dev eslint-plugin-import eslint-import-resolver-babel-module
10```
11
12## Usage
13
14Inside your `.eslintrc` file, pass this resolver to `eslint-plugin-import`:
15```
16"settings": {
17 "import/resolver": {
18 "babel-module": {}
19 }
20}
21```
22
23And see [babel-plugin-module-resolver][babel-plugin-module-resolver] to know how to configure your aliases.
24
25### Example
26
27```json
28{
29 "extends": "airbnb",
30 "rules": {
31 "comma-dangle": 0
32 },
33 "settings": {
34 "import/resolver": {
35 "babel-module": {}
36 }
37 }
38}
39```
40
41## Directory Imports
42
43Some babel plugins like [babel-plugin-import-directory](https://github.com/Anmo/babel-plugin-import-directory) or [babel-plugin-wildcard](https://github.com/vihanb/babel-plugin-wildcard) allow to import directories (i.e. each file inside a directory) as an object. In order to support this, you can activate the `allowExistingDirectories` option as follows:
44
45```
46"settings": {
47 "import/resolver": {
48 "babel-module": { allowExistingDirectories: true }
49 }
50}
51```
52
53Now when you import a directory like this, the ESLint plugin won't complain and recognize the existing directory:
54
55```
56import * as Items from './dir';
57```
58
59## License
60
61MIT, see [LICENSE.md](/LICENSE.md) for details.
62
63
64[ci-image]: https://circleci.com/gh/tleunen/eslint-import-resolver-babel-module.svg?style=shield
65[ci-url]: https://circleci.com/gh/tleunen/eslint-import-resolver-babel-module
66[coverage-image]: https://codecov.io/gh/tleunen/eslint-import-resolver-babel-module/branch/master/graph/badge.svg
67[coverage-url]: https://codecov.io/gh/tleunen/eslint-import-resolver-babel-module
68[npm-version-image]: https://img.shields.io/npm/v/eslint-import-resolver-babel-module.svg
69[npm-url]: https://www.npmjs.com/package/eslint-import-resolver-babel-module
70[babel-plugin-module-resolver]: https://github.com/tleunen/babel-plugin-module-resolver
71[eslint-plugin-import]: https://github.com/benmosher/eslint-plugin-import