@@ -17,7 +17,7 @@ const {
17
17
globPatternValidator,
18
18
} = require ( '../utils/validation' ) ;
19
19
const { getDocUrl } = require ( '../utils/doc' ) ;
20
- const { isNotEmpty } = require ( '../utils/utility' ) ;
20
+ const { isNotEmpty, isNil } = require ( '../utils/utility' ) ;
21
21
const NAMING_CONVENTION = require ( '../constants/naming-convention' ) ;
22
22
const {
23
23
FOLDER_NAMING_CONVENTION_ERROR_MESSAGE ,
@@ -73,31 +73,29 @@ module.exports = {
73
73
continue ;
74
74
}
75
75
for ( const path of getSubPaths ( folderPath ) ) {
76
- if ( ! micromatch . isMatch ( path , folderPattern ) ) {
77
- continue ;
78
- } else {
79
- const matchedPaths =
80
- micromatch . capture ( folderPattern , path ) || [ ] ;
81
- const folders = matchedPaths
82
- . filter ( isNotEmpty )
83
- . reduce ( ( s , p ) => s . concat ( getAllFolders ( p ) ) , [ ] ) ;
76
+ const matchedPaths = micromatch . capture ( folderPattern , path ) ;
84
77
85
- for ( const folder of folders ) {
86
- if (
87
- ! micromatch . isMatch (
78
+ if ( isNil ( matchedPaths ) ) continue ;
79
+
80
+ const folders = matchedPaths
81
+ . filter ( isNotEmpty )
82
+ . reduce ( ( s , p ) => s . concat ( getAllFolders ( p ) ) , [ ] ) ;
83
+
84
+ for ( const folder of folders ) {
85
+ if (
86
+ ! micromatch . isMatch (
87
+ folder ,
88
+ NAMING_CONVENTION [ namingPattern ] || namingPattern
89
+ )
90
+ ) {
91
+ context . report ( {
92
+ node,
93
+ message : FOLDER_NAMING_CONVENTION_ERROR_MESSAGE (
88
94
folder ,
89
- NAMING_CONVENTION [ namingPattern ] || namingPattern
90
- )
91
- ) {
92
- context . report ( {
93
- node,
94
- message : FOLDER_NAMING_CONVENTION_ERROR_MESSAGE (
95
- folder ,
96
- namingPattern
97
- ) ,
98
- } ) ;
99
- return ;
100
- }
95
+ namingPattern
96
+ ) ,
97
+ } ) ;
98
+ return ;
101
99
}
102
100
}
103
101
}
0 commit comments