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

depConstraint with empty "onlyDependOnLibsWithTags" passes linting #12597

Closed
quoctintran opened this issue Oct 14, 2022 · 2 comments · Fixed by #12878
Closed

depConstraint with empty "onlyDependOnLibsWithTags" passes linting #12597

quoctintran opened this issue Oct 14, 2022 · 2 comments · Fixed by #12878
Assignees
Labels
outdated scope: linter Issues related to Eslint support in Nx type: bug

Comments

@quoctintran
Copy link

quoctintran commented Oct 14, 2022

Current Behavior

A depConstraint defined as
{ "sourceTag": "scope:projectA", "onlyDependOnLibsWithTags": [] }
pass linting even if the project with tag "scope:projectA" depends on other projects with tags.

Expected Behavior

Linting should fail if projectA depends on other projects and the defined constraint shows an empty array for the property "onlyDependOnLibsWithTags".
I dig into the code and I've seen that version 13.8.5 was the last working version with the expected behavior.
I guess this PR introduced the change of behavior: #8633

Steps to Reproduce

  1. create new nx workspace with npx create-nx-workspace (angular preset, scss and no Nx cloud)
  2. create first lib: npx nx g @nrwl/angular:lib projectA --tags "scope:projectA"
  3. create second lib: npx nx g @nrwl/angular:lib projectB --tags "scope:projectB"
  4. replace the default depConstraint in the root .eslintrc.json with
              {
                "sourceTag": "scope:projectA",
                "onlyDependOnLibsWithTags": []
              },
              {
                "sourceTag": "scope:projectB",
                "onlyDependOnLibsWithTags": []
              }
  1. In the projectA.module.ts file import the projectB module
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ProjectBModule } from '@eap1386/projectB';

@NgModule({
  imports: [CommonModule, ProjectBModule],
})
export class ProjectAModule {}

Environment

❯ npx nx report

 >  NX   Report complete - copy this into the issue template

   Node : 16.17.0
   OS   : win32 x64
   npm  : 8.15.0

   nx : 13.8.6
   @nrwl/angular : 13.8.6
   @nrwl/cli : 13.8.6
   @nrwl/cypress : 13.8.6
   @nrwl/detox : undefined
   @nrwl/devkit : 13.8.6
   @nrwl/eslint-plugin-nx : 13.8.6
   @nrwl/express : undefined
   @nrwl/jest : 13.8.6
   @nrwl/js : undefined
   @nrwl/linter : 13.8.6
   @nrwl/nest : undefined
   @nrwl/next : undefined
   @nrwl/node : undefined
   @nrwl/nx-cloud : undefined
   @nrwl/react : undefined
   @nrwl/react-native : undefined
   @nrwl/schematics : undefined
   @nrwl/storybook : 13.8.6
   @nrwl/tao : 13.8.6
   @nrwl/web : undefined
   @nrwl/workspace : 13.8.6
   typescript : 4.5.5
   rxjs : 7.4.0
   ---------------------------------------
   Community plugins:
         @angular/animations: 13.2.7
         @angular/common: 13.2.7
         @angular/compiler: 13.2.7
         @angular/core: 13.2.7
         @angular/forms: 13.2.7
         @angular/platform-browser: 13.2.7
         @angular/platform-browser-dynamic: 13.2.7
         @angular/router: 13.2.7
         @angular-devkit/build-angular: 13.2.6
         @angular/cli: 13.2.6
         @angular/compiler-cli: 13.2.7
         @angular/language-service: 13.2.7

What is the intention if "onlyDependOnLibsWithTags" is an empty array? In my interpretation it says that the project with the defined tag can't depend on other projects (if you can say 'depend on anything with "*"'). It may refer to #11236

Thank you for reviewing!

@FrozenPandaz FrozenPandaz added the scope: linter Issues related to Eslint support in Nx label Oct 14, 2022
@meeroslav
Copy link
Contributor

This only functioned in the past because there was an error. The onlyDependOnLibsWithTags was never designed to be empty. But it makes sense. The behavior, in that case, would be:

A package that onlyDependsOnLibsWithTags: [] can only depend on libs that have no tags.

We do strongly discourage having projects with no tags, as it can lead to a lot of different issues and the whole rule starts to lose its purpose. But for the sake of feature completeness, we will add the above-mentioned logic to empty onlyDependOnLibsWithTags.

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: linter Issues related to Eslint support in Nx type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants