Skip to content
Nx Cloud CI is in private beta 10.6× faster average CI time with 79% less compute. Join the beta

Use the @nx/conformance plugin to write and apply rules for your entire workspace that help with consistency, maintainability, reliability, and security. The plugin is open source and MIT licensed, and doesn't need an Nx key or license.

Large organizations struggle with maintaining consistency across teams and projects. Manual audits don't scale and developers can't remember every standard. Conformance provides automated governance that catches issues before they reach production and enforces policies without manual intervention.

The @nx/conformance plugin lets you write custom rules in TypeScript that enforce your organization's standards across any language or technology in your codebase. Rules can complement existing linting tools by verifying proper configuration, or enforce entirely new policies around security, architecture, or documentation requirements.

The plugin also provides the following pre-written rules:

  • Enforce Project Boundaries: Similar to the Nx ESLint Enforce Module Boundaries rule, but enforces the boundaries on every project dependency, not just those created from TypeScript imports or package.json dependencies.

The @nx/owners plugin provides the Ensure Owners rule (@nx/owners/ensure-owners), which requires every project to have an owner.

Add the Conformance plugin to your workspace:

Terminal window
nx add @nx/conformance

@nx/conformance ships with each Nx release, so its version matches nx.

Conformance rules are configured in the conformance property of the nx.json file. You can use the pre-defined rules or reference your own custom rule. See the plugin documentation for more details.

nx.json
{
"conformance": {
"rules": [
{
"rule": "@nx/conformance/enforce-project-boundaries",
"options": {
"depConstraints": [
{
"sourceTag": "scope:shared",
"onlyDependOnProjectsWithTags": ["scope:shared"],
},
],
},
},
{
"rule": "@nx/owners/ensure-owners",
"projects": ["!experimental-app"],
},
{
"rule": "./tools/local-conformance-rule.ts",
},
],
},
}

Enforce rules with the nx conformance and nx conformance:check commands

Section titled “Enforce rules with the nx conformance and nx conformance:check commands”

The @nx/conformance plugin enables two commands:

  • nx conformance: Evaluates rules and applies any available fix generators. Changes are written to disk and rules are evaluated once more to calculate how many violations were fixed. Use this locally while working on feature branches.
  • nx conformance:check: Evaluates rules only. Fix generators are not applied (useful for CI).

Fix generators are only applied for rules whose final status is not disabled.

If @nx/conformance isn't installed, both commands tell you to run nx add @nx/conformance.

Both commands run the rules configured in nx.json locally, whether or not the workspace is connected to Nx Cloud, and don't need an Nx Cloud connection, key, or license. Rules configured in your Nx Cloud organization (nx-cloud: rules) and result reporting to Nx Cloud require Nx Cloud Enterprise and run through nx-cloud conformance and nx-cloud conformance:check. If nx.json contains an nx-cloud: rule, nx conformance fails with a message telling you to run nx-cloud conformance instead.

- name: Enforce all conformance rules
run: npx nx conformance:check

Pass --printConfig to either command to print the resolved conformance configuration for the workspace.

Taking things further with Nx Cloud Enterprise

Section titled “Taking things further with Nx Cloud Enterprise”

Organizations on the Nx Cloud Enterprise plan can publish custom conformance rules to their Nx Cloud organization without the friction of a custom registry, and then configure the rules to apply to the workspaces in their organization automatically when nx-cloud conformance or nx-cloud conformance:check runs in a workspace connected to Nx Cloud.

Add nx-cloud conformance:check to your CI process, and Nx Cloud merges the rules configured in your organization with any local rules:

- name: Enforce all conformance rules
run: npx nx-cloud conformance:check

Learn more about publishing and configuring conformance rules in Nx Cloud.