Skip to content

docs: Update nx project filtering documentation #4037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 49 additions & 37 deletions @commitlint/config-nx-scopes/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,52 +21,64 @@ As an example, the following code demonstrates how to select only applications t
In your .commitlintrc.js file:

```javascript
const {
utils: {getProjects},
} = require('@commitlint/config-nx-scopes');

module.exports = {
rules: {
'scope-enum': async (ctx) => [
2,
'always',
[
...(await getProjects(
ctx,
({name, projectType}) =>
!name.includes('e2e') && projectType == 'application'
)),
async function getConfig() {
const {
default: {
utils: {getProjects},
},
} = await import('@commitlint/config-nx-scopes');

return {
rules: {
'scope-enum': async (ctx) => [
2,
'always',
[
...(await getProjects(
ctx,
({name, projectType}) =>
!name.includes('e2e') && projectType == 'application'
)),
],
],
],
},
// . . .
};
},
// . . .
};
}

module.exports = getConfig();
```

Here is another example where projects tagged with 'stage:end-of-life' are not allowed to be used as the scope for a commit.

In your .commitlintrc.js file:

```javascript
const {
utils: {getProjects},
} = require('@commitlint/config-nx-scopes');

module.exports = {
rules: {
'scope-enum': async (ctx) => [
2,
'always',
[
...(await getProjects(
ctx,
({tags}) => !tags.includes('stage:end-of-life')
)),
async function getConfig() {
const {
default: {
utils: {getProjects},
},
} = await import('@commitlint/config-nx-scopes');

return {
rules: {
'scope-enum': async (ctx) => [
2,
'always',
[
...(await getProjects(
ctx,
({tags}) => !tags.includes('stage:end-of-life')
)),
],
],
],
},
// . . .
};
},
// . . .
};
}

module.exports = getConfig();
```

## Examples
Expand Down