Skip to content

Commit a8a3148

Browse files
committed
refactor: return early when nothing matches in the file path for rule folder-naming-convention
1 parent 2bdeb3a commit a8a3148

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/rules/folder-naming-convention.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,14 @@ module.exports = {
6565

6666
const filenameWithPath = getFilePath(context);
6767
const folderPath = getFolderPath(filenameWithPath);
68-
const subPaths = getSubPaths(folderPath);
6968

70-
for (const path of subPaths) {
71-
for (const [folderPattern, namingPattern] of Object.entries(rules)) {
69+
for (const [folderPattern, namingPattern] of Object.entries(rules)) {
70+
if (
71+
!micromatch.isMatch(folderPath, folderPattern, { contains: true })
72+
) {
73+
continue;
74+
}
75+
for (const path of getSubPaths(folderPath)) {
7276
if (!micromatch.isMatch(path, folderPattern)) {
7377
continue;
7478
} else {

0 commit comments

Comments
 (0)