Skip to content

fix(core): handle owners and conformance project refs on move/remove#34815

Merged
barbados-clemens merged 6 commits into
masterfrom
cu/remove-handles-owners-conformance-projects
Mar 24, 2026
Merged

fix(core): handle owners and conformance project refs on move/remove#34815
barbados-clemens merged 6 commits into
masterfrom
cu/remove-handles-owners-conformance-projects

Conversation

@barbados-clemens
Copy link
Copy Markdown
Contributor

@barbados-clemens barbados-clemens commented Mar 13, 2026

Current Behavior

When removing or moving a project in an Nx workspace, the owners and conformance sections in nx.json are not updated. This leaves stale project references in:

  • conformance.rules[].projects (both plain strings and { matcher } objects)
  • owners.patterns[].projects (top-level and section-level for GitLab)

Expected Behavior

  • On project removal: Strip the removed project from all conformance rules and owners patterns. Remove entries that become empty after cleanup (rules with no projects, patterns with no projects).
  • On project move/rename: Rename all references to the old project name with the new name in conformance rules and owners patterns (including section-level patterns for GitLab-style CODEOWNERS).
  • Schema: Add owners configuration schema to nx-schema.json for validation and IDE support, including sections (GitLab CODEOWNERS).

Related Issue(s)

🤖 Generated with Claude Code

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 13, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 3518626
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69c2f686df10b30008eaf1da
😎 Deploy Preview https://deploy-preview-34815--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 13, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 3518626
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69c2f6860671af000806c3c7
😎 Deploy Preview https://deploy-preview-34815--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented Mar 13, 2026

View your CI Pipeline Execution ↗ for commit 3518626

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 1h 6m 18s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 9s View ↗
nx-cloud record -- pnpm nx conformance:check ✅ Succeeded 7s View ↗
nx build workspace-plugin ✅ Succeeded 45s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-24 22:06:31 UTC

@barbados-clemens barbados-clemens force-pushed the cu/remove-handles-owners-conformance-projects branch from ac82355 to 028acf8 Compare March 13, 2026 15:20
nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

@barbados-clemens barbados-clemens force-pushed the cu/remove-handles-owners-conformance-projects branch from 1671b1a to b751692 Compare March 16, 2026 20:49
@barbados-clemens barbados-clemens changed the title fix(workspace): clean up owners and conformance project refs on remove fix(core): clean up owners and conformance project refs on remove Mar 16, 2026
@barbados-clemens barbados-clemens self-assigned this Mar 16, 2026
nx-cloud[bot]

This comment was marked as outdated.

@barbados-clemens barbados-clemens force-pushed the cu/remove-handles-owners-conformance-projects branch from 37fa17a to b1ef800 Compare March 17, 2026 14:57
"required": ["rules"],
"additionalProperties": false
},
"owners": {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

add missing owners schema definition

Comment on lines +21 to +29
// Remove project from conformance rules
if (removeProjectFromConformanceRules(nxJson, schema.projectName)) {
nxJsonChanged = true;
}

// Remove project from owners patterns
if (removeProjectFromOwnersPatterns(nxJson, schema.projectName)) {
nxJsonChanged = true;
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

make sure to remove projects referenced in conformance & owners configs

@barbados-clemens barbados-clemens force-pushed the cu/remove-handles-owners-conformance-projects branch from b1ef800 to b057580 Compare March 23, 2026 15:46
nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

@barbados-clemens barbados-clemens changed the title fix(core): clean up owners and conformance project refs on remove feat(workspace): handle owners and conformance project refs on move/remove Mar 23, 2026
@barbados-clemens barbados-clemens marked this pull request as ready for review March 23, 2026 18:24
@barbados-clemens barbados-clemens requested a review from a team as a code owner March 23, 2026 18:24
@barbados-clemens barbados-clemens added the scope: core core nx functionality label Mar 23, 2026
@barbados-clemens barbados-clemens force-pushed the cu/remove-handles-owners-conformance-projects branch from 419ff09 to e084e93 Compare March 23, 2026 21:10
nx-cloud[bot]

This comment was marked as outdated.

Copy link
Copy Markdown
Contributor

@nx-cloud nx-cloud Bot left a comment

Choose a reason for hiding this comment

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

Nx Cloud has identified a flaky task in your failed CI:

🔂 Since the failure was identified as flaky, we triggered a CI rerun by adding an empty commit to this branch.

Nx Cloud View detailed reasoning in Nx Cloud ↗

🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.


🎓 Learn more about Self-Healing CI on nx.dev

@barbados-clemens barbados-clemens changed the title feat(workspace): handle owners and conformance project refs on move/remove feat(core): handle owners and conformance project refs on move/remove Mar 24, 2026
@barbados-clemens barbados-clemens changed the title feat(core): handle owners and conformance project refs on move/remove fix(core): handle owners and conformance project refs on move/remove Mar 24, 2026
barbados-clemens and others added 6 commits March 24, 2026 15:39
When removing a project, also strip exact project name matches from
`conformance.rules[].projects` and `owners.patterns[].projects` in
nx.json so stale references don't linger.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add the owners configuration object to nx-schema.json matching the
docs (format, outputPath, patterns, GitLab sections). Also update the
remove generator to filter project refs from section-level patterns
and handle the `owners: true` shorthand.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When removing a project clears all projects from a conformance rule or
owners pattern, remove the entire entry rather than leaving an empty
projects array.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: barbados-clemens <barbados-clemens@users.noreply.github.com>
…plice

Replace nested filter callbacks with a reverse for-loop that splices
empty entries in place, making the control flow easier to follow.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@barbados-clemens barbados-clemens force-pushed the cu/remove-handles-owners-conformance-projects branch from fef6afc to 3518626 Compare March 24, 2026 20:39
@barbados-clemens barbados-clemens enabled auto-merge (squash) March 24, 2026 20:39
@barbados-clemens barbados-clemens merged commit f6692fc into master Mar 24, 2026
23 checks passed
@barbados-clemens barbados-clemens deleted the cu/remove-handles-owners-conformance-projects branch March 24, 2026 22:06
FrozenPandaz pushed a commit that referenced this pull request Mar 26, 2026
…34815)

## Current Behavior

When removing or moving a project in an Nx workspace, the `owners` and
`conformance` sections in `nx.json` are not updated. This leaves stale
project references in:
- `conformance.rules[].projects` (both plain strings and `{ matcher }`
objects)
- `owners.patterns[].projects` (top-level and section-level for GitLab)

## Expected Behavior

- **On project removal**: Strip the removed project from all conformance
rules and owners patterns. Remove entries that become empty after
cleanup (rules with no projects, patterns with no projects).
- **On project move/rename**: Rename all references to the old project
name with the new name in conformance rules and owners patterns
(including section-level patterns for GitLab-style CODEOWNERS).
- **Schema**: Add `owners` configuration schema to `nx-schema.json` for
validation and IDE support, including sections (GitLab CODEOWNERS).

## Related Issue(s)

<!-- No specific issue linked -->

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com>
Co-authored-by: barbados-clemens <barbados-clemens@users.noreply.github.com>
(cherry picked from commit f6692fc)
@github-actions
Copy link
Copy Markdown
Contributor

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 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

scope: core core nx functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants