Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
typescript-bot committed Oct 21, 2024
1 parent b98ee74 commit 857efbc
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 13 deletions.
19 changes: 14 additions & 5 deletions packages/definitions-parser/src/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,13 @@ console.log(jQuery);
);

const allowedDep = dt.pkgDir("allowed-dep");
allowedDep.set("package.json", packageJson("allowed-dep", "1.0", { "prettier": "*" }));
allowedDep.set("package.json", packageJson("allowed-dep", "1.0", { prettier: "*" }));

const nonAllowedDep = dt.pkgDir("non-allowed-dep");
nonAllowedDep.set("package.json", packageJson("non-allowed-dep", "1.0", { "not-allowed": "*" }));

const allowedPeerDep = dt.pkgDir("allowed-peer-dep");
allowedPeerDep.set("package.json", packageJson("allowed-peer-dep", "1.0", {}, { "prettier": "*" }));
allowedPeerDep.set("package.json", packageJson("allowed-peer-dep", "1.0", {}, { prettier: "*" }));

const nonAllowedPeerDep = dt.pkgDir("non-allowed-peer-dep");
nonAllowedPeerDep.set("package.json", packageJson("non-allowed-peer-dep", "1.0", {}, { "not-allowed-peer": "*" }));
Expand Down Expand Up @@ -299,7 +299,12 @@ ${testNames.map((s) => " " + JSON.stringify(s)).join(",\n")}
}`;
}

function packageJson(packageName: string, version: string, dependencies: Record<string, string>, peerDependencies?: Record<string, string>) {
function packageJson(
packageName: string,
version: string,
dependencies: Record<string, string>,
peerDependencies?: Record<string, string>,
) {
return `{
"private": true,
"name": "@types/${packageName}",
Expand All @@ -314,11 +319,15 @@ function packageJson(packageName: string, version: string, dependencies: Record<
.map(([name, version]) => ` "${name}": "${version}"`)
.join(",\n")}
},
${peerDependencies ? `"peerDependencies": {
${
peerDependencies
? `"peerDependencies": {
${Object.entries(peerDependencies)
.map(([name, version]) => ` "${name}": "${version}"`)
.join(",\n")}
},` : ""}
},`
: ""
}
"devDependencies": {
"@types/${packageName}": "workspace:."
}
Expand Down
4 changes: 2 additions & 2 deletions packages/definitions-parser/test/definition-parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ import route = require('@ember/routing/route');
return expect(getTypingInfo("non-allowed-dep", dt.fs)).resolves.toEqual({
errors: [
"In package.json: Dependency not-allowed not in the allowed dependencies list.\n" +
"Please make a pull request to microsoft/DefinitelyTyped-tools adding it to `packages/definitions-parser/allowedPackageJsonDependencies.txt`.",
"Please make a pull request to microsoft/DefinitelyTyped-tools adding it to `packages/definitions-parser/allowedPackageJsonDependencies.txt`.",
],
});
});
Expand All @@ -459,7 +459,7 @@ import route = require('@ember/routing/route');
return expect(getTypingInfo("non-allowed-peer-dep", dt.fs)).resolves.toEqual({
errors: [
"In package.json: Dependency not-allowed-peer not in the allowed dependencies list.\n" +
"Please make a pull request to microsoft/DefinitelyTyped-tools adding it to `packages/definitions-parser/allowedPackageJsonDependencies.txt`.",
"Please make a pull request to microsoft/DefinitelyTyped-tools adding it to `packages/definitions-parser/allowedPackageJsonDependencies.txt`.",
],
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/definitions-parser/test/packages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe(TypingsData, () => {
},
{
"peer-dependency-1": "*",
}
},
);
data = new TypingsData(dt.fs, versions["1.0"], true);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ const rule = createRule({
}
return dep;
})
.filter((dep) => dep !== info.realName && packageJson.dependencies?.[dep] === undefined && packageJson.peerDependencies?.[dep] === undefined); // TODO(jakebailey): add test for this case from https://github.com/microsoft/DefinitelyTyped-tools/pull/773
.filter(
(dep) =>
dep !== info.realName &&
packageJson.dependencies?.[dep] === undefined &&
packageJson.peerDependencies?.[dep] === undefined,
); // TODO(jakebailey): add test for this case from https://github.com/microsoft/DefinitelyTyped-tools/pull/773

commentsMatching(context.sourceCode, /<reference\s+types\s*=\s*"(.+)"\s*\/>/, (ref, comment) => {
if (devDeps.includes(ref)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/mergebot/src/pr-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ configSuspicious["package.json"] = makeChecker({}, urls.packageJson, {
return { peerDependencies: data.peerDependencies };
}
return {};
}
},
});
configSuspicious[".npmignore"] = () => undefined;
configSuspicious["tsconfig.json"] = makeChecker(
Expand Down
4 changes: 3 additions & 1 deletion packages/publisher/src/generate-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ export function createReadme(typing: TypingsData, packageFS: FS): string {
lines.push("");
const peerDependencies = Object.keys(typing.peerDependencies).sort();
if (peerDependencies.length) {
lines.push(` * Peer dependencies: ${peerDependencies.map((d) => `[${d}](https://npmjs.com/package/${d})`).join(", ")}`);
lines.push(
` * Peer dependencies: ${peerDependencies.map((d) => `[${d}](https://npmjs.com/package/${d})`).join(", ")}`,
);
lines.push("");
}

Expand Down
4 changes: 2 additions & 2 deletions packages/publisher/test/generate-packages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function createRawPackage(license: License): TypingsDataRaw {
typesVersions: [],
license,
dependencies: { "@types/madeira": "^1" },
peerDependencies: { "@types/express": "*"},
peerDependencies: { "@types/express": "*" },
devDependencies: { "@types/jquery": "workspace:." },
olderVersionDirectories: [],
};
Expand All @@ -58,7 +58,7 @@ function defaultFS() {
{ name: "E", githubUsername: "e" },
],
dependencies: { "@types/madeira": "^1" },
peerDependencies: { "@types/express": "*"},
peerDependencies: { "@types/express": "*" },
devDependencies: { "@types/jquery": "workspace:." },
},
undefined,
Expand Down

0 comments on commit 857efbc

Please sign in to comment.