Skip to content

Conversation

@BioPhoton
Copy link
Collaborator

@BioPhoton BioPhoton commented Dec 2, 2025

Followup of #1163

This PR includes:

  • create nx plugin under zod2md-jsdocs
  • logic to add target config if file matches zod2md.config.ts
  • plugin docs
  • remove old config
  • remove file reference from production inputs as changes in the config may impact build output

A potential followup PR could implement a nx plugin for our build target and add dependsOn settings automatically. This is also noted in a clean up issue.

Note

This is tooling code and it is not planned to get released

Related:
#1168

@github-actions github-actions bot added 📖 Project documentation improvements or additions to the project documentation 🛠️ tooling labels Dec 2, 2025
@nx-cloud
Copy link

nx-cloud bot commented Dec 2, 2025

View your CI Pipeline Execution ↗ for commit 8db0605

Command Status Duration Result
nx run-many --targets=code-pushup --parallel=fa... ❌ Failed 7m 7s View ↗
nx run-many -t unit-test,int-test ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2025-12-11 17:53:07 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 2, 2025

Open in StackBlitz

@code-pushup/ci

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/ci@1162

@code-pushup/cli

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/cli@1162

@code-pushup/core

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/core@1162

@code-pushup/create-cli

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/create-cli@1162

@code-pushup/models

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/models@1162

@code-pushup/nx-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/nx-plugin@1162

@code-pushup/axe-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/axe-plugin@1162

@code-pushup/coverage-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/coverage-plugin@1162

@code-pushup/eslint-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/eslint-plugin@1162

@code-pushup/js-packages-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/js-packages-plugin@1162

@code-pushup/jsdocs-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/jsdocs-plugin@1162

@code-pushup/lighthouse-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/lighthouse-plugin@1162

@code-pushup/typescript-plugin

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/typescript-plugin@1162

@code-pushup/utils

npm i https://pkg.pr.new/code-pushup/cli/@code-pushup/utils@1162

commit: e4a4864

@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2025

Code PushUp

🤨 Code PushUp report has both improvements and regressions – compared current commit b2e8c67 with previous commit f74d2dd.

🕵️ See full comparison in Code PushUp portal 🔍

🏷️ Categories

🏷️ Category ⭐ Previous score ⭐ Current score 🔄 Score change
Performance 🔴 44 🔴 36 ↓ −7.8
SEO 🟢 92 🟡 85 ↓ −7.7
Best Practices 🟢 100 🟢 97 ↓ −3.4
Code style 🟢 100 🟢 99 ↓ −0.4
Updates 🟡 71 🟡 71 ↓ −0.2
Code coverage 🟡 89 🟡 89 ↓ −0.1
Documentation 🔴 35 🔴 35 ↓ −0.1
Bug prevention 🟡 67 🟡 67
Security 🔴 43 🔴 43
Type Safety 🟡 56 🟡 56
Miscellaneous 🟡 67 🟡 67
Accessibility 🟢 92 🟢 92
👎 8 groups regressed, 👍 3 audits improved, 👎 13 audits regressed, 27 audits changed without impacting score

🗃️ Groups

🔌 Plugin 🗃️ Group ⭐ Previous score ⭐ Current score 🔄 Score change
ESLint Style guide (import) 🟢 100 🟡 80 ↓ −20
Lighthouse Performance 🔴 44 🔴 36 ↓ −7.8
Lighthouse SEO 🟢 92 🟡 85 ↓ −7.7
Lighthouse Best Practices 🟢 100 🟢 97 ↓ −3.4
ESLint Suggestions 🟢 100 🟢 99 ↓ −0.4
JS Packages NPM outdated dependencies 🟡 71 🟡 71 ↓ −0.2
Code coverage Code coverage metrics 🟡 89 🟡 89 ↓ −0.1
JSDoc coverage Documentation coverage 🔴 35 🔴 35 ↓ −0.1

13 other groups are unchanged.

🛡️ Audits

