Skip to content

Commit

Permalink
feat(plugin-eslint): rename eslintConfigFromNxProject to eslintConfig…
Browse files Browse the repository at this point in the history
…FromNxProjectAndDeps

Signed-off-by: Vojtech Masek <vojtech@flowup.cz>
  • Loading branch information
vmasek committed May 22, 2024
1 parent 068b335 commit efbb72a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
6 changes: 3 additions & 3 deletions packages/plugin-eslint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ Detected ESLint rules are mapped to Code PushUp audits. Audit reports are calcul
};
```

- If you wish to target a specific project along with other projects it depends on, use the `eslintConfigFromNxProject` helper and pass in in your project name:
- If you wish to target a specific project along with other projects it depends on, use the `eslintConfigFromNxProjectAndDeps` helper and pass in in your project name:

```js
import eslintPlugin, { eslintConfigFromNxProject } from '@code-pushup/eslint-plugin';
import eslintPlugin, { eslintConfigFromNxProjectAndDeps } from '@code-pushup/eslint-plugin';
export default {
plugins: [
// ...
await eslintPlugin(await eslintConfigFromNxProject('<PROJECT-NAME>')),
await eslintPlugin(await eslintConfigFromNxProjectAndDeps('<PROJECT-NAME>')),
],
};
```
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-eslint/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default eslintPlugin;
export type { ESLintPluginConfig } from './lib/config';

export {
eslintConfigFromNxProject,
eslintConfigFromNxProjectAndDeps,
eslintConfigFromNxProjects,
eslintConfigFromAllNxProjects,
} from './lib/nx';
7 changes: 5 additions & 2 deletions packages/plugin-eslint/src/lib/nx.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { fileURLToPath } from 'node:url';
import { setWorkspaceRoot, workspaceRoot } from 'nx/src/utils/workspace-root';
import type { MockInstance } from 'vitest';
import { type ESLintTarget } from './config';
import { eslintConfigFromAllNxProjects, eslintConfigFromNxProject } from './nx';
import {
eslintConfigFromAllNxProjects,
eslintConfigFromNxProjectAndDeps,
} from './nx';

describe('Nx helpers', () => {
let cwdSpy: MockInstance<[], string>;
Expand Down Expand Up @@ -109,7 +112,7 @@ describe('Nx helpers', () => {
])(
'project %j - expected configurations for projects %j',
async (project, expectedProjects) => {
const targets = await eslintConfigFromNxProject(project);
const targets = await eslintConfigFromNxProjectAndDeps(project);

expect(targets).toEqual(
expectedProjects.map(
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-eslint/src/lib/nx/find-all-projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { nxProjectsToConfig } from './projects-to-config';
* Finds all Nx projects in workspace and converts their lint configurations to Code PushUp ESLint plugin parameters.
*
* Use when you wish to automatically include every Nx project in a single Code PushUp project.
* If you prefer to only include a subset of your Nx monorepo, refer to {@link eslintConfigFromNxProject} instead.
* If you prefer to only include a subset of your Nx monorepo, refer to {@link eslintConfigFromNxProjectAndDeps} instead.
*
* @example
* import eslintPlugin, {
Expand Down
6 changes: 3 additions & 3 deletions packages/plugin-eslint/src/lib/nx/find-project-with-deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ import { findAllDependencies } from './traverse-graph';
*
* @example
* import eslintPlugin, {
* eslintConfigFromNxProject,
* eslintConfigFromNxProjectAndDeps,
* } from '@code-pushup/eslint-plugin';
*
* const projectName = 'backoffice'; // <-- name from project.json
*
* export default {
* plugins: [
* await eslintPlugin(
* await eslintConfigFromNxProject(projectName)
* await eslintConfigFromNxProjectAndDeps(projectName)
* )
* ]
* }
*
* @param projectName Nx project serving as main entry point
* @returns ESLint config and patterns, intended to be passed to {@link eslintPlugin}
*/
export async function eslintConfigFromNxProject(
export async function eslintConfigFromNxProjectAndDeps(
projectName: string,
): Promise<ESLintTarget[]> {
const { createProjectGraphAsync } = await import('@nx/devkit');
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-eslint/src/lib/nx/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export {
eslintConfigFromNxProjects,
eslintConfigFromAllNxProjects,
} from './find-all-projects';
export { eslintConfigFromNxProject } from './find-project-with-deps';
export { eslintConfigFromNxProjectAndDeps } from './find-project-with-deps';

0 comments on commit efbb72a

Please sign in to comment.