Skip to content
Permalink
Browse files

Merge pull request #1347 from rfermann/1338

[fix] `no-unused-modules`: don't crash when lint file outside src-folder
  • Loading branch information...
ljharb committed Apr 27, 2019
2 parents 4620185 + bb686de commit f63dd261809de6883b13b6b5b960e6d7f42a7813
Showing with 18 additions and 0 deletions.
  1. +8 −0 src/rules/no-unused-modules.js
  2. +10 −0 tests/src/rules/no-unused-modules.js
@@ -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
@@ -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 f63dd26

Please sign in to comment.
You can’t perform that action at this time.