Skip to content

Commit

Permalink
[Fix] no-extraneous-dependencies: ignore `export type { ... } from …
Browse files Browse the repository at this point in the history
…'...'` when `includeTypes` is false
  • Loading branch information
Pandemic1617 authored and ljharb committed Nov 7, 2023
1 parent 6d34c88 commit 12f0300
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange

## [Unreleased]

### Fixed
- [`no-extraneous-dependencies`]: ignore `export type { ... } from '...'` when `includeTypes` is `false` ([#2919], thanks [@Pandemic1617])

## [2.29.0] - 2023-10-22

### Added
Expand Down Expand Up @@ -1094,6 +1097,7 @@ for info on changes for earlier releases.

[`memo-parser`]: ./memo-parser/README.md

[#2919]: https://github.com/import-js/eslint-plugin-import/pull/2919
[#2884]: https://github.com/import-js/eslint-plugin-import/pull/2884
[#2854]: https://github.com/import-js/eslint-plugin-import/pull/2854
[#2851]: https://github.com/import-js/eslint-plugin-import/pull/2851
Expand Down Expand Up @@ -1830,6 +1834,7 @@ for info on changes for earlier releases.
[@ntdb]: https://github.com/ntdb
[@nwalters512]: https://github.com/nwalters512
[@ombene]: https://github.com/ombene
[@Pandemic1617]: https://github.com/Pandemic1617
[@ota-meshi]: https://github.com/ota-meshi
[@OutdatedVersion]: https://github.com/OutdatedVersion
[@panrafal]: https://github.com/panrafal
Expand Down
1 change: 1 addition & 0 deletions src/rules/no-extraneous-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ function reportIfMissing(context, deps, depsOptions, node, name) {
&& (
node.importKind === 'type'
|| node.importKind === 'typeof'
|| node.exportKind === 'type'
|| Array.isArray(node.specifiers) && node.specifiers.length && node.specifiers.every((specifier) => specifier.importKind === 'type' || specifier.importKind === 'typeof')
)
) {
Expand Down
12 changes: 12 additions & 0 deletions tests/src/rules/no-extraneous-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,18 @@ describe('TypeScript', () => {
options: [{ packageDir: packageDirWithTypescriptDevDependencies, devDependencies: false }],
...parserConfig,
}),

test({
code: 'import type { T } from "a"; export type { T };',
options: [{ packageDir: packageDirWithTypescriptDevDependencies, devDependencies: false }],
...parserConfig,
}),

test({
code: 'export type { T } from "a";',
options: [{ packageDir: packageDirWithTypescriptDevDependencies, devDependencies: false }],
...parserConfig,
}),
],
invalid: [
test({
Expand Down

0 comments on commit 12f0300

Please sign in to comment.