Skip to content

Commit

Permalink
[Fix] no-extraneous-dependencies: Exclude flow typeof imports
Browse files Browse the repository at this point in the history
Co-authored-by: Devon Govett <devongovett@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
  • Loading branch information
devongovett and ljharb committed Nov 2, 2019
1 parent 1031e1c commit f2db74a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -24,6 +24,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
- [`no-cycle`]/[`extensions`]: fix isExternalModule usage ([#1696], thanks [@paztis])
- [`extensions`]/[`no-cycle`]/[`no-extraneous-dependencies`]: Correct module real path resolution ([#1696], thanks [@paztis])
- [`no-named-default`]: ignore Flow import type and typeof ([#1983], thanks [@christianvuerings])
- [`no-extraneous-dependencies`]: Exclude flow `typeof` imports ([#1534], thanks [@devongovett])

### Changed
- [Generic Import Callback] Make callback for all imports once in rules ([#1237], thanks [@ljqx])
Expand Down Expand Up @@ -819,6 +820,7 @@ for info on changes for earlier releases.
[#1560]: https://github.com/benmosher/eslint-plugin-import/pull/1560
[#1551]: https://github.com/benmosher/eslint-plugin-import/pull/1551
[#1542]: https://github.com/benmosher/eslint-plugin-import/pull/1542
[#1534]: https://github.com/benmosher/eslint-plugin-import/pull/1534
[#1528]: https://github.com/benmosher/eslint-plugin-import/pull/1528
[#1526]: https://github.com/benmosher/eslint-plugin-import/pull/1526
[#1521]: https://github.com/benmosher/eslint-plugin-import/pull/1521
Expand Down Expand Up @@ -1338,3 +1340,4 @@ for info on changes for earlier releases.
[@panrafal]: https://github.com/panrafal
[@ttmarek]: https://github.com/ttmarek
[@christianvuerings]: https://github.com/christianvuerings
[@devongovett]: https://github.com/devongovett
2 changes: 1 addition & 1 deletion src/rules/no-extraneous-dependencies.js
Expand Up @@ -128,7 +128,7 @@ function getModuleRealName(resolved) {

function reportIfMissing(context, deps, depsOptions, node, name) {
// Do not report when importing types
if (node.importKind === 'type' || (node.parent && node.parent.importKind === 'type')) {
if (node.importKind === 'type' || (node.parent && node.parent.importKind === 'type') || node.importKind === 'typeof') {
return;
}

Expand Down
8 changes: 8 additions & 0 deletions tests/src/rules/no-extraneous-dependencies.js
Expand Up @@ -86,6 +86,14 @@ ruleTester.run('no-extraneous-dependencies', rule, {
options: [{ packageDir: packageDirWithFlowTyped }],
parser: require.resolve('babel-eslint'),
}),
test({
code: `
// @flow
import typeof TypeScriptModule from 'typescript';
`,
options: [{ packageDir: packageDirWithFlowTyped }],
parser: require.resolve('babel-eslint'),
}),
test({
code: 'import react from "react";',
options: [{ packageDir: packageDirMonoRepoWithNested }],
Expand Down

0 comments on commit f2db74a

Please sign in to comment.