Skip to content

Commit

Permalink
docs: update example usage of project filtering with @commitlint/conf…
Browse files Browse the repository at this point in the history
…ig-nx-scopes
  • Loading branch information
jaytavares committed May 10, 2022
1 parent bc49e93 commit 8aa6d66
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions @commitlint/config-nx-scopes/readme.md
Expand Up @@ -12,9 +12,11 @@ npm install --save-dev @commitlint/config-nx-scopes @commitlint/cli
echo "module.exports = {extends: ['@commitlint/config-nx-scopes']};" > commitlint.config.js
```

## Filtering projects by type
## Filtering projects

You can filter projects by type by specifying the project type parameter.
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.

As an example, the following code demonstrates how to select only applications that are not end-to-end tests.

In your .commitlintrc.js file:

Expand All @@ -28,9 +30,15 @@ module.exports = {
'scope-enum': async (ctx) => [
2,
'always',
[...(await getProjects(ctx, 'application'))], // ⬅ or 'library'
[
...(await getProjects(
ctx,
({name, type}) => !name.includes('e2e') && type == 'application'
)),
],
],
},
// . . .
};
```

Expand Down

0 comments on commit 8aa6d66

Please sign in to comment.