File tree 2 files changed +32
-1
lines changed
@commitlint/config-nx-scopes
2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ module.exports = {
8
8
} ,
9
9
} ;
10
10
11
- function getProjects ( context ) {
11
+ function getProjects ( context , filterFunc ) {
12
12
return Promise . resolve ( )
13
13
. then ( ( ) => {
14
14
const ctx = context || { } ;
@@ -24,6 +24,15 @@ function getProjects(context) {
24
24
} )
25
25
. then ( ( projects ) => {
26
26
return projects
27
+ . filter ( ( project ) =>
28
+ filterFunc
29
+ ? filterFunc ( {
30
+ name : project . name ,
31
+ type : project . projectType ,
32
+ tags : project . tags ,
33
+ } )
34
+ : true
35
+ )
27
36
. filter ( ( project ) => project . targets )
28
37
. map ( ( project ) => project . name )
29
38
. map ( ( name ) => ( name . charAt ( 0 ) === '@' ? name . split ( '/' ) [ 1 ] : name ) ) ;
Original file line number Diff line number Diff line change @@ -12,6 +12,28 @@ npm install --save-dev @commitlint/config-nx-scopes @commitlint/cli
12
12
echo "module.exports = {extends: ['@commitlint/config-nx-scopes']};" > commitlint.config.js
13
13
```
14
14
15
+ ## Filtering projects by type
16
+
17
+ You can filter projects by type by specifying the project type parameter.
18
+
19
+ In your .commitlintrc.js file:
20
+
21
+ ``` javascript
22
+ const {
23
+ utils: {getProjects },
24
+ } = require (' @commitlint/config-nx-scopes' );
25
+
26
+ module .exports = {
27
+ rules: {
28
+ ' scope-enum' : async (ctx ) => [
29
+ 2 ,
30
+ ' always' ,
31
+ [... (await getProjects (ctx, ' application' ))], // ⬅ or 'library'
32
+ ],
33
+ },
34
+ };
35
+ ```
36
+
15
37
## Examples
16
38
17
39
```
You can’t perform that action at this time.
0 commit comments