ESLint plugin for Nx monorepos with boundary enforcement and dependency management rules.
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
The nx-plugin-checks rule validates Nx plugin configuration files to ensure proper structure, valid implementation paths, and correct schema definitions for generators, executors, and migrations.
Validates common Nx plugin configuration files including generators.json, executors.json, migrations.json, and their TypeScript implementations.
/**
* ESLint rule that validates Nx plugin configuration files
* Rule name: "@nx/nx-plugin-checks"
*/
interface NxPluginChecksRule {
name: "nx-plugin-checks";
meta: {
docs: {
description: "Checks common nx-plugin configuration files for validity";
};
schema: [NxPluginChecksOptions];
messages: Record<MessageIds, string>;
};
defaultOptions: [NxPluginChecksOptions];
create: (context: RuleContext) => RuleListener;
}Complete configuration interface for plugin validation behavior.
interface NxPluginChecksOptions {
/** Path to the project's generators.json file, relative to project root */
generatorsJson?: string;
/** Path to the project's executors.json file, relative to project root */
executorsJson?: string;
/** Path to the project's migrations.json file, relative to project root */
migrationsJson?: string;
/** Path to the project's package.json file, relative to project root */
packageJson?: string;
/** List of valid version specifiers for package versions */
allowedVersionStrings: string[];
/** Path to TypeScript configuration file for implementation validation */
tsConfig?: string;
}Standard defaults for most Nx plugin projects.
const DEFAULT_OPTIONS: NxPluginChecksOptions = {
generatorsJson: 'generators.json',
executorsJson: 'executors.json',
migrationsJson: 'migrations.json',
packageJson: 'package.json',
allowedVersionStrings: ['*', 'latest', 'next'],
tsConfig: 'tsconfig.lib.json'
};All possible validation messages returned by the rule.
type MessageIds =
| "missingRequiredSchema"
| "invalidSchemaPath"
| "missingImplementation"
| "invalidImplementationPath"
| "invalidImplementationModule"
| "unableToReadImplementationExports"
| "invalidVersion"
| "missingVersion"
| "noGeneratorsOrSchematicsFound"
| "noExecutorsOrBuildersFound"
| "valueShouldBeObject";Usage Examples:
// Basic plugin validation
{
rules: {
"@nx/nx-plugin-checks": "error"
}
}
// Custom configuration paths
{
rules: {
"@nx/nx-plugin-checks": [
"error",
{
generatorsJson: "src/generators.json",
executorsJson: "src/executors.json",
migrationsJson: "migrations.json",
packageJson: "package.json",
tsConfig: "tsconfig.json"
}
]
}
}
// Custom allowed version strings
{
rules: {
"@nx/nx-plugin-checks": [
"error",
{
allowedVersionStrings: ["*", "latest", "next", "beta", "alpha"]
}
]
}
}The rule performs comprehensive validation across multiple areas:
For generators.json files, the rule validates:
interface GeneratorConfig {
generators: {
[name: string]: {
factory: string; // Path to implementation function
schema: string; // Path to JSON schema file
description?: string;
aliases?: string[];
hidden?: boolean;
};
};
}Validation Checks:
For executors.json files, the rule validates:
interface ExecutorConfig {
executors: {
[name: string]: {
implementation: string; // Path to implementation function
schema: string; // Path to JSON schema file
description?: string;
hasher?: string; // Path to custom hasher function
};
};
}Validation Checks:
For migrations.json files, the rule validates:
interface MigrationConfig {
generators?: {
[version: string]: {
version: string;
description?: string;
factory?: string; // Path to migration function
cli?: "nx"; // CLI compatibility
};
};
packageJsonUpdates?: {
[version: string]: {
version: string;
packages: {
[packageName: string]: {
version: string;
alwaysAddToPackageJson?: boolean;
};
};
};
};
}Validation Checks:
The rule also validates package.json integration:
interface PackageJsonPluginConfig {
"nx-migrations"?: {
migrations: string; // Path to migrations.json
};
generators?: string; // Path to generators.json (legacy)
schematics?: string; // Path to generators.json (Angular compatibility)
executors?: string; // Path to executors.json
builders?: string; // Path to executors.json (Angular compatibility)
}Validation Checks:
When tsConfig is specified, the rule performs advanced TypeScript analysis:
The rule understands and validates against Nx plugin conventions:
Install with Tessl CLI
npx tessl i tessl/npm-nx--eslint-plugin