Skip to content

Commit

Permalink
[fix] no-unused-modules: don't crash when lint file outside src-folder
Browse files Browse the repository at this point in the history
  • Loading branch information
rfermann committed Apr 27, 2019
1 parent 4620185 commit bb686de
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/rules/no-unused-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,14 @@ module.exports = {
return
}

// refresh list of source files
const srcFiles = resolveFiles(getSrc(src), ignoreExports)

// make sure file to be linted is included in source files
if (!srcFiles.has(file)) {
return
}

exports = exportList.get(file)

// special case: export * from
Expand Down
10 changes: 10 additions & 0 deletions tests/src/rules/no-unused-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,3 +592,13 @@ describe('do not report missing export for ignored file', () => {
invalid: [],
})
})

// lint file not available in `src`
ruleTester.run('no-unused-modules', rule, {
valid: [
test({ options: unusedExportsOptions,
code: `export const jsxFoo = 'foo'; export const jsxBar = 'bar'`,
filename: testFilePath('../jsx/named.jsx')}),
],
invalid: [],
})

0 comments on commit bb686de

Please sign in to comment.