Skip to content

Commit 64c0823

Browse files
joaovieiraljharb
authored andcommitted
[fix] TypeScript config: lookup for external modules in @types folder
1 parent 4e8960d commit 64c0823

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

CHANGELOG.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
77
## [Unreleased]
88
### Fixed
99
- [`no-unused-modules`]: fix usage of `import/extensions` settings ([#1560], thanks [@stekycz])
10-
11-
### Fixed
1210
- [`import/extensions`]: ignore non-main modules ([#1563], thanks [@saschanaz])
11+
- TypeScript config: lookup for external modules in @types folder ([#1526], thanks [@joaovieira])
1312

1413
## [2.19.1] - 2019-12-08
1514
### Fixed
@@ -629,6 +628,7 @@ for info on changes for earlier releases.
629628
[#1560]: https://github.com/benmosher/eslint-plugin-import/pull/1560
630629
[#1551]: https://github.com/benmosher/eslint-plugin-import/pull/1551
631630
[#1542]: https://github.com/benmosher/eslint-plugin-import/pull/1542
631+
[#1526]: https://github.com/benmosher/eslint-plugin-import/pull/1526
632632
[#1521]: https://github.com/benmosher/eslint-plugin-import/pull/1521
633633
[#1519]: https://github.com/benmosher/eslint-plugin-import/pull/1519
634634
[#1507]: https://github.com/benmosher/eslint-plugin-import/pull/1507
@@ -1046,3 +1046,4 @@ for info on changes for earlier releases.
10461046
[@randallreedjr]: https://github.com/randallreedjr
10471047
[@Pessimistress]: https://github.com/Pessimistress
10481048
[@stekycz]: https://github.com/stekycz
1049+
[@joaovieira]: https://github.com/joaovieira

config/typescript.js

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module.exports = {
88

99
settings: {
1010
'import/extensions': allExtensions,
11+
'import/external-module-folders': ['node_modules', 'node_modules/@types'],
1112
'import/parsers': {
1213
'@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'],
1314
},

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"pretest": "linklocal",
2222
"posttest": "eslint .",
2323
"mocha": "cross-env BABEL_ENV=test NODE_PATH=./src nyc -s mocha -R dot --recursive -t 5s",
24-
"test": "npm run mocha tests/src",
24+
"test": "npm run mocha tests/{src,config}",
2525
"test-compiled": "npm run prepublish && NODE_PATH=./lib mocha --compilers js:babel-register --recursive tests/src",
2626
"test-all": "npm test && for resolver in ./resolvers/*; do cd $resolver && npm test && cd ../..; done",
2727
"prepublish": "npm run build",

tests/config/typescript.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import path from 'path'
2+
import { expect } from 'chai'
3+
4+
const config = require(path.join(process.cwd(), 'config', 'typescript'))
5+
6+
describe('config typescript', () => {
7+
// https://github.com/benmosher/eslint-plugin-import/issues/1525
8+
it('should mark @types paths as external', () => {
9+
const externalModuleFolders = config.settings['import/external-module-folders']
10+
expect(externalModuleFolders).to.exist
11+
expect(externalModuleFolders).to.contain('node_modules')
12+
expect(externalModuleFolders).to.contain('node_modules/@types')
13+
})
14+
})

0 commit comments

Comments
 (0)