Complete Nx plugin development toolkit: create custom generators, executors, and extend Nx workspaces with reusable automation
93
94%
Does it follow best practices?
Impact
92%
1.00xAverage score across 5 eval scenarios
Passed
No known issues
Your team needs a generator that creates React components with consistent structure. Instead of string concatenation, you should use Nx's template system for maintainability.
The generator should create components with:
npx nx g my-plugin:component user-profile --directory=sharedShould create:
libs/shared/user-profile/UserProfile.tsx (component)libs/shared/user-profile/UserProfile.spec.tsx (test)Someone tried this with string concatenation:
export default async function (tree: Tree, options: { name: string }) {
const code = `export function ${options.name}() { return null; }`;
tree.write(`libs/${options.name}.tsx`, code);
}Problems:
Build a proper generator using Nx template system.
Create these files:
<%= className %> for PascalCase component name<%= fileName %> for kebab-case file names<%= propertyName %> for camelCase identifierstmpl: '' in template variables to handle .template extension