Skip to content

Commit

Permalink
Fix #1323 for 'no-unused-modules' crashing when using 'ignoreExports'…
Browse files Browse the repository at this point in the history
…-option
  • Loading branch information
rfermann committed Apr 15, 2019
1 parent 3512563 commit 1666c84
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 1666c84

Please sign in to comment.