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

fix(linter): disable absolute paths within project #5555

Merged
merged 3 commits into from
May 6, 2021

Conversation

meeroslav
Copy link
Contributor

Current Behavior

If a project imports from itself using the full package name, the lint rule does not detect a circular dependency.

// In @happy-org/header library
// This should be a circular dependency
import { MyComponent } from '@happy-org/header';

Expected Behavior

The linter should report an error with information why the error happened.
e.g.

Only relative imports are allowed within the project. Absolute import found: @happy-org/header

Related Issue(s)

Fixes #2019

@vercel
Copy link

vercel bot commented May 4, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/nrwl/nx-dev/CN9W1HU5D6WChSEkiVRdZR1Dsoqd
✅ Preview: https://nx-dev-git-fork-meeroslav-fix-linter-circular-ab-8a933e.vercel.app

@nx-cloud
Copy link

nx-cloud bot commented May 4, 2021

Nx Cloud Report

CI ran the following commands for commit 8ccdf3e. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch

Status Command
#000000 nx affected --target=build
#000000 nx affected --target=e2e
#000000 nx affected --target=lint
#000000 nx affected --target=test

Sent with 💌 from NxCloud.

Copy link
Collaborator

@FrozenPandaz FrozenPandaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🎉

@FrozenPandaz
Copy link
Collaborator

Can you see why the e2e tests are failing?

@meeroslav
Copy link
Contributor Author

Looks like a timeout. I'll look into it tomorrow.

@vsavkin
Copy link
Member

vsavkin commented May 5, 2021

I think this can be a breaking change for a lot of folks. Should we have a flag that allows you to switch it off?

@meeroslav
Copy link
Contributor Author

I think this can be a breaking change for a lot of folks. Should we have a flag that allows you to switch it off?

Good point, @vsavkin! I will add the flag

@Wykks
Copy link

Wykks commented May 11, 2021

Hello!

I can confirm that this is a breaking change, because I actually need to do this when using secondary entry point for a library. When code in the secondary entry point import something from the main entry point.

@meeroslav
You forgot to add the flag to the schema around here :

properties: {
enforceBuildableLibDependency: { type: 'boolean' },
allow: [{ type: 'string' }],
depConstraints: [
{
type: 'object',
properties: {
sourceTag: { type: 'string' },
onlyDependOnLibsWithTags: [{ type: 'string' }],
},
additionalProperties: false,
},
],
},
additionalProperties: false,

Unfortunately without it, eslint is rejecting the new config with a ""Configuration for rule "@nrwl/nx/enforce-module-boundaries" is invalid"

@meeroslav
Copy link
Contributor Author

@Wykks Thank you for the fast feedback. The missing schema property definition was accidentally removed. I will add it asap.

@meeroslav meeroslav deleted the fix-linter-circular-absolute-path branch May 11, 2021 14:36
meeroslav added a commit to meeroslav/nx that referenced this pull request May 11, 2021
@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(lint): add import rule to prevent circular dependencies
5 participants