Skip to content

Commit

Permalink
Error on versioned directories when parent npmignores are missing sub…
Browse files Browse the repository at this point in the history
…dir (#971)
  • Loading branch information
jakebailey authored Mar 4, 2024
1 parent b4d4432 commit 465dbce
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/hot-dogs-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@definitelytyped/dtslint": patch
---

Error on versioned directories when parent npmignores are missing subdir
11 changes: 11 additions & 0 deletions packages/dtslint/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,17 @@ function checkExpectedFiles(dirPath: string, isLatest: boolean): { errors: strin
expectedNpmIgnore.push(`/${subdir.name}/`);
}
}
} else {
const thisDir = `/${basename(dirPath)}/`;
const parentNpmIgnorePath = joinPaths(dirname(dirPath), ".npmignore");
if (!fs.existsSync(parentNpmIgnorePath)) {
errors.push(`${dirPath}: Missing parent '.npmignore'`);
} else {
const parentNpmIgnore = fs.readFileSync(parentNpmIgnorePath, "utf-8").trim().split(/\r?\n/);
if (!parentNpmIgnore.includes(thisDir)) {
errors.push(`${dirPath}: Parent package '.npmignore' should contain ${thisDir}`);
}
}
}

const expectedNpmIgnoreAsString = expectedNpmIgnore.join("\n");
Expand Down

0 comments on commit 465dbce

Please sign in to comment.