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(utils): add string helper #916

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

feat(utils): add string helper #916

wants to merge 12 commits into from

Conversation

BioPhoton
Copy link
Collaborator

This PR includes helper for the TypeScript plugin #902

@BioPhoton BioPhoton marked this pull request as ready for review January 10, 2025 18:53
@BioPhoton BioPhoton requested a review from matejchalk January 10, 2025 18:53
Copy link

github-actions bot commented Jan 10, 2025

Code PushUp

🤨 Code PushUp report has both improvements and regressions – compared target commit d34b256 with source commit 6c7ed9f.

🕵️ See full comparison in Code PushUp portal 🔍

🏷️ Categories

🏷️ Category ⭐ Previous score ⭐ Current score 🔄 Score change
Performance 🟡 55 🟡 51 ↓ −3.7
Documentation 🔴 23 🔴 23 ↑ +0.1
Code coverage 🟢 91 🟢 91 ↑ +0.1
Security 🟡 79 🟡 79
Updates 🟡 77 🟡 77
Accessibility 🟢 92 🟢 92
Best Practices 🟢 100 🟢 100
SEO 🟡 61 🟡 61
Bug prevention 🟢 100 🟢 100
Code style 🟢 100 🟢 100
👍 2 groups improved, 👎 1 group regressed, 👍 5 audits improved, 👎 6 audits regressed, 10 audits changed without impacting score

🗃️ Groups

🔌 Plugin 🗃️ Group ⭐ Previous score ⭐ Current score 🔄 Score change
Lighthouse Performance 🟡 55 🟡 51 ↓ −3.7
JSDoc coverage Documentation coverage 🔴 23 🔴 23 ↑ +0.1
Code coverage Code coverage metrics 🟢 91 🟢 91 ↑ +0.1

15 other groups are unchanged.

🛡️ Audits

🔌 Plugin 🛡️ Audit 📏 Previous value 📏 Current value 🔄 Value change
Lighthouse Initial server response time was short 🟥 Root document took 610 ms 🟩 Root document took 450 ms ↓ −25.7 %
Lighthouse Speed Index 🟨 5.0 s 🟥 6.3 s ↑ +25.3 %
Lighthouse Time to Interactive 🟥 13.7 s 🟥 15.9 s ↑ +16.3 %
Lighthouse Largest Contentful Paint 🟨 3.3 s 🟨 3.5 s ↑ +4.6 %
Lighthouse First Contentful Paint 🟨 2.7 s 🟨 2.8 s ↑ +2.7 %
Lighthouse Total Blocking Time 🟥 3,800 ms 🟥 7,070 ms ↑ +86.2 %
JSDoc coverage Functions coverage 🟥 437 undocumented functions 🟥 437 undocumented functions  +0 %
JSDoc coverage Types coverage 🟥 198 undocumented types 🟥 200 undocumented types ↑ +1 %
Code coverage Line coverage 🟩 90.1 % 🟩 90.1 % ↑ +0.1 %
Code coverage Branch coverage 🟨 86 % 🟨 86 % ↑ +0.1 %
Code coverage Function coverage 🟩 93.1 % 🟩 93.1 % ↑ +0.1 %
Lighthouse Minimizes main-thread work 🟥 13.3 s 🟥 20.0 s ↑ +50.3 %
Lighthouse JavaScript execution time 🟥 6.3 s 🟥 8.9 s ↑ +40.7 %
Lighthouse Metrics 🟩 100% 🟩 100% ↑ +16.3 %
Lighthouse Max Potential First Input Delay 🟥 1,800 ms 🟥 2,360 ms ↑ +31.3 %
Lighthouse Eliminate render-blocking resources 🟥 Potential savings of 840 ms 🟥 Potential savings of 510 ms ↓ −39.2 %
Lighthouse Reduce unused CSS 🟥 Potential savings of 67 KiB 🟥 Potential savings of 48 KiB ↓ −67.4 %
Lighthouse Server Backend Latencies 🟩 130 ms 🟩 300 ms ↑ +119.7 %
Lighthouse Avoids enormous network payloads 🟩 Total size was 1,816 KiB 🟩 Total size was 1,816 KiB ↑ +0.1 %
Lighthouse Network Round Trip Times 🟩 20 ms 🟩 60 ms ↑ +248 %
Lighthouse Uses efficient cache policy on static assets 🟨 27 resources found 🟨 27 resources found ↓ −0.1 %

574 other audits are unchanged.

packages/utils/src/lib/string.ts Outdated Show resolved Hide resolved
packages/utils/src/lib/string.ts Outdated Show resolved Hide resolved
packages/utils/src/lib/string.unit.test.ts Outdated Show resolved Hide resolved
packages/utils/src/lib/string.ts Outdated Show resolved Hide resolved
packages/utils/src/lib/string.ts Outdated Show resolved Hide resolved
packages/utils/src/lib/types.ts Show resolved Hide resolved
packages/utils/src/lib/string.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@matejchalk matejchalk left a comment

Choose a reason for hiding this comment

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

Good job with the refactor and the tests 👍

I think the type tests need some more setup (see comments), but I don't see it as a blocker for this PR.

import { assertType, describe, expectTypeOf, it } from 'vitest';
import type { CamelCaseToKebabCase, KebabCaseToCamelCase } from './types.js';

/* eslint-disable vitest/expect-expect */
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's possible to configure alternative assertion function names to expect using assertFunctionNames option. I suggest adding this configuration to the base eslint.config.js:

export default tseslint.config(
  // ...
  {
    files: ['**/*.type.test.ts'],
    rules: {
      'vitest/expect-expect': [
        'error',
        { assertFunctionNames: ['expectTypeOf', 'assertType'] },
      ],
    },
  },
);

Copy link
Collaborator

Choose a reason for hiding this comment

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

I noticed these type tests aren't included anywhere. Extending the vite.config.unit.ts configuration like this includes them in unit-test target:

export default defineConfig({
  // ...
  test: {
    // ...
    typecheck: {
      enabled: true,
      include: ['**/*.type.test.ts'],
    },
  },
});

Copy link
Collaborator

Choose a reason for hiding this comment

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

Unfortunately, it seems to me like the typecheck always passes. When I deliberately introduce errors, they're correctly highlighted in IDE, but the test command reports passed tests anyway 😕

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants