Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions eng/tools/typespec-validation/src/rules/folder-structure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export class FolderStructureRule implements Rule {
}
});

// Verify top level folder is lower case
let folderStruct = relativePath.split("/");
// Verify top level folder is lower case and remove empty entries when splitting by slash
let folderStruct = relativePath.split("/").filter(Boolean);
if (folderStruct[1].match(/[A-Z]/g)) {
success = false;
errorOutput += `Invalid folder name. Folders under specification/ must be lower case.\n`;
Expand Down
16 changes: 16 additions & 0 deletions eng/tools/typespec-validation/test/folder-structure.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ describe("folder-structure", function () {
assert(result.errorOutput.includes("must be lower case"));
});

it("should succeed if package folder has trailing slash", async function () {
let host = new TsvTestHost();
host.globby = async () => {
return ["/foo/bar/tspconfig.yaml"];
};
host.normalizePath = () => {
return "/gitroot";
};

const result = await new FolderStructureRule().execute(
host,
"/gitroot/specification/foo/Foo/Foo/",
);
assert(result.success);
});

it("should fail if package folder is more than 3 levels deep", async function () {
let host = new TsvTestHost();
host.globby = async () => {
Expand Down