File tree 6 files changed +39
-3
lines changed
6 files changed +39
-3
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,10 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
11
11
### Changed
12
12
- Modified [ ` no-nodejs-modules ` ] error message to include the module's name ([ #453 ] , [ #461 ] )
13
13
14
+ ### Fixed
15
+ - [ ` import/extensions ` setting] is respected in spite of the appearance of imports
16
+ in an imported file. (fixes [ #478 ] , thaks [ @rhys-vdw ] )
17
+
14
18
## [ 1.12.0] - 2016-07-26
15
19
### Added
16
20
- [ ` import/external-module-folders ` setting] : a possibility to configure folders for "external" modules ([ #444 ] , thanks [ @zloirock ] )
@@ -311,6 +315,7 @@ for info on changes for earlier releases.
311
315
[ #157 ] : https://github.com/benmosher/eslint-plugin-import/pull/157
312
316
[ #314 ] : https://github.com/benmosher/eslint-plugin-import/pull/314
313
317
318
+ [ #478 ] : https://github.com/benmosher/eslint-plugin-import/issues/478
314
319
[ #456 ] : https://github.com/benmosher/eslint-plugin-import/issues/456
315
320
[ #453 ] : https://github.com/benmosher/eslint-plugin-import/issues/453
316
321
[ #441 ] : https://github.com/benmosher/eslint-plugin-import/issues/441
@@ -399,3 +404,4 @@ for info on changes for earlier releases.
399
404
[ @ljharb ] : https://github.com/ljharb
400
405
[ @rhettlivingston ] : https://github.com/rhettlivingston
401
406
[ @zloirock ] : https://github.com/zloirock
407
+ [ @rhys-vdw ] : https://github.com/rhys-vdw
Original file line number Diff line number Diff line change 12
12
" memo-parser"
13
13
],
14
14
"scripts" : {
15
- "watch" : " cross-env NODE_PATH=./lib gulp watch-test " ,
15
+ "watch" : " cross-env NODE_PATH=./src mocha -- watch --compilers js:babel-register --recursive tests/src " ,
16
16
"cover" : " gulp pretest && cross-env NODE_PATH=./lib istanbul cover --dir reports/coverage _mocha tests/lib/ -- --recursive -R progress" ,
17
17
"posttest" : " eslint ./src" ,
18
18
"test" : " cross-env BABEL_ENV=test NODE_PATH=./src nyc mocha --recursive tests/src -t 5s" ,
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import * as doctrine from 'doctrine'
7
7
8
8
import parse from './parse'
9
9
import resolve , { relative as resolveRelative } from './resolve'
10
- import isIgnored from './ignore'
10
+ import isIgnored , { hasValidExtension } from './ignore'
11
11
12
12
import { hashObject } from './hash'
13
13
@@ -71,6 +71,12 @@ export default class ExportMap {
71
71
// future: check content equality?
72
72
}
73
73
74
+ // check valid extensions first
75
+ if ( ! hasValidExtension ( path , context ) ) {
76
+ exportCache . set ( cacheKey , null )
77
+ return null
78
+ }
79
+
74
80
const content = fs . readFileSync ( path , { encoding : 'utf8' } )
75
81
76
82
// check for and cache ignore
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ export default function ignore(path, context) {
26
26
: [ 'node_modules' ]
27
27
28
28
// check extension list first (cheap)
29
- if ( ! validExtensions ( context ) . has ( extname ( path ) ) ) return true
29
+ if ( ! hasValidExtension ( path , context ) ) return true
30
30
31
31
if ( ignoreStrings . length === 0 ) return false
32
32
@@ -37,3 +37,7 @@ export default function ignore(path, context) {
37
37
38
38
return false
39
39
}
40
+
41
+ export function hasValidExtension ( path , context ) {
42
+ return validExtensions ( context ) . has ( extname ( path ) )
43
+ }
Original file line number Diff line number Diff line change
1
+ type X = { y : string | null }
2
+
3
+ export function getX ( ) : X {
4
+ return null
5
+ }
Original file line number Diff line number Diff line change @@ -292,4 +292,19 @@ describe('getExports', function () {
292
292
} )
293
293
} )
294
294
295
+ context ( 'issue #478: never parse non-whitelist extensions' , function ( ) {
296
+ const context = Object . assign ( { } , fakeContext ,
297
+ { settings : { 'import/extensions' : [ '.js' ] } } )
298
+
299
+ let imports
300
+ before ( 'load imports' , function ( ) {
301
+ imports = ExportMap . get ( './typescript.ts' , context )
302
+ } )
303
+
304
+ it ( 'returns nothing for a TypeScript file' , function ( ) {
305
+ expect ( imports ) . not . to . exist
306
+ } )
307
+
308
+ } )
309
+
295
310
} )
You can’t perform that action at this time.
0 commit comments