Skip to content

Commit

Permalink
fix: rule PHANTOM_DEPS support optional deps (#618)
Browse files Browse the repository at this point in the history
* fix: rule PHANTOM_DEPS support optional deps

* test: add optional deps case
  • Loading branch information
PeachScript committed Apr 3, 2023
1 parent e95c969 commit 6629edd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/doctor/rules/PHANTOM_DEPS.ts
Expand Up @@ -17,6 +17,7 @@ export default (api: IApi) => {
api.pkg.name !== pkgName &&
!api.pkg.dependencies?.[pkgName] &&
!api.pkg.peerDependencies?.[pkgName] &&
!api.pkg.optionalDependencies?.[pkgName] &&
aliasKeys.every((k) => k !== i.path && !i.path.startsWith(`${k}/`)) &&
!mergedExternals[i.path]
) {
Expand Down
3 changes: 3 additions & 0 deletions tests/fixtures/doctor/health/package.json
Expand Up @@ -4,5 +4,8 @@
],
"dependencies": {
"hello.world": "0.0.0"
},
"optionalDependencies": {
"optional": "0.0.0"
}
}
1 change: 1 addition & 0 deletions tests/fixtures/doctor/health/src/index.ts
@@ -1,2 +1,3 @@
// expect handle pkg name includes .
import 'hello.world';
import 'optional';

0 comments on commit 6629edd

Please sign in to comment.