🔌 Plugin 🛡️ Audit 📏 Previous value 📏 Current value 🔄 Value change
ESLint Forbid unassigned imports 🟩 passed 🟥 1 warning ↑ +∞ %
Lighthouse No browser errors logged to the console 🟩 passed 🟥 failed ↓ −100 %
Lighthouse robots.txt is valid 🟩 passed 🟥 failed ↓ −100 %
Lighthouse Enable text compression 🟩 0 🟨 Potential savings of 44 KiB  −∞ %
Lighthouse Properly size images 🟨 Potential savings of 5 KiB 🟩 0  −∞ %
Lighthouse First Contentful Paint 🟥 3.2 s 🟥 5.1 s ↑ +55.9 %
Lighthouse Speed Index 🟥 6.7 s 🟥 9.8 s ↑ +47.2 %
Lighthouse Total Blocking Time 🟥 800 ms 🟥 920 ms ↑ +15.4 %
Lighthouse Time to Interactive 🟥 13.0 s 🟥 14.4 s ↑ +10.2 %
JS Packages Outdated NPM dev dependencies. 🟨 59 outdated package versions (34 major, 19 minor, 6 patch) 🟨 60 outdated package versions (35 major, 19 minor, 6 patch) ↑ +1.7 %
Code coverage Line coverage 🟨 84.7 % 🟨 84.4 % ↓ −0.3 %
Code coverage Branch coverage 🟨 87.3 % 🟨 87.1 % ↓ −0.2 %
JSDoc coverage Types coverage 🟥 241 undocumented types 🟥 244 undocumented types ↑ +1.2 %
Code coverage Function coverage 🟩 90.3 % 🟩 90.4 % ↑ +0.1 %
JSDoc coverage Variables coverage 🟥 246 undocumented variables 🟥 253 undocumented variables ↑ +2.8 %
JSDoc coverage Functions coverage 🟥 561 undocumented functions 🟥 559 undocumented functions ↓ −0.4 %
Lighthouse Avoids enormous network payloads 🟩 Total size was 2,032 KiB 🟩 Total size was 2,192 KiB ↑ +7.9 %
Lighthouse Uses efficient cache policy on static assets 🟨 32 resources found 🟨 29 resources found ↓ −1.3 %
Lighthouse Initial server response time was short 🟥 Root document took 790 ms 🟥 Root document took 2,580 ms ↑ +226.6 %
Lighthouse Metrics 🟩 100% 🟩 100% ↑ +10.2 %
Lighthouse Minimizes main-thread work 🟥 7.5 s 🟥 8.7 s ↑ +15.9 %
Lighthouse Largest Contentful Paint 🟥 11.6 s 🟥 11.2 s ↓ −3.5 %
Lighthouse Server Backend Latencies 🟩 1,760 ms 🟩 2,100 ms ↑ +19.2 %
Lighthouse Reduce unused CSS 🟥 Potential savings of 105 KiB 🟥 Potential savings of 94 KiB ↓ −26.9 %
Lighthouse Reduce unused JavaScript 🟥 Potential savings of 186 KiB 🟥 Potential savings of 188 KiB ↑ +16.9 %
Lighthouse JavaScript execution time 🟥 2.9 s 🟥 3.1 s ↑ +4 %
Lighthouse Avoids an excessive DOM size 🟥 2,249 elements 🟥 2,328 elements ↑ +3.5 %
Lighthouse Max Potential First Input Delay 🟥 840 ms 🟥 900 ms ↑ +7 %
Lighthouse Network Round Trip Times 🟩 50 ms 🟩 20 ms ↓ −49.4 %
TypeScript Semantic errors 🟥 2623 errors 🟥 2636 errors ↑ +0.5 %
Lighthouse Remove duplicate modules in JavaScript bundles 🟥 Potential savings of 104 KiB 🟥 Potential savings of 104 KiB ↓ −2 %
Axe Accessibility IDs used in ARIA and labels must be unique 🟩 38 elements 🟩 28 elements ↓ −26.3 %
Axe Accessibility ARIA hidden element must not be focusable or contain focusable elements 🟩 192 elements 🟩 200 elements ↑ +4.2 %
Axe Accessibility Elements must only use supported ARIA attributes 🟩 102 elements 🟩 96 elements ↓ −5.9 %
Axe Accessibility ARIA attributes must be used as specified for the element's role 🟩 102 elements 🟩 96 elements ↓ −5.9 %
Axe Accessibility Elements must only use permitted ARIA attributes 🟩 102 elements 🟩 96 elements ↓ −5.9 %
Axe Accessibility ARIA attributes must conform to valid names 🟩 102 elements 🟩 96 elements ↓ −5.9 %
Axe Accessibility Interactive controls must not be nested 🟩 63 elements 🟩 59 elements ↓ −6.3 %
Axe Accessibility Inline text spacing must be adjustable with custom stylesheets 🟩 44 elements 🟩 41 elements ↓ −6.8 %
Axe Accessibility Buttons must have discernible text 🟩 15 elements 🟩 13 elements ↓ −13.3 %
TypeScript No implicit any errors 🟥 96 errors 🟥 97 errors ↑ +1 %
Axe Accessibility ARIA attributes must conform to valid values 🟥 9 errors 🟥 8 errors ↓ −11.1 %
Axe Accessibility Elements must have their visible text as part of their accessible name 🟥 3 errors 🟥 2 errors ↓ −33.3 %

