Skip to content

Commit

Permalink
[fix] TypeScript config: lookup for external modules in @types folder
Browse files Browse the repository at this point in the history
  • Loading branch information
joaovieira authored and ljharb committed Oct 29, 2019
1 parent 4e8960d commit 34b1574
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
## [Unreleased]
### Fixed
- [`no-unused-modules`]: fix usage of `import/extensions` settings ([#1560], thanks [@stekycz])

### Fixed
- [`import/extensions`]: ignore non-main modules ([#1563], thanks [@saschanaz])
- TypeScript config: lookup for external modules in @types folder ([#1526], thanks [@joaovieira])

## [2.19.1] - 2019-12-08
### Fixed
Expand Down Expand Up @@ -629,6 +628,7 @@ for info on changes for earlier releases.
[#1560]: https://github.com/benmosher/eslint-plugin-import/pull/1560
[#1551]: https://github.com/benmosher/eslint-plugin-import/pull/1551
[#1542]: https://github.com/benmosher/eslint-plugin-import/pull/1542
[#1526]: https://github.com/benmosher/eslint-plugin-import/pull/1526
[#1521]: https://github.com/benmosher/eslint-plugin-import/pull/1521
[#1519]: https://github.com/benmosher/eslint-plugin-import/pull/1519
[#1507]: https://github.com/benmosher/eslint-plugin-import/pull/1507
Expand Down Expand Up @@ -1046,3 +1046,4 @@ for info on changes for earlier releases.
[@randallreedjr]: https://github.com/randallreedjr
[@Pessimistress]: https://github.com/Pessimistress
[@stekycz]: https://github.com/stekycz
[@joaovieira]: https://github.com/joaovieira
1 change: 1 addition & 0 deletions config/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {

settings: {
'import/extensions': allExtensions,
'import/external-module-folders': ['node_modules', 'node_modules/@types'],
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'],
},
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
"scripts": {
"build": "babel --quiet --out-dir lib src",
"prebuild": "rimraf lib",
"watch": "npm run mocha -- --watch tests/src",
"watch": "npm run mocha -- --watch tests/{src,config}",
"pretest": "linklocal",
"posttest": "eslint .",
"mocha": "cross-env BABEL_ENV=test NODE_PATH=./src nyc -s mocha -R dot --recursive -t 5s",
"test": "npm run mocha tests/src",
"test": "npm run mocha tests/{src,config}",
"test-compiled": "npm run prepublish && NODE_PATH=./lib mocha --compilers js:babel-register --recursive tests/src",
"test-all": "npm test && for resolver in ./resolvers/*; do cd $resolver && npm test && cd ../..; done",
"prepublish": "npm run build",
Expand Down
14 changes: 14 additions & 0 deletions tests/config/typescript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import path from 'path'
import { expect } from 'chai'

const config = require(path.join(__dirname, '..', '..', 'config', 'typescript'))

describe('config typescript', () => {
// https://github.com/benmosher/eslint-plugin-import/issues/1525
it('should mark @types paths as external', () => {
const externalModuleFolders = config.settings['import/external-module-folders']
expect(externalModuleFolders).to.exist
expect(externalModuleFolders).to.contain('node_modules')
expect(externalModuleFolders).to.contain('node_modules/@types')
})
})

0 comments on commit 34b1574

Please sign in to comment.