From 8c0a2cc515e4541883e1d8aba85fa71d3a865891 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Wed, 25 Sep 2024 17:32:56 -0700 Subject: [PATCH] docs: Explain the transitive dependency case for no-extraneous-* (#347) Co-authored-by: Sebastian Good <2230835+scagood@users.noreply.github.com> --- docs/rules/no-extraneous-import.md | 5 ++++- docs/rules/no-extraneous-require.md | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/rules/no-extraneous-import.md b/docs/rules/no-extraneous-import.md index 7aae0d7e..fbeaaa63 100644 --- a/docs/rules/no-extraneous-import.md +++ b/docs/rules/no-extraneous-import.md @@ -4,7 +4,10 @@ -If an `import` declaration's source is extraneous (it's not written in `package.json`), the program works in local, but will not work after dependencies are re-installed. It will cause troubles to your team/contributors. +If an `import` declaration's source is extraneous (it's not listed in your `package.json`), the program may work locally but can break after dependencies are re-installed. This can cause issues for your team/contributors. If a declaration source is extraneous yet consistently works for you and your team, it might be a transitive dependency (a dependency of another dependency). Transitive dependencies should still be added as an explicit dependency in your `package.json` to avoid the risk of a dependency potentially changing or removing the transitive dependency. + +Additionally, the transitive dependency could be a dev dependency, meaning your code could work in development but not in production. + This rule disallows `import` declarations of extraneous modules. ## 📖 Rule Details diff --git a/docs/rules/no-extraneous-require.md b/docs/rules/no-extraneous-require.md index 94596d89..25a54224 100644 --- a/docs/rules/no-extraneous-require.md +++ b/docs/rules/no-extraneous-require.md @@ -4,7 +4,10 @@ -If a `require()`'s target is extraneous (it's not written in `package.json`), the program works in local, but will not work after dependencies are re-installed. It will cause troubles to your team/contributors. +If a `require()`'s target is extraneous (it's not listed in your `package.json`), the program may work locally but can break after dependencies are re-installed. This can cause issues for your team/contributors. If a declaration source is extraneous yet consistently works for you and your team, it might be a transitive dependency (a dependency of another dependency). Transitive dependencies should still be added as an explicit dependency in your `package.json` to avoid the risk of a dependency potentially changing or removing the transitive dependency. + +Additionally, the transitive dependency could be a dev dependency, meaning your code could work in development but not in production. + This rule disallows `require()` of extraneous modules. ## 📖 Rule Details