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

feat: add TypeScript plugin #902

Draft
wants to merge 49 commits into
base: main
Choose a base branch
from
Draft

feat: add TypeScript plugin #902

wants to merge 49 commits into from

Conversation

BioPhoton
Copy link
Collaborator

@BioPhoton BioPhoton commented Dec 23, 2024

Implementation of the typescript plugin mentioned in #901. It uses the compiler programatically to retrieve TypeScript diagnostics for the compiler. Those diagnostice are mapped to audits and act like linting errors/warning.

NOTE
This is a PoC PR, when reviewing keep in mind that it will land in multiple smaller PR's.
The main reasoning behind the architecture is places in the related issue: #901

This PR includes:

  • implementation
  • unit tests
  • integration tests
  • e2e tests
  • user docs
  • code docs

Todos:

  • tsConfigPath: './tsconfig.json', should be optional
  • codes are commented
  • integration tests for all diagnostic issues

Proposed PR delivery:

  • changes in @code-pushup/utils
  • runner logic
  • plugin utils
  • plugin & usage
  • docs & CONTRIBUTING.md
  • e2e

closes #901

Screenshot 2024-12-27 at 21 03 51

Example Md Report:

Code PushUp Report

🏷 Category ⭐ Score 🛡 Audits
Typescript 🟡 88 47

🏷 Categories

Typescript

🟡 Score: 88

🛡️ Audits

ModuleResolution (Typescript)

🟥 19 (score: 0)

Issues

Severity Message Source file Line(s)
🚨 error Cannot find module '@babel/parser'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? node_modules/@types/babel__core/index.d.ts 2
🚨 error Cannot find module '@babel/types'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? node_modules/@types/babel__core/index.d.ts 5
🚨 error Cannot find module '@babel/parser'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? node_modules/@types/babel__core/index.d.ts 10
🚨 error Cannot find module '@babel/types'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? node_modules/@types/babel__generator/index.d.ts 1
🚨 error Cannot find module '@babel/parser'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? node_modules/@types/babel__template/index.d.ts 1
🚨 error Cannot find module '@babel/types'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? node_modules/@types/babel__template/index.d.ts 2
🚨 error Cannot find module '@babel/types'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? node_modules/@types/babel__traverse/index.d.ts 1
🚨 error Cannot find module 'undici-types'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option? node_modules/@types/node/globals.d.ts 6

📖 Docs

@github-actions github-actions bot added 📖 Project documentation improvements or additions to the project documentation 🔬 testing writing tests 🛠️ tooling labels Dec 23, 2024
Copy link

github-actions bot commented Dec 23, 2024

Code PushUp

🤨 Code PushUp report has both improvements and regressions – compared target commit 9b54309 with source commit c219602.

🕵️ See full comparison in Code PushUp portal 🔍

🏷️ Categories

🏷️ Category ⭐ Previous score ⭐ Current score 🔄 Score change
Performance 🟡 57 🔴 39 ↓ −17.7
Code coverage 🟢 91 🟢 91 ↑ +0.1
Typescript n/a (*) 🟢 100 n/a (*)
Security 🟡 81 🟡 81
Updates 🟡 80 🟡 80
Accessibility 🟢 91 🟢 91
Best Practices 🟢 100 🟢 100
SEO 🟡 61 🟡 61
Bug prevention 🟢 100 🟢 100
Code style 🟢 100 🟢 100

(*) New category.

👍 1 group improved, 👎 1 group regressed, 👍 1 audit improved, 👎 6 audits regressed, 11 audits changed without impacting score

🗃️ Groups

🔌 Plugin 🗃️ Group ⭐ Previous score ⭐ Current score 🔄 Score change
Lighthouse Performance 🟡 57 🔴 39 ↓ −17.7
Code coverage Code coverage metrics 🟢 91 🟢 91 ↑ +0.1

15 other groups are unchanged.

🛡️ Audits

🔌 Plugin 🛡️ Audit 📏 Previous value 📏 Current value 🔄 Value change
Lighthouse Largest Contentful Paint 🟨 2.9 s 🟥 4.6 s ↑ +56.5 %
Lighthouse Speed Index 🟨 5.3 s 🟥 7.6 s ↑ +45.2 %
Lighthouse First Contentful Paint 🟨 2.9 s 🟥 3.7 s ↑ +26 %
Lighthouse Time to Interactive 🟥 12.2 s 🟥 16.3 s ↑ +33 %
Lighthouse Total Blocking Time 🟥 2,860 ms 🟥 6,820 ms ↑ +138.6 %
Code coverage Function coverage 🟩 93.1 % 🟩 93.3 % ↑ +0.1 %
Code coverage Line coverage 🟩 90.9 % 🟩 90.8 % ↓ −0.1 %
Lighthouse Minimizes main-thread work 🟥 12.4 s 🟥 21.4 s ↑ +73.1 %
Lighthouse JavaScript execution time 🟥 5.0 s 🟥 10.1 s ↑ +102.3 %
Lighthouse Avoids enormous network payloads 🟩 Total size was 1,825 KiB 🟩 Total size was 1,820 KiB ↓ −0.3 %
Lighthouse Metrics 🟩 100% 🟩 100% ↑ +33 %
Lighthouse Max Potential First Input Delay 🟥 1,170 ms 🟥 3,960 ms ↑ +237.8 %
Lighthouse Uses efficient cache policy on static assets 🟨 28 resources found 🟨 28 resources found ↓ −0.1 %
Lighthouse Eliminate render-blocking resources 🟥 Potential savings of 1,080 ms 🟥 Potential savings of 1,460 ms ↑ +35.7 %
Lighthouse Initial server response time was short 🟩 Root document took 550 ms 🟩 Root document took 460 ms ↓ −15.5 %
Lighthouse Server Backend Latencies 🟩 190 ms 🟩 200 ms ↑ +4.9 %
Lighthouse Network Round Trip Times 🟩 70 ms 🟩 70 ms ↑ +0.6 %
Code coverage Branch coverage 🟨 85.8 % 🟨 85.8 % ↓ −0.1 %

570 other audits are unchanged.

@vmasek
Copy link
Collaborator

vmasek commented Dec 25, 2024

Amazing work, can't wait to give it a try in some big project, I had a brief look but I'll review later (🤔 is this a 🎄🎁?)

@BioPhoton BioPhoton mentioned this pull request Dec 26, 2024
9 tasks
package.json Outdated Show resolved Hide resolved
@@ -25,7 +27,7 @@
"@code-pushup/portal-client": "^0.9.0",
"@isaacs/cliui": "^8.0.2",
"@nx/devkit": "19.8.13",
"@poppinss/cliui": "^6.4.1",
"@poppinss/cliui": "^6.4.2",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a left over

Comment on lines +158 to +163
{
slug: 'language-and-environment',
weight: 1,
type: 'group',
plugin: 'typescript',
},
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

here we should mention the helper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📖 Project documentation improvements or additions to the project documentation 🔬 testing writing tests 🛠️ tooling 🧩 utils
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeScript Plugin
3 participants