Skip to content

Commit

Permalink
[fix] no-unused-modules: avoid crash when using ignoreExports-option
Browse files Browse the repository at this point in the history
Fixes #1323.
  • Loading branch information
rfermann authored and ljharb committed Apr 15, 2019
1 parent 3512563 commit b151d04
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/rules/no-unused-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ module.exports = {
return
}

if (ignoredFiles.has(file)) {
return
}

const exportCount = exportList.get(file)
const exportAll = exportCount.get(EXPORT_ALL_DECLARATION)
const namespaceImports = exportCount.get(IMPORT_NAMESPACE_SPECIFIER)
Expand Down
15 changes: 15 additions & 0 deletions tests/src/rules/no-unused-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,3 +549,18 @@ describe('test behaviour for new file', () => {
}
})
})

describe('do not report missing export for ignored file', () => {
ruleTester.run('no-unused-modules', rule, {
valid: [
test({ options: [{
src: [testFilePath('./no-unused-modules/**/*.js')],
ignoreExports: [testFilePath('./no-unused-modules/*ignored*.js')],
missingExports: true
}],
code: 'export const test = true',
filename: testFilePath('./no-unused-modules/file-ignored-a.js')}),
],
invalid: [],
})
})

0 comments on commit b151d04

Please sign in to comment.