Skip to content

Commit 8aa6d66

Browse files
committed
docs: update example usage of project filtering with @commitlint/config-nx-scopes
1 parent bc49e93 commit 8aa6d66

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

@commitlint/config-nx-scopes/readme.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ npm install --save-dev @commitlint/config-nx-scopes @commitlint/cli
1212
echo "module.exports = {extends: ['@commitlint/config-nx-scopes']};" > commitlint.config.js
1313
```
1414

15-
## Filtering projects by type
15+
## Filtering projects
1616

17-
You can filter projects by type by specifying the project type parameter.
17+
You can filter projects by defining a filter function as the second parameter to the getProjects function. The function will be called with the each projects' `name`, `type`, and `tags`. You can return a boolean to indicate whether the project should be included or not.
18+
19+
As an example, the following code demonstrates how to select only applications that are not end-to-end tests.
1820

1921
In your .commitlintrc.js file:
2022

@@ -28,9 +30,15 @@ module.exports = {
2830
'scope-enum': async (ctx) => [
2931
2,
3032
'always',
31-
[...(await getProjects(ctx, 'application'))], // ⬅ or 'library'
33+
[
34+
...(await getProjects(
35+
ctx,
36+
({name, type}) => !name.includes('e2e') && type == 'application'
37+
)),
38+
],
3239
],
3340
},
41+
// . . .
3442
};
3543
```
3644

0 commit comments

Comments
 (0)