Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-16845] Lint unowned dependencies #12748

Merged
merged 10 commits into from
Jan 8, 2025
16 changes: 13 additions & 3 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@
"matchPackageNames": [
"@babel/core",
"@babel/preset-env",
"@bitwarden/sdk-internal",
"@electron/fuses",
"@electron/notarize",
"@electron/rebuild",
"@ngtools/webpack",
Expand All @@ -115,7 +117,7 @@
"@types/node",
"@types/node-forge",
"@types/node-ipc",
"@yao-pkg",
"@yao-pkg/pkg",
"babel-loader",
"browserslist",
"copy-webpack-plugin",
Expand All @@ -135,6 +137,7 @@
"tsconfig-paths-webpack-plugin",
"type-fest",
"typescript",
"typescript-strict-plugin",
"webpack",
"webpack-cli",
"webpack-dev-server",
Expand All @@ -151,21 +154,25 @@
"@angular/cdk",
"@angular/cli",
"@angular/common",
"@angular/compiler",
"@angular/compiler-cli",
"@angular/compiler",
"@angular/core",
"@angular/forms",
"@angular/platform-browser-dynamic",
"@angular/platform-browser",
"@angular/platform",
"@angular/compiler",
"@angular/router",
"@compodoc/compodoc",
"@ng-select/ng-select",
"@storybook/addon-a11y",
"@storybook/addon-actions",
"@storybook/addon-designs",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
"@storybook/addon-links",
"@storybook/angular",
"@storybook/manager-api",
"@storybook/theming",
"@types/react",
"autoprefixer",
"bootstrap",
Expand All @@ -188,7 +195,9 @@
"matchPackageNames": [
"@angular-eslint/eslint-plugin",
"@angular-eslint/eslint-plugin-template",
"@angular-eslint/schematics",
"@angular-eslint/template-parser",
"@angular/elements",
"@types/jest",
"@typescript-eslint/eslint-plugin",
"@typescript-eslint/parser",
Expand All @@ -201,6 +210,7 @@
"eslint-plugin-storybook",
"eslint-plugin-tailwindcss",
"husky",
"jest-extended",
"jest-junit",
"jest-mock-extended",
"jest-preset-angular",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"test:watch:all": "jest --watchAll",
"test:types": "node ./scripts/test-types.js",
"test:locales": "tsc --project ./scripts/tsconfig.json && node ./scripts/dist/test-locales.js",
"lint:dep-ownership": "tsc --project ./scripts/tsconfig.json && node ./scripts/dist/dep-ownership.js",
"docs:json": "compodoc -p ./tsconfig.json -e json -d . --disableRoutesGraph",
"storybook": "ng run components:storybook",
"build-storybook": "ng run components:build-storybook",
Expand Down
31 changes: 31 additions & 0 deletions scripts/dep-ownership.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* eslint-disable no-console */

/// Ensure that all dependencies in package.json have an owner in the renovate.json file.

import fs from "fs";
import path from "path";

const renovateConfig = JSON.parse(
fs.readFileSync(path.join(__dirname, "..", "..", ".github", "renovate.json"), "utf8"),
);

const packagesWithOwners = renovateConfig.packageRules
.flatMap((rule: any) => rule.matchPackageNames)
.filter((packageName: string) => packageName != null);

const packageJson = JSON.parse(
fs.readFileSync(path.join(__dirname, "..", "..", "package.json"), "utf8"),
);
const dependencies = Object.keys(packageJson.dependencies).concat(
Object.keys(packageJson.devDependencies),
);

const missingOwners = dependencies.filter((dep) => !packagesWithOwners.includes(dep));

if (missingOwners.length > 0) {
console.error("Missing owners for the following dependencies:");
console.error(missingOwners.join("\n"));
process.exit(1);
}

console.log("All dependencies have owners.");
Loading