635 other audits are unchanged.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2025

Code PushUp

😐 Code PushUp report is unchanged – compared current commit c35dd16 with previous commit f74d2dd.


All of 14 projects are unchanged.

@BioPhoton BioPhoton marked this pull request as ready for review December 2, 2025 23:41
@BioPhoton BioPhoton requested a review from matejchalk December 2, 2025 23:41
BioPhoton and others added 7 commits December 3, 2025 16:20
Co-authored-by: Matěj Chalk <34691111+matejchalk@users.noreply.github.com>
Co-authored-by: Matěj Chalk <34691111+matejchalk@users.noreply.github.com>
BioPhoton added a commit that referenced this pull request Dec 5, 2025
This PR moves the transformer logic into tools and makes it configurable

Followup PR: #1162

---------

Co-authored-by: John Doe <john.doe@example.com>
Co-authored-by: Matěj Chalk <34691111+matejchalk@users.noreply.github.com>
@github-actions github-actions bot added the 🔬 testing writing tests label Dec 5, 2025
@BioPhoton BioPhoton requested a review from matejchalk December 5, 2025 16:45
@BioPhoton BioPhoton mentioned this pull request Dec 5, 2025
10 tasks
@BioPhoton BioPhoton enabled auto-merge (squash) December 10, 2025 12:41
"vscode-material-icons": "^0.1.0",
"zod": "^4.0.5"
"zod": "^4.0.5",
"zod2md": "^0.2.4"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is wrong. Think about what you are doing, please.

The package's dependencies should only list production dependencies, i.e. the minimum the end-user needs to have installed. Development tools like vitest or zod2md do not belong here.

The @nx/dependency-checks lint rule determines what the production dependencies should be by checking imports in all files matched by the production cache input. This is why we had the "!{projectRoot}/zod2md.config.ts" pattern in nx.json, because we know that zod2md.config.ts files aren't part of production builds. I've no idea why you removed that line.

"!{projectRoot}/CHANGELOG.md",
"!{projectRoot}/perf/**/*",
"!{projectRoot}/tools/**/*",
"!{projectRoot}/zod2md.config.ts",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please restore this line - see previous comment.

Comment on lines 10 to +11
"generate-docs",
"ts-patch",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't the plugin add these dependencies? The whole idea is that each project creates a config file (zod2md.config.ts), and the Nx plugin (zod2md-jsdocs) takes care of everything else.

Also, I wouldn't place the ts-patch here. The previous setup was simpler, as there was a single tspatch (actually called pre-build before) target in zod2md-jsdocs, and it was a dependency of zod2md-jsdocs's build target. This way, there's only 1 target in 1 project. Which makes sense, because installing ts-patch isn't something that needs to run per project, our development dependencies are installed globally.

