-
Notifications
You must be signed in to change notification settings - Fork 16
Code PushUp integration guide for Nx monorepos
Matěj Chalk edited this page Dec 5, 2023
·
26 revisions
This is a guide for how to integrate Code PushUp CLI and ESLint plugin in an Nx monorepo, and how to automatically upload reports to portal's staging environment.
Warning
Only Nx 17 is supported. If your repo uses an older version, you'll need to update first - run npx nx migrate latest --interactive (confirm latest versions of TypeScript and Angular), followed by npx nx migrate --run-migrations (more info in Nx docs).
Example for Nx monorepo using Angular, Jest and Cypress:
-
Install peer dependencies as required (for more info, see setup docs):
npm i -D eslint-plugin-{deprecation,functional@latest,import,no-secrets,promise,rxjs,sonarjs,unicorn@48} -
Install Code PushUp's ESLint config package:
npm i -D @code-pushup/eslint-config
-
In
.eslintrc.json, extend configs:
{ "root": true, "ignorePatterns": ["**/*"], "plugins": ["@nx"], "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], "rules": { "@nx/enforce-module-boundaries": [ "error", { "enforceBuildableLibDependency": true, "allow": [], "depConstraints": [ { "sourceTag": "*", "onlyDependOnLibsWithTags": ["*"] } ] } ] } }, { "files": ["*.ts", "*.tsx"], "extends": [ "plugin:@nx/typescript", // extend configs for TS files "@code-pushup/eslint-config/angular", "@code-pushup/eslint-config/jest", "@code-pushup/eslint-config/cypress" ], "settings": { // configure TS path aliases "import/resolver": { "typescript": { "project": "tsconfig.base.json" } } }, "rules": { // ... customize as needed ... "@angular-eslint/component-selector": [ "warn", { "type": "element", "style": "kebab-case", "prefix": ["cp"] // <-- replace with your own prefix } ], "@angular-eslint/directive-selector": [ "warn", { "type": "attribute", "style": "camelCase", "prefix": "cp" // <-- replace with your own prefix } ], "@angular-eslint/pipe-prefix": [ "warn", { "prefixes": ["cp"] // <-- replace with your own prefix } ] } }, { "files": ["*.js", "*.jsx"], "extends": ["plugin:@nx/javascript", "@code-pushup"], // add default config for JS files "rules": {} } ] }