@@ -2,11 +2,11 @@ import type { ESLintTarget } from '../config';
22import { nxProjectsToConfig } from './projects-to-config' ;
33
44/**
5- * Accepts a target Nx projects , converts lint configurations to Code PushUp ESLint plugin parameters.
5+ * Accepts a target Nx project , converts its lint configuration to Code PushUp ESLint plugin parameters.
66 *
7- * Use when you wish to include a targeted subset of your Nx monorepo in your Code PushUp project.
8- * If you prefer to include all Nx projects, refer to {@link eslintConfigFromAllNxProjects} instead,
9- * if you'd like to auto include all dependencies of the provided target project use {@link eslintConfigFromNxProjectAndDeps} instead.
7+ * Use when you wish to only have a single Nx project as your Code PushUp project, without any other dependencies .
8+ * If you prefer to include all Nx projects, refer to {@link eslintConfigFromAllNxProjects} instead.
9+ * If you'd like to auto include all dependencies of the provided target project use {@link eslintConfigFromNxProjectAndDeps} instead.
1010 *
1111 * @example
1212 * import eslintPlugin, {
@@ -23,17 +23,22 @@ import { nxProjectsToConfig } from './projects-to-config';
2323 * ]
2424 * }
2525 *
26- * @param projectName Nx project serving as main entry point
26+ * @param projectName Nx project name
2727 * @returns ESLint config and patterns, intended to be passed to {@link eslintPlugin}
2828 */
2929export async function eslintConfigFromNxProject (
3030 projectName : string ,
31- ) : Promise < ESLintTarget [ ] > {
31+ ) : Promise < ESLintTarget > {
3232 const { createProjectGraphAsync } = await import ( '@nx/devkit' ) ;
3333 const projectGraph = await createProjectGraphAsync ( { exitOnError : false } ) ;
3434
35- return nxProjectsToConfig (
35+ const [ project ] = nxProjectsToConfig (
3636 projectGraph ,
3737 project => ! ! project . name && project . name === projectName ,
3838 ) ;
39+
40+ if ( ! project ) {
41+ throw new Error ( `Couldn't find Nx project named "${ projectName } "` ) ;
42+ }
43+ return project ;
3944}
0 commit comments