code-pushup / cli

A CLI to run all kinds of code quality measurements to align your team with company goals
https://code-pushup.dev
MIT License
255 stars 14 forks source link

refactor: use type imports throughout codebase #803

Closed matejchalk closed 2 months ago

matejchalk commented 2 months ago

Motivation - see Consistent Type Imports and Exports: Why and How.

Enabled verbatimModuleSyntax flag and autofixed imports and exports by temporarily enabling consistent-type-imports and consistent-type-exports ESLint rules. The TypeScript ESLint docs don't recommend combining lint rules with compiler flag, so I went with compiler flag for all ESM-compatible projects. The CommonJS-only nx-plugin is the exception, so lint rules are used instead of compiler flag in this case.

IDEs should automatically suggest type imports and provide suggestions when there's an error (tested with VSCode), so it should make for good DX :crossed_fingers:

Also added an ESLint config for tools folder, since quite a lot of code exists there which could benefit from linting. It's not enforced in CI as it's not an Nx project, but the errors and warnings are now shown in IDE.

Almost all the changed files in this PR are result of autofix, the only other changes are to files:

github-actions[bot] commented 2 months ago

Code PushUp

๐Ÿคจ Code PushUp report has both improvements and regressions โ€“ compared target commit c2b66917958cfbcc8c268490bfd3d65d4a185623 with source commit 2db9a5c4c3b26365bc276c5c11b350a32e9d5f06.

๐Ÿ•ต๏ธ See full comparison in Code PushUp portal ๐Ÿ”

๐Ÿท๏ธ Categories

