Skip to content

Commit ef46cd3

Browse files
authored
[TEST] Add test cases (import-js#4)
Added some test cases to sanity check the config.
1 parent b72325c commit ef46cd3

11 files changed

+1485
-9
lines changed

README.md

+32-8
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,47 @@
11
# eslint-import-resolver-typescript
22

3-
This plugin allows you to resolve `typescript` files with `eslint-plugin-import`.
3+
This plugin adds typescript support to [`eslint-plugin-import`](https://www.npmjs.com/package/eslint-plugin-import).
44

5-
The resolution respects the [`paths`](https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping) you have defined in your `tsconfig.json`.
5+
This means you can:
66

7-
![](screenshot.png)
7+
- `import`/`require` files with extension `.ts`/`.tsx` **without** using `--ext`!
8+
- Use [`paths`](https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping) defined in `tsconfig.json`.
89

910
## Installation
1011

1112
```bash
12-
npm install --save-dev eslint-import-resolver-typescript
13+
npm install --save-dev eslint-plugin-import typescript-eslint-parser eslint-import-resolver-typescript
1314
```
1415

15-
Add the following to your eslint config:
16+
## Configuration
17+
18+
Add the following to your `.eslintrc` config:
1619

1720
```JSON
18-
"settings": {
19-
"import/resolver": {
20-
"typescript": true
21+
{
22+
"settings": {
23+
"parser": "typescript-eslint-parser",
24+
"plugins": [
25+
"import"
26+
],
27+
"rules": {
28+
// turn on errors for missing imports
29+
"import/no-unresolved": "error"
30+
},
31+
"import/resolver": {
32+
// use <root>/tsconfig.json
33+
"typescript": {},
34+
35+
// use <root>/path/to/folder/tsconfig.json
36+
"typescript": {
37+
"directory": "./path/to/folder"
38+
}
39+
}
2140
}
2241
}
2342
```
43+
44+
## Contributing
45+
46+
- Make sure your change is covered by a test import.
47+
- Make sure that `npm test` passes without a failure.

0 commit comments

Comments
 (0)