From 28df2057fd4e57d9773b5554ac3b64d49ee1c540 Mon Sep 17 00:00:00 2001 From: Jack Hsu Date: Wed, 19 Jul 2023 17:07:52 -0400 Subject: [PATCH] chore(repo): replace dep check script with new lint rule (#18060) --- .circleci/config.yml | 2 +- CODEOWNERS | 1 - package.json | 3 - packages/angular/.eslintrc.json | 61 ++++ packages/angular/package.json | 5 +- packages/create-nx-plugin/.eslintrc.json | 12 + packages/create-nx-plugin/package.json | 1 + packages/create-nx-workspace/.eslintrc.json | 12 + packages/cypress/.eslintrc.json | 20 ++ packages/cypress/package.json | 3 +- packages/detox/.eslintrc.json | 13 + packages/detox/package.json | 3 +- packages/devkit/.eslintrc.json | 23 ++ packages/esbuild/.eslintrc.json | 13 + packages/eslint-plugin/.eslintrc.json | 20 ++ packages/eslint-plugin/package.json | 3 +- packages/expo/.eslintrc.json | 24 ++ packages/expo/package.json | 1 + packages/express/.eslintrc.json | 19 ++ packages/express/package.json | 3 +- packages/jest/.eslintrc.json | 21 ++ packages/js/.eslintrc.json | 31 ++ packages/linter/.eslintrc.json | 21 ++ packages/nest/.eslintrc.json | 19 ++ packages/nest/package.json | 4 +- packages/next/.eslintrc.json | 25 ++ packages/next/package.json | 3 +- .../executors/server/lib/default-server.ts | 34 --- packages/node/.eslintrc.json | 13 + packages/nx/.eslintrc.json | 30 ++ packages/playwright/.eslintrc.json | 13 + packages/playwright/package.json | 3 +- packages/plugin/.eslintrc.json | 13 + packages/react-native/.eslintrc.json | 23 ++ packages/react-native/package.json | 1 + packages/react/.eslintrc.json | 55 ++++ packages/react/package.json | 1 + packages/rollup/.eslintrc.json | 20 ++ packages/storybook/.eslintrc.json | 19 ++ packages/storybook/package.json | 1 + packages/tao/.eslintrc.json | 13 + packages/tao/package.json | 3 +- packages/vite/.eslintrc.json | 13 + packages/web/.eslintrc.json | 24 ++ packages/webpack/.eslintrc.json | 29 ++ packages/workspace/.eslintrc.json | 20 ++ packages/workspace/package.json | 12 - pnpm-lock.yaml | 138 --------- scripts/depcheck/discrepancies.ts | 32 --- scripts/depcheck/index.ts | 132 --------- scripts/depcheck/missing.ts | 271 ------------------ scripts/depcheck/unused.ts | 104 ------- 52 files changed, 643 insertions(+), 740 deletions(-) delete mode 100644 packages/next/src/executors/server/lib/default-server.ts delete mode 100644 scripts/depcheck/discrepancies.ts delete mode 100644 scripts/depcheck/index.ts delete mode 100644 scripts/depcheck/missing.ts delete mode 100644 scripts/depcheck/unused.ts diff --git a/.circleci/config.yml b/.circleci/config.yml index ee767f57a1370..bbd8f17ac79ed 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -187,7 +187,7 @@ jobs: pnpm nx-cloud record -- nx format:check --base=$NX_BASE --head=$NX_HEAD & pids+=($!) - pnpm nx run-many -t check-imports check-commit check-lock-files depcheck check-codeowners documentation --parallel=1 --no-dte & + pnpm nx run-many -t check-imports check-commit check-lock-files check-codeowners documentation --parallel=1 --no-dte & pids+=($!) pnpm nx affected --target=lint --base=$NX_BASE --head=$NX_HEAD --parallel=3 & diff --git a/CODEOWNERS b/CODEOWNERS index 3f039747aebfd..17d3f9e385a77 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -161,7 +161,6 @@ pnpm-lock.yaml @nrwl/nx-pipelines-reviewers /CODEOWNERS @FrozenPandaz @AgentEnder # Scripts -/scripts/depcheck @FrozenPandaz @vsavkin @jaysoo /scripts/documentation @nrwl/nx-docs-reviewers /scripts/angular-support-upgrades @nrwl/nx-angular-reviewers diff --git a/package.json b/package.json index 1870ee8e9524d..fba5e2e550b42 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,6 @@ "nx-release": "ts-node -P ./scripts/tsconfig.release.json ./scripts/nx-release", "prepublishOnly": "node ./scripts/update-package-group.js", "version": "pnpm prettier lerna.json --write", - "depcheck": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/depcheck", "local-registry": "nx local-registry @nx/nx-source", "documentation": "ts-node -P scripts/tsconfig.scripts.json ./scripts/documentation/generators/main.ts && pnpm check-documentation-map", "submit-plugin": "node ./scripts/submit-plugin.js", @@ -153,7 +152,6 @@ "cytoscape-popper": "^2.0.0", "cz-git": "^1.4.0", "czg": "^1.4.0", - "depcheck": "^1.3.1", "detect-port": "^1.5.1", "dotenv": "~10.0.0", "ejs": "^3.1.7", @@ -352,7 +350,6 @@ "check-imports", "check-lock-files", "check-codeowners", - "depcheck", "documentation" ] }, diff --git a/packages/angular/.eslintrc.json b/packages/angular/.eslintrc.json index a5d6238a0af6f..f9eb90627c72b 100644 --- a/packages/angular/.eslintrc.json +++ b/packages/angular/.eslintrc.json @@ -33,6 +33,67 @@ "rules": { "@nx/nx-plugin-checks": "error" } + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": [ + "nx", + "eslint", + "rxjs", + "semver", + // These are installed by ensurePackage so missing in package.json + "@nx/cypress", + "@nx/jest", + "@nx/rollup", + "@nx/storybook", + "@nx/vite", + "@nx/webpack", + "prettier", + "typescript", + // These are installed by generators + "@angular-devkit/core", + "@angular-devkit/architect", + "@angular-devkit/build-angular", + "@angular-devkit/schematics", + "@angular/compiler", + "@angular/compiler-cli", + "@angular/core", + "@angular/router", + "@ngrx/effects", + "@ngrx/router-store", + "@ngrx/store", + "@storybook/angular", + "@module-federation/node", + // installed dynamically by the library generator + "ng-packagr", + // ng-packagr deps, some are handled if not installed + "injection-js", + "browserslist", + "cacache", + "less", + "node-sass", + "node-sass-tilde-importer", + "ora", + "convert-source-map", + "postcss", + "postcss-import", + "postcss-preset-env", + "postcss-url", + "sass", + "stylus", + "tailwindcss", + // used in the CT angular plugin where Cy is already installed to use it. + "cypress" + ] + } + ] + } } ] } diff --git a/packages/angular/package.json b/packages/angular/package.json index 22e00320ee764..f08a5ca817c85 100644 --- a/packages/angular/package.json +++ b/packages/angular/package.json @@ -48,15 +48,14 @@ "@phenomnomnominal/tsquery": "~5.0.1", "@typescript-eslint/type-utils": "^5.36.1", "chalk": "^4.1.0", - "chokidar": "^3.5.1", "find-cache-dir": "^3.3.2", - "http-server": "^14.1.0", "ignore": "^5.0.4", "magic-string": "~0.26.2", "minimatch": "3.0.5", "semver": "7.5.3", + "tslib": "^2.3.0", "webpack": "^5.80.0", - "webpack-merge": "5.7.3", + "webpack-merge": "^5.8.0", "enquirer": "^2.3.6", "@nx/cypress": "file:../cypress", "@nx/devkit": "file:../devkit", diff --git a/packages/create-nx-plugin/.eslintrc.json b/packages/create-nx-plugin/.eslintrc.json index b7717ac0ddf9a..2a04d796eb24d 100644 --- a/packages/create-nx-plugin/.eslintrc.json +++ b/packages/create-nx-plugin/.eslintrc.json @@ -24,6 +24,18 @@ { "files": ["*.js", "*.jsx"], "rules": {} + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"] + } + ] + } } ] } diff --git a/packages/create-nx-plugin/package.json b/packages/create-nx-plugin/package.json index df0f020b07ec7..ac1a55894a385 100644 --- a/packages/create-nx-plugin/package.json +++ b/packages/create-nx-plugin/package.json @@ -32,6 +32,7 @@ "create-nx-workspace": "file:../create-nx-workspace", "chalk": "^4.1.0", "enquirer": "~2.3.6", + "tslib": "^2.3.0", "yargs": "^17.6.2" }, "publishConfig": { diff --git a/packages/create-nx-workspace/.eslintrc.json b/packages/create-nx-workspace/.eslintrc.json index b7717ac0ddf9a..2a04d796eb24d 100644 --- a/packages/create-nx-workspace/.eslintrc.json +++ b/packages/create-nx-workspace/.eslintrc.json @@ -24,6 +24,18 @@ { "files": ["*.js", "*.jsx"], "rules": {} + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"] + } + ] + } } ] } diff --git a/packages/cypress/.eslintrc.json b/packages/cypress/.eslintrc.json index 1410ed8f5dc5b..9e585b3a1b219 100644 --- a/packages/cypress/.eslintrc.json +++ b/packages/cypress/.eslintrc.json @@ -24,6 +24,26 @@ "rules": { "@nx/nx-plugin-checks": "error" } + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": [ + "nx", + "typescript", + // Type imports only + "eslint", + "rollup", + "vite" + ] + } + ] + } } ], "ignorePatterns": ["!**/*"] diff --git a/packages/cypress/package.json b/packages/cypress/package.json index 93eb2a05a3e22..7181a7ca6529e 100644 --- a/packages/cypress/package.json +++ b/packages/cypress/package.json @@ -35,9 +35,10 @@ }, "dependencies": { "@phenomnomnominal/tsquery": "~5.0.1", + "detect-port": "^1.5.1", "dotenv": "~10.0.0", "semver": "7.5.3", - "detect-port": "^1.5.1", + "tslib": "^2.3.0", "@nx/devkit": "file:../devkit", "@nx/js": "file:../js", "@nx/linter": "file:../linter" diff --git a/packages/detox/.eslintrc.json b/packages/detox/.eslintrc.json index 538ec128dd4f0..652ae83671c1b 100644 --- a/packages/detox/.eslintrc.json +++ b/packages/detox/.eslintrc.json @@ -14,6 +14,19 @@ "rules": { "@nx/nx-plugin-checks": "error" } + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": ["nx", "typescript", "detox"] + } + ] + } } ] } diff --git a/packages/detox/package.json b/packages/detox/package.json index 23ea61cbdf076..8437047ae186d 100644 --- a/packages/detox/package.json +++ b/packages/detox/package.json @@ -29,7 +29,8 @@ "@nx/jest": "file:../jest", "@nx/js": "file:../js", "@nx/linter": "file:../linter", - "@nx/react": "file:../react" + "@nx/react": "file:../react", + "tslib": "^2.3.0" }, "peerDependencies": { "detox": "^20.9.0" diff --git a/packages/devkit/.eslintrc.json b/packages/devkit/.eslintrc.json index db3f037515f47..29aa362d1c72b 100644 --- a/packages/devkit/.eslintrc.json +++ b/packages/devkit/.eslintrc.json @@ -50,6 +50,29 @@ "rules": { "@nx/nx-plugin-checks": "error" } + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": [ + "nx", + "typescript", + "prettier", + // Installed to workspace by plugins + "rxjs", + "@angular-devkit/core", + "@angular-devkit/architect", + "@angular-devkit/schematics", + "webpack" + ] + } + ] + } } ] } diff --git a/packages/esbuild/.eslintrc.json b/packages/esbuild/.eslintrc.json index 4cf7f347f6a85..c24063c65cc0b 100644 --- a/packages/esbuild/.eslintrc.json +++ b/packages/esbuild/.eslintrc.json @@ -20,6 +20,19 @@ "rules": { "@nx/nx-plugin-checks": "error" } + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": ["nx", "typescript", "esbuild"] + } + ] + } } ] } diff --git a/packages/eslint-plugin/.eslintrc.json b/packages/eslint-plugin/.eslintrc.json index a40930e8b428f..86666f71669f0 100644 --- a/packages/eslint-plugin/.eslintrc.json +++ b/packages/eslint-plugin/.eslintrc.json @@ -22,6 +22,26 @@ { "files": ["*.js", "*.jsx"], "rules": {} + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": [ + "nx", + "typescript", + // Installed to workspace by plugins + "@typescript-eslint/parser", + "eslint-config-prettier", + "@angular-eslint/eslint-plugin" + ] + } + ] + } } ] } diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 02c6a5615849a..bf155b59a0031 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -40,7 +40,8 @@ "chalk": "^4.1.0", "confusing-browser-globals": "^1.0.9", "jsonc-eslint-parser": "^2.1.0", - "semver": "7.5.3" + "semver": "7.5.3", + "tslib": "^2.3.0" }, "publishConfig": { "access": "public" diff --git a/packages/expo/.eslintrc.json b/packages/expo/.eslintrc.json index 538ec128dd4f0..7d17ab0ff9d08 100644 --- a/packages/expo/.eslintrc.json +++ b/packages/expo/.eslintrc.json @@ -14,6 +14,30 @@ "rules": { "@nx/nx-plugin-checks": "error" } + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": [ + "nx", + "@nx/rollup", + "@nx/webpack", + "typescript", + "eslint", + "expo", + "react", + "@expo/cli", + "eas-cli", + "util" // This is coming from @storybook/builder-manager since it uses the browser polyfill + ] + } + ] + } } ] } diff --git a/packages/expo/package.json b/packages/expo/package.json index f39394ca2ffe7..d0fe2c5b6b9d3 100644 --- a/packages/expo/package.json +++ b/packages/expo/package.json @@ -33,6 +33,7 @@ "metro-resolver": "0.76.7", "node-fetch": "^2.6.7", "tar-fs": "^2.1.1", + "tslib": "^2.3.0", "tsconfig-paths": "^4.1.2", "tsconfig-paths-webpack-plugin": "^4.0.0", "@nx/detox": "file:../detox", diff --git a/packages/express/.eslintrc.json b/packages/express/.eslintrc.json index 0b6554fa779f3..cd27ca0d46d2a 100644 --- a/packages/express/.eslintrc.json +++ b/packages/express/.eslintrc.json @@ -34,6 +34,25 @@ "rules": { "@nx/nx-plugin-checks": "error" } + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": [ + "nx", + "@nx/linter", + "typescript", + "eslint", + "express" + ] + } + ] + } } ] } diff --git a/packages/express/package.json b/packages/express/package.json index 9f8319d27bcdb..0d7e951b8bd01 100644 --- a/packages/express/package.json +++ b/packages/express/package.json @@ -31,7 +31,8 @@ }, "dependencies": { "@nx/devkit": "file:../devkit", - "@nx/node": "file:../node" + "@nx/node": "file:../node", + "tslib": "^2.3.0" }, "peerDependencies": { "express": "^4.18.1" diff --git a/packages/jest/.eslintrc.json b/packages/jest/.eslintrc.json index 1410ed8f5dc5b..ad99b67fe4c0a 100644 --- a/packages/jest/.eslintrc.json +++ b/packages/jest/.eslintrc.json @@ -24,6 +24,27 @@ "rules": { "@nx/nx-plugin-checks": "error" } + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": [ + "nx", + "typescript", + "prettier", + "jest", + "@jest/types", + // require.resolve is used for these packages + "identity-obj-proxy" + ] + } + ] + } } ], "ignorePatterns": ["!**/*"] diff --git a/packages/js/.eslintrc.json b/packages/js/.eslintrc.json index f74c8b8e82e38..b14f51b5e8ac1 100644 --- a/packages/js/.eslintrc.json +++ b/packages/js/.eslintrc.json @@ -27,6 +27,37 @@ "rules": { "@nx/nx-plugin-checks": "error" } + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": [ + "nx", + "prettier", + "typescript", + "eslint", + "verdaccio", // Optional, used for local registry + // require.resolve is used for these packages + "source-map-support", + "@babel/core", + "@babel/plugin-proposal-class-properties", + "@babel/plugin-proposal-decorators", + "@babel/plugin-transform-runtime", + "@babel/preset-env", + "@babel/preset-typescript", + "@babel/runtime", + "babel-plugin-const-enum", + "babel-plugin-macros", + "babel-plugin-transform-typescript-metadata" + ] + } + ] + } } ] } diff --git a/packages/linter/.eslintrc.json b/packages/linter/.eslintrc.json index 1410ed8f5dc5b..b87b1dd21c38e 100644 --- a/packages/linter/.eslintrc.json +++ b/packages/linter/.eslintrc.json @@ -24,6 +24,27 @@ "rules": { "@nx/nx-plugin-checks": "error" } + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": [ + "nx", + "@nx/jest", + "typescript", + "eslint", + "tslint-to-eslint-config", + "@angular-devkit/core", + "@typescript-eslint/eslint-plugin" + ] + } + ] + } } ], "ignorePatterns": ["!**/*"] diff --git a/packages/nest/.eslintrc.json b/packages/nest/.eslintrc.json index 0c4dbcba2aabb..cef1596a3cfad 100644 --- a/packages/nest/.eslintrc.json +++ b/packages/nest/.eslintrc.json @@ -34,6 +34,25 @@ "rules": { "@nx/nx-plugin-checks": "error" } + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": [ + "nx", + "typescript", + "eslint", + "nest", + "@nestjs/schematics" + ] + } + ] + } } ] } diff --git a/packages/nest/package.json b/packages/nest/package.json index 85f931c9a739b..fb9eeac789a24 100644 --- a/packages/nest/package.json +++ b/packages/nest/package.json @@ -36,7 +36,9 @@ "@nx/js": "file:../js", "@nx/linter": "file:../linter", "@nx/node": "file:../node", - "@phenomnomnominal/tsquery": "~5.0.1" + "@phenomnomnominal/tsquery": "~5.0.1", + "semver": "7.5.3", + "tslib": "^2.3.0" }, "publishConfig": { "access": "public" diff --git a/packages/next/.eslintrc.json b/packages/next/.eslintrc.json index ca2f609cff772..b7fa759b7ce04 100644 --- a/packages/next/.eslintrc.json +++ b/packages/next/.eslintrc.json @@ -68,6 +68,31 @@ "rules": { "@nx/nx-plugin-checks": "error" } + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": [ + "nx", + "@nx/webpack", + "@nx/cypress", + "@nx/jest", + "typescript", + "react", + "webpack", + // require.resovle is used for these + "@babel/plugin-proposal-decorators", + "url-loader", + "@svgr/webpack" + ] + } + ] + } } ], "ignorePatterns": ["!**/*"] diff --git a/packages/next/package.json b/packages/next/package.json index d9a7fefffd736..bc04e10da1632 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -39,12 +39,11 @@ "chalk": "^4.1.0", "copy-webpack-plugin": "^10.2.4", "dotenv": "~10.0.0", - "express": "^4.18.1", "fs-extra": "^11.1.0", - "http-proxy-middleware": "^2.0.6", "ignore": "^5.0.4", "semver": "7.5.3", "url-loader": "^4.1.1", + "tslib": "^2.3.0", "webpack-merge": "^5.8.0", "@nx/devkit": "file:../devkit", "@nx/js": "file:../js", diff --git a/packages/next/src/executors/server/lib/default-server.ts b/packages/next/src/executors/server/lib/default-server.ts deleted file mode 100644 index 2002875a0cbb2..0000000000000 --- a/packages/next/src/executors/server/lib/default-server.ts +++ /dev/null @@ -1,34 +0,0 @@ -import * as express from 'express'; -import { NextServerOptions, ProxyConfig } from '../../../utils/types'; - -/** - * Adapted from https://github.com/zeit/next.js/blob/master/examples/with-custom-reverse-proxy/server.js - * @param settings - */ -export async function defaultServer( - settings: NextServerOptions, - proxyConfig?: ProxyConfig -): Promise { - const next = require('next'); - const app = next(settings); - const handle = app.getRequestHandler(); - - await app.prepare(); - - const server: express.Express = express(); - server.disable('x-powered-by'); - - // Set up the proxy. - if (proxyConfig) { - const proxyMiddleware = - require('http-proxy-middleware').createProxyMiddleware; - Object.keys(proxyConfig).forEach((context) => { - server.use(proxyMiddleware(context, proxyConfig[context])); - }); - } - - // Default catch-all handler to allow Next.js to handle all other routes - server.all('*', (req, res) => handle(req, res)); - - server.listen(settings.port, settings.hostname); -} diff --git a/packages/node/.eslintrc.json b/packages/node/.eslintrc.json index 0b6554fa779f3..721d2bf67965c 100644 --- a/packages/node/.eslintrc.json +++ b/packages/node/.eslintrc.json @@ -34,6 +34,19 @@ "rules": { "@nx/nx-plugin-checks": "error" } + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": ["nx", "typescript"] + } + ] + } } ] } diff --git a/packages/nx/.eslintrc.json b/packages/nx/.eslintrc.json index 18e95a5d0852e..9c43bd42c92ce 100644 --- a/packages/nx/.eslintrc.json +++ b/packages/nx/.eslintrc.json @@ -70,6 +70,36 @@ ], "no-restricted-imports": "off" } + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": [ + "typescript", + "@angular-devkit/build-angular", + "@angular-devkit/core", + "@angular-devkit/architect", + "@swc/core", //Optional, used in JS analysis if available + "@swc/node-register", //Optional, used in JS analysis if available + "rxjs", + "@angular-devkit/schematics", + "@pnpm/lockfile-types", + "@nestjs/cli", // nx init nest makes use of nestjs cli (which should be available in NestJS CLI app) to parse the nest-cli.json file + "ts-node", // We *may* fall back on ts-node, but we want to encourage the use of @swc-node instead so we don't explicitly list ts-node as an optional dep + "memfs", // used in mock for handling .node files in tests + "events", // This is coming from @storybook/builder-manager since it uses the browser polyfill + "process", // This is coming from @storybook/builder-manager since it uses the browser polyfill + "prettier", // This is coming from @storybook/builder-manager since it uses the browser polyfill + "util" // This is coming from @storybook/builder-manager since it uses the browser polyfill + ] + } + ] + } } ] } diff --git a/packages/playwright/.eslintrc.json b/packages/playwright/.eslintrc.json index d33dd4fda746e..8a408a6557eeb 100644 --- a/packages/playwright/.eslintrc.json +++ b/packages/playwright/.eslintrc.json @@ -20,6 +20,19 @@ "rules": { "@nx/nx-plugin-checks": "error" } + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": ["nx", "typescript", "@playwright/test"] + } + ] + } } ] } diff --git a/packages/playwright/package.json b/packages/playwright/package.json index f85b790be75b2..2d7b94ebb4dc8 100644 --- a/packages/playwright/package.json +++ b/packages/playwright/package.json @@ -29,7 +29,8 @@ "directory": "packages/playwright" }, "dependencies": { - "@nx/devkit": "file:../devkit" + "@nx/devkit": "file:../devkit", + "tslib": "^2.3.0" }, "peerDependencies": { "@playwright/test": "^1.36.0" diff --git a/packages/plugin/.eslintrc.json b/packages/plugin/.eslintrc.json index 463540ef46559..b832b47538c56 100644 --- a/packages/plugin/.eslintrc.json +++ b/packages/plugin/.eslintrc.json @@ -38,6 +38,19 @@ "rules": { "@nx/nx-plugin-checks": "error" } + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": ["nx", "typescript", "eslint"] + } + ] + } } ] } diff --git a/packages/react-native/.eslintrc.json b/packages/react-native/.eslintrc.json index 538ec128dd4f0..ace2a5e1787e8 100644 --- a/packages/react-native/.eslintrc.json +++ b/packages/react-native/.eslintrc.json @@ -14,6 +14,29 @@ "rules": { "@nx/nx-plugin-checks": "error" } + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": [ + "nx", + "eslint", + "prettier", + "typescript", + "react", + "react-native", + // These are in ensurePackage + "@nx/rollup", + "@nx/storybook" + ] + } + ] + } } ] } diff --git a/packages/react-native/package.json b/packages/react-native/package.json index 7aa7ef0cd198d..a50cab6ab76ab 100644 --- a/packages/react-native/package.json +++ b/packages/react-native/package.json @@ -35,6 +35,7 @@ "minimatch": "3.0.5", "node-fetch": "^2.6.7", "tsconfig-paths": "^4.1.2", + "tslib": "^2.3.0", "@nx/detox": "file:../detox", "@nx/devkit": "file:../devkit", "@nx/jest": "file:../jest", diff --git a/packages/react/.eslintrc.json b/packages/react/.eslintrc.json index 750eb252e37fe..03611d9778d6c 100644 --- a/packages/react/.eslintrc.json +++ b/packages/react/.eslintrc.json @@ -30,6 +30,61 @@ "rules": { "@nx/nx-plugin-checks": "error" } + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": [ + "nx", + "eslint", + "prettier", + "typescript", + "react", + // These are installed by ensurePackage so missing in package.json + "@nx/cypress", + "@nx/jest", + "@nx/rollup", + "@nx/storybook", + "@nx/vite", + "@nx/webpack", + // These are brought in by the webpack, rollup, or vite packages via init generators. + "@babel/preset-react", + "@module-federation/node", + "@phenomnomnominal/tsquery", + "@pmmmwh/react-refresh-webpack-plugin", + "@svgr/rollup", + "@rollup/plugin-url", + "@svgr/webpack", + "@swc/jest", + "babel-jest", + "babel-loader", + "babel-plugin-emotion", + "babel-plugin-styled-components", + "css-loader", + "file-loader", + "less-loader", + "react-refresh", + "rollup", + "sass", + "sass-loader", + "style-loader", + "stylus-loader", + "swc-loader", + "tsconfig-paths-webpack-plugin", + "url-loader", + "webpack", + "webpack-merge", + // used via the CT react plugin installed via vite plugin + "vite" + ] + } + ] + } } ], "ignorePatterns": ["!**/*"] diff --git a/packages/react/package.json b/packages/react/package.json index 8aaa696d78447..2bc7c4d2e9225 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -36,6 +36,7 @@ "chalk": "^4.1.0", "file-loader": "^6.2.0", "minimatch": "3.0.5", + "tslib": "^2.3.0", "@nx/devkit": "file:../devkit", "@nx/js": "file:../js", "@nx/linter": "file:../linter", diff --git a/packages/rollup/.eslintrc.json b/packages/rollup/.eslintrc.json index 4cf7f347f6a85..81ffc83539f54 100644 --- a/packages/rollup/.eslintrc.json +++ b/packages/rollup/.eslintrc.json @@ -20,6 +20,26 @@ "rules": { "@nx/nx-plugin-checks": "error" } + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": [ + "nx", + "typescript", + "@swc/core", // Installed to workspace and only used in swc() plugin + // Used in require.resolve calls + "babel-plugin-transform-async-to-promises", + "postcss" + ] + } + ] + } } ] } diff --git a/packages/storybook/.eslintrc.json b/packages/storybook/.eslintrc.json index c7b0b5b64150a..173eb4ad9766d 100644 --- a/packages/storybook/.eslintrc.json +++ b/packages/storybook/.eslintrc.json @@ -30,6 +30,25 @@ "rules": { "@nx/nx-plugin-checks": "error" } + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": [ + "nx", + "typescript", + "@nx/web", // Just types used + "@storybook/core-server", + "@storybook/types" + ] + } + ] + } } ], "ignorePatterns": ["!**/*"] diff --git a/packages/storybook/package.json b/packages/storybook/package.json index 79b92cb2df16e..28e3959469e89 100644 --- a/packages/storybook/package.json +++ b/packages/storybook/package.json @@ -33,6 +33,7 @@ "dotenv": "~10.0.0", "@phenomnomnominal/tsquery": "~5.0.1", "semver": "7.5.3", + "tslib": "^2.3.0", "@nx/cypress": "file:../cypress", "@nx/devkit": "file:../devkit", "@nx/js": "file:../js", diff --git a/packages/tao/.eslintrc.json b/packages/tao/.eslintrc.json index a40930e8b428f..77160b79a3b04 100644 --- a/packages/tao/.eslintrc.json +++ b/packages/tao/.eslintrc.json @@ -22,6 +22,19 @@ { "files": ["*.js", "*.jsx"], "rules": {} + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": ["nx", "typescript"] + } + ] + } } ] } diff --git a/packages/tao/package.json b/packages/tao/package.json index d3e64b5a9d021..4880deafb1466 100644 --- a/packages/tao/package.json +++ b/packages/tao/package.json @@ -31,7 +31,8 @@ }, "homepage": "https://nx.dev", "dependencies": { - "nx": "file:../nx" + "nx": "file:../nx", + "tslib": "^2.3.0" }, "publishConfig": { "access": "public" diff --git a/packages/vite/.eslintrc.json b/packages/vite/.eslintrc.json index 4cf7f347f6a85..4a5d6fc8e2304 100644 --- a/packages/vite/.eslintrc.json +++ b/packages/vite/.eslintrc.json @@ -20,6 +20,19 @@ "rules": { "@nx/nx-plugin-checks": "error" } + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": ["nx", "typescript", "vite"] + } + ] + } } ] } diff --git a/packages/web/.eslintrc.json b/packages/web/.eslintrc.json index 750eb252e37fe..fb5a5b04e2c21 100644 --- a/packages/web/.eslintrc.json +++ b/packages/web/.eslintrc.json @@ -30,6 +30,30 @@ "rules": { "@nx/nx-plugin-checks": "error" } + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": [ + "nx", + "typescript", + "eslint", + "http-server", // Used by readModulePackageJson + // Installed by ensurePackage + "@nx/linter", + "@nx/cypress", + "@nx/vite", + "@nx/webpack", + "@nx/jest" + ] + } + ] + } } ], "ignorePatterns": ["!**/*"] diff --git a/packages/webpack/.eslintrc.json b/packages/webpack/.eslintrc.json index 4cf7f347f6a85..4e0f42431e3be 100644 --- a/packages/webpack/.eslintrc.json +++ b/packages/webpack/.eslintrc.json @@ -20,6 +20,35 @@ "rules": { "@nx/nx-plugin-checks": "error" } + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": [ + "nx", + "typescript", + "eslint", + // Used in require.resolve calls + "@babel/core", + "css-loader", + "less", + "less-loader", + "postcss-loader", + "sass-loader", + "style-loader", + "stylus", + "stylus-loader", + "source-map-loader", + "ts-loader" + ] + } + ] + } } ] } diff --git a/packages/workspace/.eslintrc.json b/packages/workspace/.eslintrc.json index 0c0c781a7ea77..15f6d6e7312c1 100644 --- a/packages/workspace/.eslintrc.json +++ b/packages/workspace/.eslintrc.json @@ -35,6 +35,26 @@ } ] } + }, + { + "files": ["./package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": [ + "error", + { + "buildTargets": ["build-base"], + "ignoredDependencies": [ + "nx", + "prettier", + "typescript", + "@angular-devkit/schematics", + "@angular-devkit/core", + "@angular-devkit/architect" + ] + } + ] + } } ], "ignorePatterns": ["!**/*"] diff --git a/packages/workspace/package.json b/packages/workspace/package.json index 4a2c9f84c466d..2b9d6a43ad2b4 100644 --- a/packages/workspace/package.json +++ b/packages/workspace/package.json @@ -61,22 +61,10 @@ } }, "dependencies": { - "@parcel/watcher": "2.0.4", "chalk": "^4.1.0", - "chokidar": "^3.5.1", - "cli-cursor": "3.1.0", - "cli-spinners": "2.6.1", - "dotenv": "~10.0.0", - "figures": "3.2.0", - "flat": "^5.0.2", "ignore": "^5.0.4", - "minimatch": "3.0.5", - "npm-run-path": "^4.0.1", - "open": "^8.4.0", "rxjs": "^7.8.0", - "tmp": "~0.2.1", "tslib": "^2.3.0", - "yargs": "^17.6.2", "yargs-parser": "21.1.1", "@nx/devkit": "file:../devkit" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5cbc8b5cb6c34..f317e3f36744d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -528,9 +528,6 @@ devDependencies: czg: specifier: ^1.4.0 version: 1.4.0 - depcheck: - specifier: ^1.3.1 - version: 1.4.3 detect-port: specifier: ^1.5.1 version: 1.5.1 @@ -2206,14 +2203,6 @@ packages: chalk: 2.4.2 js-tokens: 4.0.0 - /@babel/parser@7.16.4: - resolution: {integrity: sha512-6V0qdPUaiVHH3RtZeLIsc+6pDhbYzHR8ogA8w+f+Wc77DuXto19g2QUwveINoS34Uw+W8/hQDGJCx+i4n7xcng==} - engines: {node: '>=6.0.0'} - hasBin: true - dependencies: - '@babel/types': 7.22.5 - dev: true - /@babel/parser@7.21.4: resolution: {integrity: sha512-alVJj7k7zIxqBZ7BTRhz0IqJFxW1VJbm6N8JbcYhQ186df9ZBPbZBmWSqAMXwHGsCJdYks7z/voa3ibiS5bCIw==} engines: {node: '>=6.0.0'} @@ -11136,15 +11125,6 @@ packages: pretty-format: 27.5.1 dev: false - /@vue/compiler-core@3.2.41: - resolution: {integrity: sha512-oA4mH6SA78DT+96/nsi4p9DX97PHcNROxs51lYk7gb9Z4BPKQ3Mh+BLn6CQZBw857Iuhu28BfMSRHAlPvD4vlw==} - dependencies: - '@babel/parser': 7.22.5 - '@vue/shared': 3.2.41 - estree-walker: 2.0.2 - source-map: 0.6.1 - dev: true - /@vue/compiler-core@3.3.4: resolution: {integrity: sha512-cquyDNvZ6jTbf/+x+AgM2Arrp6G4Dzbb0R64jiG804HRMfRiFXWI6kqUVqZ6ZR0bQhIoQjB4+2bhNtVwndW15g==} dependencies: @@ -11154,13 +11134,6 @@ packages: source-map-js: 1.0.2 dev: true - /@vue/compiler-dom@3.2.41: - resolution: {integrity: sha512-xe5TbbIsonjENxJsYRbDJvthzqxLNk+tb3d/c47zgREDa/PCp6/Y4gC/skM4H6PIuX5DAxm7fFJdbjjUH2QTMw==} - dependencies: - '@vue/compiler-core': 3.2.41 - '@vue/shared': 3.2.41 - dev: true - /@vue/compiler-dom@3.3.4: resolution: {integrity: sha512-wyM+OjOVpuUukIq6p5+nwHYtj9cFroz9cwkfmP9O1nzH68BenTTv0u7/ndggT8cIQlnBeOo6sUT/gvHcIkLA5w==} dependencies: @@ -11168,21 +11141,6 @@ packages: '@vue/shared': 3.3.4 dev: true - /@vue/compiler-sfc@3.2.41: - resolution: {integrity: sha512-+1P2m5kxOeaxVmJNXnBskAn3BenbTmbxBxWOtBq3mQTCokIreuMULFantBUclP0+KnzNCMOvcnKinqQZmiOF8w==} - dependencies: - '@babel/parser': 7.22.5 - '@vue/compiler-core': 3.2.41 - '@vue/compiler-dom': 3.2.41 - '@vue/compiler-ssr': 3.2.41 - '@vue/reactivity-transform': 3.2.41 - '@vue/shared': 3.2.41 - estree-walker: 2.0.2 - magic-string: 0.25.9 - postcss: 8.4.19 - source-map: 0.6.1 - dev: true - /@vue/compiler-sfc@3.3.4: resolution: {integrity: sha512-6y/d8uw+5TkCuzBkgLS0v3lSM3hJDntFEiUORM11pQ/hKvkhSKZrXW6i69UyXlJQisJxuUEJKAWEqWbWsLeNKQ==} dependencies: @@ -11198,13 +11156,6 @@ packages: source-map-js: 1.0.2 dev: true - /@vue/compiler-ssr@3.2.41: - resolution: {integrity: sha512-Y5wPiNIiaMz/sps8+DmhaKfDm1xgj6GrH99z4gq2LQenfVQcYXmHIOBcs5qPwl7jaW3SUQWjkAPKMfQemEQZwQ==} - dependencies: - '@vue/compiler-dom': 3.2.41 - '@vue/shared': 3.2.41 - dev: true - /@vue/compiler-ssr@3.3.4: resolution: {integrity: sha512-m0v6oKpup2nMSehwA6Uuu+j+wEwcy7QmwMkVNVfrV9P2qE5KshC6RwOCq8fjGS/Eak/uNb8AaWekfiXxbBB6gQ==} dependencies: @@ -11212,16 +11163,6 @@ packages: '@vue/shared': 3.3.4 dev: true - /@vue/reactivity-transform@3.2.41: - resolution: {integrity: sha512-mK5+BNMsL4hHi+IR3Ft/ho6Za+L3FA5j8WvreJ7XzHrqkPq8jtF/SMo7tuc9gHjLDwKZX1nP1JQOKo9IEAn54A==} - dependencies: - '@babel/parser': 7.22.5 - '@vue/compiler-core': 3.2.41 - '@vue/shared': 3.2.41 - estree-walker: 2.0.2 - magic-string: 0.25.9 - dev: true - /@vue/reactivity-transform@3.3.4: resolution: {integrity: sha512-MXgwjako4nu5WFLAjpBnCj/ieqcjE2aJBINUNQzkZQfzIZA4xn+0fV1tIYBJvvva3N3OvKGofRLvQIwEQPpaXw==} dependencies: @@ -11263,10 +11204,6 @@ packages: vue: 3.3.4 dev: true - /@vue/shared@3.2.41: - resolution: {integrity: sha512-W9mfWLHmJhkfAmV+7gDjcHeAWALQtgGT3JErxULl0oz6R6+3ug91I7IErs93eCFhPCZPHBs4QJS7YWEV7A3sxw==} - dev: true - /@vue/shared@3.3.4: resolution: {integrity: sha512-7OjdcV8vQ74eiz1TZLzZP4JwqM5fA94K6yntPS5Z25r9HDuGNzaGdgvwKYq6S+MxwF0TFRwe50fIR/MYnakdkQ==} dev: true @@ -14923,38 +14860,6 @@ packages: resolution: {integrity: sha512-KNTihKNmQENUZeKu5fzfpzRqR5S2VMp4gl9RFHiWzj9DfvYQPMJ6XHKNaQxaGCXwPk6y9yme3aUoaiAe+KX+vg==} dev: true - /depcheck@1.4.3: - resolution: {integrity: sha512-vy8xe1tlLFu7t4jFyoirMmOR7x7N601ubU9Gkifyr9z8rjBFtEdWHDBMqXyk6OkK+94NXutzddVXJuo0JlUQKQ==} - engines: {node: '>=10'} - hasBin: true - dependencies: - '@babel/parser': 7.16.4 - '@babel/traverse': 7.21.4(supports-color@5.5.0) - '@vue/compiler-sfc': 3.2.41 - camelcase: 6.3.0 - cosmiconfig: 7.0.1 - debug: 4.3.4(supports-color@5.5.0) - deps-regex: 0.1.4 - ignore: 5.2.0 - is-core-module: 2.11.0 - js-yaml: 3.14.1 - json5: 2.2.3 - lodash: 4.17.21 - minimatch: 3.1.2 - multimatch: 5.0.0 - please-upgrade-node: 3.2.0 - query-ast: 1.0.4 - readdirp: 3.6.0 - require-package-name: 2.0.1 - resolve: 1.22.1 - sass: 1.58.1 - scss-parser: 1.0.5 - semver: 7.5.3 - yargs: 16.2.0 - transitivePeerDependencies: - - supports-color - dev: true - /depd@1.1.2: resolution: {integrity: sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==} engines: {node: '>= 0.6'} @@ -14973,10 +14878,6 @@ packages: resolution: {integrity: sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==} dev: true - /deps-regex@0.1.4: - resolution: {integrity: sha512-3tzwGYogSJi8HoG93R5x9NrdefZQOXgHgGih/7eivloOq6yC6O+yoFxZnkgP661twvfILONfoKRdF9GQOGx2RA==} - dev: true - /dequal@2.0.3: resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} engines: {node: '>=6'} @@ -22386,12 +22287,6 @@ packages: hasBin: true dev: true - /please-upgrade-node@3.2.0: - resolution: {integrity: sha512-gQR3WpIgNIKwBMVLkpMUeR3e1/E1y42bqDQZfql+kDeXd8COYfM8PQA4X6y7a8u9Ua9FHmsrrmirW2vHs45hWg==} - dependencies: - semver-compare: 1.0.0 - dev: true - /pluralize@8.0.0: resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==} engines: {node: '>=4'} @@ -23819,13 +23714,6 @@ packages: engines: {node: '>=0.6'} dev: true - /query-ast@1.0.4: - resolution: {integrity: sha512-KFJFSvODCBjIH5HbHvITj9EEZKYUU6VX0T5CuB1ayvjUoUaZkKMi6eeby5Tf8DMukyZHlJQOE1+f3vevKUe6eg==} - dependencies: - invariant: 2.2.4 - lodash: 4.17.21 - dev: true - /querystringify@2.2.0: resolution: {integrity: sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==} dev: true @@ -24455,10 +24343,6 @@ packages: engines: {node: '>=0.10.0'} dev: true - /require-package-name@2.0.1: - resolution: {integrity: sha512-uuoJ1hU/k6M0779t3VMVIYpb2VMJk05cehCaABFhXaibcbvfgR8wKiozLjVFSzJPmQMRqIcO0HMyTFqfV09V6Q==} - dev: true - /requireindex@1.2.0: resolution: {integrity: sha512-L9jEkOi3ASd9PYit2cwRfyppc9NoABujTP8/5gFcbERmo5jUoAKovIC3fsF17pkTnGsrByysqX+Kxd2OTNI1ww==} engines: {node: '>=0.10.5'} @@ -24818,16 +24702,6 @@ packages: immutable: 4.1.0 source-map-js: 1.0.2 - /sass@1.58.1: - resolution: {integrity: sha512-bnINi6nPXbP1XNRaranMFEBZWUfdW/AF16Ql5+ypRxfTvCRTTKrLsMIakyDcayUt2t/RZotmL4kgJwNH5xO+bg==} - engines: {node: '>=12.0.0'} - hasBin: true - dependencies: - chokidar: 3.5.3 - immutable: 4.1.0 - source-map-js: 1.0.2 - dev: true - /sass@1.63.2: resolution: {integrity: sha512-u56TU0AIFqMtauKl/OJ1AeFsXqRHkgO7nCWmHaDwfxDo9GUMSqBA4NEh6GMuh1CYVM7zuROYtZrHzPc2ixK+ww==} engines: {node: '>=14.0.0'} @@ -24907,14 +24781,6 @@ packages: ajv-keywords: 5.1.0(ajv@8.12.0) dev: true - /scss-parser@1.0.5: - resolution: {integrity: sha512-RZOtvCmCnwkDo7kdcYBi807Y5EoTIxJ34AgEgJNDmOH1jl0/xG0FyYZFbH6Ga3Iwu7q8LSdxJ4C5UkzNXjQxKQ==} - engines: {node: '>=6.0.0'} - dependencies: - invariant: 2.2.4 - lodash: 4.17.21 - dev: true - /secure-compare@3.0.1: resolution: {integrity: sha512-AckIIV90rPDcBcglUwXPF3kg0P0qmPsPXAj6BBEENQE1p5yA1xfmDJzfi1Tappj37Pv2mVbKpL3Z1T+Nn7k1Qw==} dev: true @@ -24930,10 +24796,6 @@ packages: node-forge: 1.3.1 dev: true - /semver-compare@1.0.0: - resolution: {integrity: sha512-YM3/ITh2MJ5MtzaM429anh+x2jiLVjqILF4m4oyQB18W7Ggea7BfqdH/wGMK7dDiMghv/6WG7znWMwUDzJiXow==} - dev: true - /semver-regex@4.0.5: resolution: {integrity: sha512-hunMQrEy1T6Jr2uEVjrAIqjwWcQTgOAcIM52C8MY1EZSD3DDNft04XzvYKPqjED65bNVVko0YI38nYeEHCX3yw==} engines: {node: '>=12'} diff --git a/scripts/depcheck/discrepancies.ts b/scripts/depcheck/discrepancies.ts deleted file mode 100644 index 2e36816aba17b..0000000000000 --- a/scripts/depcheck/discrepancies.ts +++ /dev/null @@ -1,32 +0,0 @@ -import * as chalk from 'chalk'; -import { satisfies } from 'semver'; - -// Ignore packages that are defined here per package -const IGNORE_MATCHES = { - '*': [] as string[], - angular: ['webpack-merge', '@phenomnomnominal/tsquery'], - cypress: ['webpack', '@babel/core', 'babel-loader'], -}; - -export default function getDiscrepancies( - name: string, - projectDependencies: JSON, - devDependencies: JSON -) { - return Object.keys(projectDependencies ?? ({} as Record)) - .filter((p) => !p.startsWith('@nx/') && p !== 'nx') - .filter((p) => - !IGNORE_MATCHES['*'].includes(p) && IGNORE_MATCHES[name] - ? !IGNORE_MATCHES[name].includes(p) - : true - ) - .filter( - (p) => - devDependencies[p] && - projectDependencies[p] !== devDependencies[p] && - !satisfies(devDependencies[p], projectDependencies[p]) - ) - .map( - (p) => `${p}@${devDependencies[p]} ${chalk.dim(projectDependencies[p])}` - ); -} diff --git a/scripts/depcheck/index.ts b/scripts/depcheck/index.ts deleted file mode 100644 index cecfdc24d8bdd..0000000000000 --- a/scripts/depcheck/index.ts +++ /dev/null @@ -1,132 +0,0 @@ -import { readFileSync, readdirSync } from 'fs'; -import { join } from 'path'; -import * as chalk from 'chalk'; -import getDiscrepancies from './discrepancies'; -import getMissingDependencies from './missing'; -import getUnusedDependencies from './unused'; - -const argv = require('yargs') - .usage('Check projects for dependency discrepancies.') - .option('projects', { - alias: 'p', - type: 'array', - description: 'Projects to check', - }) - .option('unused', { - alias: 'm', - type: 'boolean', - default: true, - description: 'Check for unused dependencies', - }) - .option('missing', { - alias: 'm', - type: 'boolean', - default: true, - description: 'Check for missing dependencies', - }) - .option('discrepancies', { - alias: 'd', - type: 'boolean', - default: true, - description: 'Check for discrepancies between package and dev dependencies', - }) - .option('verbose', { - alias: 'v', - type: 'boolean', - description: 'Run with verbose logging', - }).argv; - -(async () => { - const { devDependencies } = JSON.parse( - readFileSync(`./package.json`).toString() - ); - - const packagesDirectory = join(__dirname, '../..', 'packages'); - - const projects = - argv.projects || - readdirSync(packagesDirectory, { withFileTypes: true }) - .filter((dirent) => dirent.isDirectory()) - .map((dirent) => dirent.name); - - const results = await Promise.all( - projects - .sort() - .map((name) => ({ name })) - .map(async (project) => { - const projectPath = join(packagesDirectory, project.name); - const { dependencies, peerDependencies } = JSON.parse( - readFileSync(`${projectPath}/package.json`).toString() - ); - - const missing = argv.missing - ? await getMissingDependencies( - project.name, - projectPath, - { ...dependencies, ...(peerDependencies || {}) }, - argv.verbose - ) - : []; - - const unused = argv.unused - ? await getUnusedDependencies( - project.name, - projectPath, - - { ...dependencies, ...(peerDependencies || {}) }, - argv.verbose - ) - : []; - - const discrepancies = argv.discrepancies - ? getDiscrepancies(project.name, dependencies, devDependencies) - : []; - - return { ...project, missing, discrepancies, unused }; - }) - ); - - const total = { missing: 0, discrepancies: 0, unused: 0 }; - - results.forEach(({ name, missing, discrepancies, unused }) => { - if (!missing.length && !discrepancies.length && !unused.length) { - return; - } - - console.log(`${chalk.inverse.bold.cyan(` ${name.toUpperCase()} `)}`); - - if (missing.length > 0) { - total.missing += missing.length; - console.log( - `⚠️ ${chalk.bold.inverse(` Missing `)}\n${missing - .sort() - .map( - (p) => ` ${devDependencies[p] ? `${p}@${devDependencies[p]}` : p}` - ) - .join(`\n`)}\n` - ); - } - - if (unused.length > 0) { - total.unused += unused.length; - console.log( - `⚠️ ${chalk.bold.inverse(` Unused`)}\n ${unused.join('\n ')}\n` - ); - } - - if (discrepancies.length > 0) { - total.discrepancies += discrepancies.length; - console.log( - `⛔ ${chalk.bold.inverse(` Discrepancies `)}\n${discrepancies - .map((d) => ` ${d}`) - .join(`\n`)}\n` - ); - } - }); - - if (total.discrepancies > 0 || total.missing > 0 || total.unused > 0) { - process.exit(1); - } - - process.exit(0); -})().catch((err) => console.log(err)); diff --git a/scripts/depcheck/missing.ts b/scripts/depcheck/missing.ts deleted file mode 100644 index 345ee33ec9b4b..0000000000000 --- a/scripts/depcheck/missing.ts +++ /dev/null @@ -1,271 +0,0 @@ -import * as depcheck from 'depcheck'; -import { join } from 'path'; - -// Ignore packages that are defined here per package -const IGNORE_MATCHES_IN_PACKAGE = { - '*': [ - 'nx', - 'prettier', - 'typescript', - // These are installed as needed and should not be added to package.json - '@nx/cypress', - '@nx/jest', - '@nx/rollup', - '@nx/storybook', - '@nx/vite', - '@nx/webpack', - ], - angular: [ - '@angular-devkit/architect', - '@angular-devkit/build-angular', - '@angular-devkit/core', - '@angular/compiler', - '@angular/compiler-cli', - '@angular/core', - '@angular/router', - '@ngrx/effects', - '@ngrx/router-store', - '@ngrx/store', - '@storybook/angular', - '@module-federation/node', - 'rxjs', - 'semver', - // installed dynamically by the library generator - 'ng-packagr', - // ng-packagr deps, some are handled if not installed - 'injection-js', - 'browserslist', - 'cacache', - 'less', - 'node-sass', - 'node-sass-tilde-importer', - 'ora', - 'convert-source-map', - 'postcss', - 'postcss-import', - 'postcss-preset-env', - 'postcss-url', - 'sass', - 'stylus', - 'tailwindcss', - // used in the CT angular plugin where Cy is already installed to use it. - 'cypress', - ], - cli: ['nx'], - cypress: ['cypress', '@angular-devkit/schematics', 'vite'], - devkit: [ - '@angular-devkit/architect', - '@angular-devkit/schematics', - 'rxjs', - 'webpack', - ], - 'eslint-plugin': ['@angular-eslint/eslint-plugin'], - jest: [ - 'jest', - '@jest/types', - 'identity-obj-proxy', - '@angular-devkit/schematics', - ], - js: [], - linter: [ - 'eslint', - '@angular-devkit/schematics', - '@angular-devkit/architect', - // Installed and uninstalled dynamically when the conversion generator runs - 'tslint-to-eslint-config', - // Resolved from the end user's own workspace installation dynamically - '@typescript-eslint/eslint-plugin', - ], - next: [ - '@angular-devkit/architect', - 'express', - 'http-proxy-middleware', - 'next', - 'rxjs', - 'tsconfig-paths-webpack-plugin', - 'webpack', - ], - react: [ - // These are brought in by the webpack, rollup, or vite packages via init generators. - '@babel/preset-react', - '@module-federation/node', - '@phenomnomnominal/tsquery', - '@pmmmwh/react-refresh-webpack-plugin', - '@svgr/rollup', - '@rollup/plugin-url', - '@svgr/webpack', - '@swc/jest', - 'babel-jest', - 'babel-loader', - 'babel-plugin-emotion', - 'babel-plugin-styled-components', - 'css-loader', - 'file-loader', - 'less-loader', - 'react-refresh', - 'rollup', - 'sass', - 'sass-loader', - 'style-loader', - 'stylus-loader', - 'swc-loader', - 'tsconfig-paths-webpack-plugin', - 'url-loader', - 'webpack', - 'webpack-merge', - // used via the CT react plugin installed via vite plugin - 'vite', - ], - 'react-native': ['@nx/storybook'], - rollup: ['@swc/core'], - storybook: [ - '@angular-devkit/architect', - '@angular-devkit/core', - '@angular-devkit/schematics', - '@storybook/addon-knobs', - '@storybook/addon-essentials', - '@storybook/core', - '@storybook/core-server', - '@storybook/types', - // lazy installed with ensurePackage - '@nx/web', - '@nx/jest', - '@nx/rollup', - '@nx/vite', - '@nx/webpack', - 'rxjs', - ], - nx: [ - '@angular-devkit/build-angular', - '@angular-devkit/schematics', - '@angular-devkit/core', - '@angular-devkit/architect', - '@angular/cli', - '@nrwl/angular', - '@nx/angular', - '@nrwl/cli', - 'rxjs', - '@nestjs/cli', // nx init nest makes use of nestjs cli (which should be available in NestJS CLI app) to parse the nest-cli.json file - 'ts-node', // We *may* fall back on ts-node, but we want to encourage the use of @swc-node instead so we don't explicitly list ts-node as an optional dep - '@nx/nx-android-arm-eabi', // native optional deps - '@nx/nx-android-arm64', // native optional deps - '@nx/nx-darwin-arm64', // native optional deps - '@nx/nx-darwin-universal', // native optional deps - '@nx/nx-darwin-x64', // native optional deps - '@nx/nx-freebsd-x64', // native optional deps - '@nx/nx-linux-arm-gnueabihf', // native optional deps - '@nx/nx-linux-arm64-gnu', // native optional deps - '@nx/nx-linux-arm64-musl', // native optional deps - '@nx/nx-linux-x64-gnu', // native optional deps - '@nx/nx-linux-x64-musl', // native optional deps - '@nx/nx-win32-arm64-msvc', // native optional deps - '@nx/nx-win32-ia32-msvc', // native optional deps - '@nx/nx-win32-x64-msvc', // native optional deps - 'memfs', // used in mock for handling .node files in tests - ], - web: [ - // we don't want to bloat the install of @nx/web by including @swc/core and swc-loader as a dependency. - '@swc/core', - 'swc-loader', - - '@nx/cypress', - '@nx/jest', - '@nx/rollup', - '@nx/vite', - '@nx/webpack', - 'fibers', - 'node-sass', - ], - webpack: ['@swc/core', 'style-loader', 'swc-loader'], - workspace: [ - '@angular-devkit/architect', - '@angular-devkit/core', - '@angular-devkit/schematics', - '@phenomnomnominal/tsquery', - ], - nest: ['semver'], -}; - -const IGNORE_MATCHES_BY_FILE: Record = { - '@storybook/core': [ - join( - __dirname, - '../../packages/angular/src/migrations/update-12-3-0/update-storybook.ts' - ), - ], - '@nx/plugin': [ - join( - __dirname, - '../../packages/workspace/src/migrations/update-16-0-0/move-workspace-generators-to-local-plugin.spec.ts' - ), - join( - __dirname, - '../../packages/workspace/src/migrations/update-16-0-0/move-workspace-generators-to-local-plugin.ts' - ), - ], -}; - -export default async function getMissingDependencies( - name: string, - path: string, - dependencies: JSON, - verbose: boolean -) { - const options: any = { - /** - * If a dependency is exclusively used via a TypeScript type import - * e.g. `import type { Foo } from 'bar';` - * ...then we do not want it to trigger a missing dependency warning - * because it is not required at runtime. - * - * We can achieve this by overriding the default detector for - * ImportDeclaration nodes to check the `importKind` value. - */ - detectors: [ - ...Object.entries(depcheck.detector).map(([detectorName, detectorFn]) => { - // Use all the default detectors, apart from 'importDeclaration' - if (detectorName !== 'importDeclaration') { - return detectorFn; - } - const customImportDeclarationDetector: depcheck.Detector = (node) => { - return node.type === 'ImportDeclaration' && - node.source && - node.source.value && - node.importKind !== 'type' - ? [node.source.value] - : []; - }; - return customImportDeclarationDetector; - }), - ], - skipMissing: false, // skip calculation of missing dependencies - ignorePatterns: [ - '*.d.ts', - '.eslintrc.json', - '*.spec*', - 'src/schematics/**/files/**', - ], - }; - let { missing } = await depcheck(path, { - ...options, - package: { dependencies }, - }); - - const packagesMissing = Object.keys(missing).filter( - (m) => - !IGNORE_MATCHES_IN_PACKAGE['*'].includes(m) && - !(IGNORE_MATCHES_IN_PACKAGE[name] || []).includes(m) && - missing[m].filter( - (occurence) => !IGNORE_MATCHES_BY_FILE[m]?.includes(occurence) - ).length - ); - - if (verbose) { - console.log(`> ${name}`); - packagesMissing.map((p) => { - console.log(p, missing[p]); - }); - } - - return packagesMissing; -} diff --git a/scripts/depcheck/unused.ts b/scripts/depcheck/unused.ts deleted file mode 100644 index 2aed3732d6862..0000000000000 --- a/scripts/depcheck/unused.ts +++ /dev/null @@ -1,104 +0,0 @@ -import * as depcheck from 'depcheck'; - -// Ignore packages that are defined here per package. -// Note: If @babel/parser fails to parse a file, then its imports will not be detected. -const IGNORE_MATCHES = { - '*': ['@nx/devkit', '@nx/workspace', 'chalk', 'tslib', '@swc/helpers'], - angular: ['@angular-devkit/schematics', '@schematics/angular', 'http-server'], - cli: [], - cypress: [], - devkit: [], - 'eslint-plugin': [], - jest: [ - // This is used for the type import only, we should remove it. - 'jest-resolve', - ], - linter: [], - nest: ['@nestjs/schematics'], - next: [], - node: [], - 'nx-plugin': [], - react: [], - rollup: [], - storybook: [], - nx: ['glob'], - vite: [], - web: ['http-server'], - webpack: [ - // These are not being picked up because @babel/parser is failing on the files that import them. - 'css-loader', - 'style-loader', - 'ts-loader', - 'webpack-merge', - ], - workspace: [ - '@parcel/watcher', - 'cli-cursor', - 'cli-spinners', - 'dotenv', - 'figures', - 'flat', - 'minimatch', - 'npm-run-path', - 'open', - 'tmp', - 'yargs', - ], -}; - -export default async function getUnusedDependencies( - name: string, - path: string, - dependencies: JSON, - verbose: boolean -) { - const options: any = { - detectors: [ - ...Object.entries(depcheck.detector).map(([detectorName, detectorFn]) => { - // Use all the default detectors, apart from 'importDeclaration' - if (detectorName !== 'importDeclaration') { - return detectorFn; - } - const customImportDeclarationDetector: depcheck.Detector = (node) => { - switch (node.type) { - case 'ImportDeclaration': - return node.source && - node.source.value && - node.importKind !== 'type' - ? [node.source.value] - : []; - case 'CallExpression': - return (node.callee?.name === 'require' || - (node.callee?.object?.name === 'require' && - node.callee?.property?.name === 'resolve')) && - node.arguments[0]?.value - ? [node.arguments[0].value] - : []; - default: - return []; - } - }; - return customImportDeclarationDetector; - }), - ], - skipMissing: false, // skip calculation of missing dependencies - ignorePatterns: [ - '*.d.ts', - '.eslintrc.json', - '*.spec*', - 'src/schematics/**/files/**', - ], - }; - let { dependencies: unused } = await depcheck(path, { - ...options, - package: { dependencies }, - }); - - const unusedPackages = unused.filter( - (m) => - !IGNORE_MATCHES['*'].includes(m) && - !(IGNORE_MATCHES[name] || []).includes(m) - ); - - return unusedPackages; -}