Skip to content

Commit

Permalink
chore(deps): align @types dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mxdvl committed Jan 17, 2023
1 parent a6d096c commit df27387
Show file tree
Hide file tree
Showing 3 changed files with 251 additions and 168 deletions.
84 changes: 42 additions & 42 deletions dotcom-rendering/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,41 +107,41 @@
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^12.1.5",
"@testing-library/user-event": "^13.5.0",
"@types/amphtml-validator": "^1.0.1",
"@types/compression": "^0.0.36",
"@types/crypto-js": "^4.1.1",
"@types/dompurify": "^2.3.3",
"@types/express": "^4.17.11",
"@types/amphtml-validator": "~1.0",
"@types/compression": "~1.7",
"@types/crypto-js": "~4.1",
"@types/dompurify": "~2.4",
"@types/express": "~4.17",
"@types/gapi.analytics": "^0.0.4",
"@types/google.analytics": "^0.0.42",
"@types/he": "^1.1.1",
"@types/html-minifier": "^4.0.2",
"@types/jest": "^27.4.0",
"@types/jsdom": "^16.2.10",
"@types/lodash.debounce": "^4.0.7",
"@types/lodash.get": "^4.4.7",
"@types/he": "~1.1",
"@types/html-minifier": "~4.0",
"@types/jest": "~24.9",
"@types/jsdom": "~20.0",
"@types/lodash.debounce": "~4.0",
"@types/lodash.get": "~4.4",
"@types/node": "^14.18.36",
"@types/node-fetch": "^2.6.1",
"@types/node-fetch": "~2.6",
"@types/raven-js": "^3.10.0",
"@types/react": "^17.0.52",
"@types/react-dom": "^17.0.18",
"@types/react-google-recaptcha": "^2.1.5",
"@types/react": "~17.0",
"@types/react-dom": "~17.0",
"@types/react-google-recaptcha": "~2.1",
"@types/react-test-renderer": "18.0.0",
"@types/response-time": "^2.3.4",
"@types/rimraf": "^3.0.2",
"@types/sanitize-html": "^2.6.0",
"@types/response-time": "~2.3",
"@types/rimraf": "~3.0",
"@types/sanitize-html": "~2.6",
"@types/twitter-for-web": "^0.0.2",
"@types/uuid": "^8.3.4",
"@types/webpack-bundle-analyzer": "^4.4.1",
"@types/uuid": "~8.3",
"@types/webpack-bundle-analyzer": "~4.4",
"@types/webpack-env": "^1.18.0",
"@types/webpack-node-externals": "^2.5.3",
"@types/webpack-node-externals": "~2.5",
"@types/youtube": "^0.0.46",
"@typescript-eslint/eslint-plugin": "^5",
"@typescript-eslint/eslint-plugin-tslint": "^5.20.0",
"@typescript-eslint/parser": "^5",
"ajv": "^8.1.0",
"ajv-formats": "^2.0.2",
"amphtml-validator": "^1.0.34",
"amphtml-validator": "~1.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^27.5.1",
"babel-loader": "^8.2.5",
Expand All @@ -152,17 +152,17 @@
"browserslist": "^4.21.4",
"bundlesize": "^0.18.1",
"chalk": "^4.1.0",
"compression": "^1.7.3",
"compression": "~1.7",
"cpy": "^8.1.2",
"crypto-js": "^4.1.1",
"crypto-js": "~4.1",
"curlyquotes": "^1.5.5",
"cypress": "^10.3.0",
"cypress-plugin-tab": "^1.0.5",
"cypress-wait-until": "^1.7.1",
"cypress-webpack-preprocessor-v5": "^5.0.0-alpha.1",
"desvg-loader": "^0.1.0",
"doctoc": "^2.2.1",
"dompurify": "^2.3.6",
"dompurify": "~2.4",
"dynamic-import-polyfill": "^0.1.1",
"eslint": "^8.28.0",
"eslint-config-airbnb-base": "^15.0.0",
Expand All @@ -178,26 +178,26 @@
"eslint-plugin-react-hooks": "^4.5.0",
"eslint-stats": "^1.0.1",
"execa": "^5.0.0",
"express": "^4.17.3",
"express": "~4.17",
"fetch-mock": "^9.11.0",
"find": "^0.3.0",
"glob": "^8.0.3",
"he": "^1.2.0",
"html-minifier": "^4.0.0",
"he": "~1.2",
"html-minifier": "~4.0",
"htmlparser2": "^7.2.0",
"inquirer": "^8.2.4",
"jest": "^24.9.0",
"jest": "~24.9",
"jest-environment-jsdom-sixteen": "^1.0.3",
"jest-teamcity-reporter": "^0.9.0",
"jsdom": "^20.0.0",
"jsdom": "~20.0",
"lighthouse": "^7.3.0",
"lint-staged": "^12.3.4",
"load-json-file": "^6.2.0",
"lodash.debounce": "^4.0.8",
"lodash.get": "^4.4.2",
"lodash.debounce": "~4.0",
"lodash.get": "~4.4",
"log4js": "6.5.1",
"mockdate": "^3.0.5",
"node-fetch": "2.6.7",
"node-fetch": "~2.6",
"nodemon": "^2.0.7",
"npm-run-all": "^4.1.5",
"ophan-tracker-js": "^1.3.29",
Expand All @@ -206,14 +206,14 @@
"preact-render-to-string": "^5.1.19",
"prettier-eslint": "^15.0.1",
"pretty-bytes": "^6.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-google-recaptcha": "^2.1.0",
"react": "~17.0",
"react-dom": "~17.0",
"react-google-recaptcha": "~2.1",
"regenerator-runtime": "^0.13.7",
"require-from-string": "^2.0.2",
"response-time": "^2.3.2",
"rimraf": "^3.0.2",
"sanitize-html": "^2.6.0",
"response-time": "~2.3",
"rimraf": "~3.0",
"sanitize-html": "~2.6",
"simple-progress-webpack-plugin": "^2.0.0",
"snyk": "^1.1066.0",
"start-server-and-test": "^1.12.1",
Expand All @@ -231,11 +231,11 @@
"ts-unused-exports": "^8.0.0",
"tslib": "^2.4.0",
"typescript-json-schema": "^0.54.0",
"uuid": "^8.3.2",
"uuid": "~8.3",
"web-vitals": "^2.1.0",
"webpack": "^5.51.1",
"webpack-assets-manifest": "^5.1.0",
"webpack-bundle-analyzer": "^4.4.0",
"webpack-bundle-analyzer": "~4.4",
"webpack-cli": "^4.5.0",
"webpack-dev-middleware": "^5.3.1",
"webpack-dev-server": "^4.7.4",
Expand All @@ -245,7 +245,7 @@
"webpack-manifest-plugin": "^5.0.0",
"webpack-merge": "^5.7.3",
"webpack-messages": "^2.0.4",
"webpack-node-externals": "^3.0.0",
"webpack-node-externals": "~3.0",
"webpack-sources": "^3.2.3"
},
"resolutions": {
Expand Down
27 changes: 16 additions & 11 deletions scripts/deno/types-dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,29 @@ import { octokit } from './github.ts';

const prefix = '@types/';

/**
* We only look at major.minor versions as per DefinitelyTyped docs:
* https://github.com/DefinitelyTyped/DefinitelyTyped#how-do-definitely-typed-package-versions-relate-to-versions-of-the-corresponding-library
*/
const majorMinorVersions = Object.entries(pkg.dependencies).map(
([dependency, version]) =>
[dependency, version.match(/(\d+\.\d+)/)?.at(0)] as const,
);

const dependencies = majorMinorVersions
const dependencies = Object.entries(pkg.dependencies)
.filter(([dependency]) => dependency.startsWith(prefix))
.map(([dependency, version]) => ({
main: majorMinorVersions.find(
main: Object.entries(pkg.dependencies).find(
([dep]) => dep === dependency.replace(prefix, ''),
),
type: [dependency, version] as const,
}));

/**
* We only look at major.minor versions as per DefinitelyTyped docs:
* https://github.com/DefinitelyTyped/DefinitelyTyped#how-do-definitely-typed-package-versions-relate-to-versions-of-the-corresponding-library
*/
const nonTildeVersions = dependencies.filter(
({ main, type: [, version] }) => !!main && !version.startsWith('~'),
);

if (nonTildeVersions.length) {
console.error('Some @types/ definition are not using a tilde range');
console.error(nonTildeVersions.map(({ type: [dep] }) => dep));
Deno.exit(1);
}

const body = `## Audit of \`@types/\` packages
### No main package found
Expand Down
Loading

0 comments on commit df27387

Please sign in to comment.