๐Ÿท๏ธ Category โญ Previous score โญ Current score ๐Ÿ”„ Score change
Performance ๐ŸŸก 51 ๐ŸŸก 54 โ†‘ +2.7
Code style ๐ŸŸข 99 ๐ŸŸข 99 โ†‘ +0
Code coverage ๐ŸŸก 90 ๐ŸŸก 90 โ†“ +0
Custom checks ๐ŸŸก 67 ๐ŸŸก 67 โ€“
Security ๐ŸŸข 98 ๐ŸŸข 98 โ€“
Updates ๐ŸŸก 78 ๐ŸŸก 78 โ€“
Accessibility ๐ŸŸข 91 ๐ŸŸข 91 โ€“
Best Practices ๐ŸŸข 100 ๐ŸŸข 100 โ€“
SEO ๐ŸŸก 61 ๐ŸŸก 61 โ€“
Bug prevention ๐ŸŸข 100 ๐ŸŸข 100 โ€“
๐Ÿ‘ 2 groups improved, ๐Ÿ‘Ž 1 group regressed, ๐Ÿ‘ 5 audits improved, ๐Ÿ‘Ž 1 audit regressed, 12 audits changed without impacting score ## ๐Ÿ—ƒ๏ธ Groups | ๐Ÿ”Œ Plugin | ๐Ÿ—ƒ๏ธ Group | โญ Previous score | โญ Current score | ๐Ÿ”„ Score change | | :--------------------------------------------------------------------------- | :-------------------- | :--------------: | :-------------: | :--------------------------------------------------------------: | | Lighthouse | Performance | ๐ŸŸก 51 | ๐ŸŸก **54** | ![โ†‘ +2.7](https://img.shields.io/badge/%E2%86%91%20%2B2.7-green) | | [ESLint](https://www.npmjs.com/package/@code-pushup/eslint-plugin) | Suggestions | ๐ŸŸข 99 | ๐ŸŸข **99** | ![โ†‘ +0](https://img.shields.io/badge/%E2%86%91%20%2B0-green) | | [Code coverage](https://www.npmjs.com/package/@code-pushup/coverage-plugin/) | Code coverage metrics | ๐ŸŸก 90 | ๐ŸŸก **90** | ![โ†“ +0](https://img.shields.io/badge/%E2%86%93%20%2B0-red) | 17 other groups are unchanged. ## ๐Ÿ›ก๏ธ Audits | ๐Ÿ”Œ Plugin | ๐Ÿ›ก๏ธ Audit | ๐Ÿ“ Previous value | ๐Ÿ“ Current value | ๐Ÿ”„ Value change | | :--------------------------------------------------------------------------- | :------------------------------------------- | :------------------------------: | :---------------------------------: | :--------------------------------------------------------------------------------: | | Lighthouse | Speed Index | ๐ŸŸฅ 6.2ย s | ๐ŸŸจ **5.6ย s** | ![โ†“ โˆ’10โ€‰%](https://img.shields.io/badge/%E2%86%93%20%E2%88%9210%E2%80%89%25-green) | | Lighthouse | Largest Contentful Paint | ๐ŸŸจ 3.4ย s | ๐ŸŸจ **3.2ย s** | ![โ†“ โˆ’7โ€‰%](https://img.shields.io/badge/%E2%86%93%20%E2%88%927%E2%80%89%25-green) | | Lighthouse | First Meaningful Paint | ๐ŸŸจ 3.0ย s | ๐ŸŸจ **2.9ย s** | ![โ†“ โˆ’3โ€‰%](https://img.shields.io/badge/%E2%86%93%20%E2%88%923%E2%80%89%25-green) | | Lighthouse | Time to Interactive | ๐ŸŸฅ 17.6ย s | ๐ŸŸฅ **15.9ย s** | ![โ†“ โˆ’10โ€‰%](https://img.shields.io/badge/%E2%86%93%20%E2%88%9210%E2%80%89%25-green) | | Lighthouse | First Contentful Paint | ๐ŸŸจ 2.9ย s | ๐ŸŸจ **2.9ย s** | ![โ†“ โˆ’1โ€‰%](https://img.shields.io/badge/%E2%86%93%20%E2%88%921%E2%80%89%25-green) | | [Code coverage](https://www.npmjs.com/package/@code-pushup/coverage-plugin/) | Line coverage | ๐ŸŸฉ 91.9 % | ๐ŸŸฉ **91.9 %** | ![โ†“ +0โ€‰%](https://img.shields.io/badge/%E2%86%93%20%2B0%E2%80%89%25-red) | | Lighthouse | Total Blocking Time | ๐ŸŸฅ 10,920ย ms | ๐ŸŸฅ **6,920ย ms** | ![โ†“ โˆ’37โ€‰%](https://img.shields.io/badge/%E2%86%93%20%E2%88%9237%E2%80%89%25-gray) | | Lighthouse | Minimizes main-thread work | ๐ŸŸฅ 22.7ย s | ๐ŸŸฅ **18.7ย s** | ![โ†“ โˆ’18โ€‰%](https://img.shields.io/badge/%E2%86%93%20%E2%88%9218%E2%80%89%25-gray) | | Lighthouse | JavaScript execution time | ๐ŸŸฅ 10.6ย s | ๐ŸŸฅ **8.0ย s** | ![โ†“ โˆ’25โ€‰%](https://img.shields.io/badge/%E2%86%93%20%E2%88%9225%E2%80%89%25-gray) | | Lighthouse | Metrics | ๐ŸŸฉ 100% | ๐ŸŸฉ **100%** | ![โ†“ โˆ’10โ€‰%](https://img.shields.io/badge/%E2%86%93%20%E2%88%9210%E2%80%89%25-gray) | | Lighthouse | Max Potential First Input Delay | ๐ŸŸฅ 2,920ย ms | ๐ŸŸฅ **2,220ย ms** | ![โ†“ โˆ’24โ€‰%](https://img.shields.io/badge/%E2%86%93%20%E2%88%9224%E2%80%89%25-gray) | | Lighthouse | Uses efficient cache policy on static assets | ๐ŸŸจ 27 resources found | ๐ŸŸจ **27 resources found** | ![โ†‘ +0โ€‰%](https://img.shields.io/badge/%E2%86%91%20%2B0%E2%80%89%25-gray) | | Lighthouse | Eliminate render-blocking resources | ๐ŸŸฅ Potential savings of 1,000ย ms | ๐ŸŸฅ **Potential savings of 860ย ms** | ![โ†“ โˆ’14โ€‰%](https://img.shields.io/badge/%E2%86%93%20%E2%88%9214%E2%80%89%25-gray) | | Lighthouse | Avoids enormous network payloads | ๐ŸŸฉ Total size was 1,808ย KiB | ๐ŸŸฉ **Total size was 1,808ย KiB** | ![โ†“ +0โ€‰%](https://img.shields.io/badge/%E2%86%93%20%2B0%E2%80%89%25-gray) | | Lighthouse | Server Backend Latencies | ๐ŸŸฉ 240ย ms | ๐ŸŸฉ **200ย ms** | ![โ†“ โˆ’19โ€‰%](https://img.shields.io/badge/%E2%86%93%20%E2%88%9219%E2%80%89%25-gray) | | Lighthouse | Reduce unused CSS | ๐ŸŸฅ Potential savings of 106ย KiB | ๐ŸŸฅ **Potential savings of 106ย KiB** | ![โ†‘ +5โ€‰%](https://img.shields.io/badge/%E2%86%91%20%2B5%E2%80%89%25-gray) | | Lighthouse | Initial server response time was short | ๐ŸŸฉ Root document took 520ย ms | ๐ŸŸฉ **Root document took 510ย ms** | ![โ†“ โˆ’2โ€‰%](https://img.shields.io/badge/%E2%86%93%20%E2%88%922%E2%80%89%25-gray) | | Lighthouse | Network Round Trip Times | ๐ŸŸฉ 70ย ms | ๐ŸŸฉ **70ย ms** | ![โ†‘ +1โ€‰%](https://img.shields.io/badge/%E2%86%91%20%2B1%E2%80%89%25-gray) | 492 other audits are unchanged.