Comment on lines +7 to +15
/**
* Creates the ts-patch target configuration
* @returns {object} ts-patch target configuration
*/
const createTsPatchTargetConfig = {
command: 'ts-patch install',
cache: true,
inputs: ['sharedGlobals', { runtime: 'ts-patch check' }],
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move this target into tools/zod2md-jsdocs/project.json - see previous comment.

Comment on lines -17 to -21
"pre-build": {
"command": "ts-patch install",
"cache": true,
"inputs": ["sharedGlobals", { "runtime": "ts-patch check" }]
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would restore this target - see previous comment. I'm fine with renaming pre-build to tspatch, though.

Comment on lines 11 to 21
{
files: ['**/*.ts', '**/*.cjs', '**/*.js'],
rules: {
'import/no-commonjs': 'off',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'unicorn/prefer-module': 'off',
'functional/immutable-data': 'off',
'arrow-body-style': 'off',
},
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to disable any of these rules. Some of them don't actually have any errors (no-unused-vars and arrow-body-style). All the others are caused by using require('...') and module.exports = ... in .ts files.

I understand that Nx plugins have to run in CJS. But if you're using .ts, you can use normal import/export syntax anyway, because it gets transpiled to CJS syntax in .js files.

Suggested change
{
files: ['**/*.ts', '**/*.cjs', '**/*.js'],
rules: {
'import/no-commonjs': 'off',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'unicorn/prefer-module': 'off',
'functional/immutable-data': 'off',
'arrow-body-style': 'off',
},
},

Our regular lint config will pass if you convert the .ts files to use ESM imports/exports.

diff --git a/tools/zod2md-jsdocs/src/index.ts b/tools/zod2md-jsdocs/src/index.ts
index 461bc243a..a44fd9901 100644
--- a/tools/zod2md-jsdocs/src/index.ts
+++ b/tools/zod2md-jsdocs/src/index.ts
@@ -1,4 +1,3 @@
-const transformers = require('./lib/transformers.js');
+import transformers from './lib/transformers.js';
 
-module.exports = transformers;
-module.exports.default = transformers;
+export default transformers;
diff --git a/tools/zod2md-jsdocs/src/lib/transformers.ts b/tools/zod2md-jsdocs/src/lib/transformers.ts
index dc146fd1d..4b326d6e3 100644
--- a/tools/zod2md-jsdocs/src/lib/transformers.ts
+++ b/tools/zod2md-jsdocs/src/lib/transformers.ts
@@ -1,7 +1,5 @@
 import type { PluginConfig, TransformerExtras } from 'ts-patch';
-import type * as ts from 'typescript';
-
-const tsInstance: typeof ts = require('typescript');
+import ts from 'typescript';
 
 /**
  * Generates a JSDoc comment for a given type name and base URL.
@@ -36,7 +34,7 @@ function annotateTypeDefinitions(
         'Please configure it in your tsconfig.json plugins section.',
     );
   }
-  const tsLib = extras?.ts ?? tsInstance;
+  const tsLib = extras?.ts ?? ts;
   return (context: ts.TransformationContext) => {
     const visitor = (node: ts.Node): ts.Node => {
       if (
@@ -59,4 +57,4 @@ function annotateTypeDefinitions(
   };
 }
 
-module.exports = annotateTypeDefinitions;
+export default annotateTypeDefinitions;

Note that the nx-plugin.cjs file also doesn't violate our lint config, despite using require and module.exports. This is because our config is smart enough to recognize that it makes no sense to enforce ESM syntax in .cjs files:

https://github.com/code-pushup/eslint-config/blob/a15bb527f2fe89c5440ac638b53b74350e2b7a03/src/configs/javascript.js#L271-L279

// nx.json
{
//...
"plugins": ["./tools/zod2md-jsdocs-nx-plugin/src/lib/plugin.js"],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path ./tools/zod2md-jsdocs-nx-plugin/src/lib/plugin.js is incorrect; it's actually ./tools/zod2md-jsdocs/dist/src (as used in nx.json). It appears several times in this document.

BioPhoton and others added 4 commits December 11, 2025 16:49
Co-authored-by: Matěj Chalk <34691111+matejchalk@users.noreply.github.com>
Co-authored-by: Matěj Chalk <34691111+matejchalk@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🧹 maintenance 📖 Project documentation improvements or additions to the project documentation 🔬 testing writing tests 🛠️ tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants