Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1323 for 'no-unused-modules' crashing when using 'ignoreExports'… #1331

Merged
merged 1 commit into from
Apr 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: [],
})
})