Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eslint): introduce @nrwl/nx/enforce-module-boundaries to prevent using transitive dependencies #21999

Open
Hotell opened this issue Mar 8, 2022 · 12 comments

Comments

@Hotell
Copy link
Contributor

Hotell commented Mar 8, 2022

Describe the issue:

'import/no-extraneous-dependencies' rule is unable to handle following situation (single version policy for devDeps and monorepo packages):

// @filename package.json
{
  "dependencies": {
  },
  "devDependencies": {
     "lib-a": "1.0.0",
     "lib-b": "1.0.0",
  }
}
// @filename packages/react-foo/package.json
{
  "dependencies": {
        "@fluentui/react-one": "1.0.0"
  },
  "devDependencies": {
       "@fluentui/scripts": "1.0.0"
  }
}
// @filename packages/react-foo/src/hello.stories.ts

// 🚨 error, because `react-two` is not defined as dependency - ✋THIS IS INCORRECT ✋
// WHY: 
// - @fluentui/react-two is a monorepo package
// - @fluentui/react-two is used only for non production code (stories/tests/config)
import {Two} from '@fluentui/react-two";
// @filename packages/react-foo/src/implementation.ts

// ✅ no errors, because `react-one` is defined as dependency of this package
import {One} from '@fluentui/react-one"

Solution

After [link], import/no-extraneous-dependencies was turned off for non production files for reasons specified in this issue.

With that we know wont' trigger error if someone imports a transitive dev dependencies in non production code ( this is not the end of the world for sure). We would still like to prevent such a behaviour. thankfully NX eslint plugin comes with such a rule:

{
 "@nrwl/nx/enforce-module-boundaries": ["error", {"banTransitiveDependencies": true}]
}

Note that this rule will check only dependencies within root package.json - single version policy. so to be completely covered - we need to migrate whole monorepo to this approach

Related issues

@msft-fluent-ui-bot
Copy link
Collaborator

Because this issue has not had activity for over 180 days, we're automatically closing it for house-keeping purposes.

Still require assistance? Please, create a new issue with up-to date details.

@Hotell Hotell reopened this Oct 10, 2022
@layershifter layershifter removed the Resolution: Soft Close Soft closing inactive issues over a certain period label Jan 23, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot added Resolution: Soft Close Soft closing inactive issues over a certain period labels Aug 25, 2023
@microsoft-github-policy-service

Because this issue has not had activity for over 180 days, we're automatically closing it for house-keeping purposes.

Still require assistance? Please, create a new issue with up-to date details.

2 similar comments
@microsoft-github-policy-service

This comment was marked as duplicate.

@microsoft-github-policy-service

This comment was marked as duplicate.

@microsoft-github-policy-service

This comment was marked as duplicate.

6 similar comments
@microsoft-github-policy-service

This comment was marked as duplicate.

@microsoft-github-policy-service

This comment was marked as duplicate.

@microsoft-github-policy-service

This comment was marked as duplicate.

@microsoft-github-policy-service

This comment was marked as duplicate.

@microsoft-github-policy-service

This comment was marked as duplicate.

@microsoft-github-policy-service

This comment was marked as duplicate.

@Hotell Hotell reopened this Sep 19, 2023

Because this issue has not had activity for over 180 days, we're automatically closing it for house-keeping purposes.

Still require assistance? Please, create a new issue with up-to date details.

@Hotell Hotell changed the title eslint-plugin: introduce @nrwl/nx/enforce-module-boundaries to prevent using transitive dependencies feat(eslint): introduce @nrwl/nx/enforce-module-boundaries to prevent using transitive dependencies Mar 28, 2024
@Hotell Hotell reopened this Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

3 participants