File tree 2 files changed +26
-1
lines changed
@commitlint/config-nx-scopes
2 files changed +26
-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 , projectType ) {
12
12
return Promise . resolve ( )
13
13
. then ( ( ) => {
14
14
const ctx = context || { } ;
@@ -24,6 +24,9 @@ function getProjects(context) {
24
24
} )
25
25
. then ( ( projects ) => {
26
26
return projects
27
+ . filter ( ( project ) =>
28
+ projectType ? project . projectType === projectType : true
29
+ )
27
30
. filter ( ( project ) => project . targets )
28
31
. map ( ( project ) => project . name )
29
32
. 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