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

test(eslint-plugin): render snapshots of ESLint output for each code example #8497

Merged
merged 27 commits into from
Apr 4, 2024

Conversation

auvred
Copy link
Member

@auvred auvred commented Feb 17, 2024

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @auvred!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

Copy link

netlify bot commented Feb 17, 2024

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 25c8102
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/660e8d1cac13fd0008467d16
😎 Deploy Preview https://deploy-preview-8497--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 99 (🟢 up 8 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 98 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Feb 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.08%. Comparing base (d863dd6) to head (25c8102).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8497      +/-   ##
==========================================
+ Coverage   88.02%   88.08%   +0.05%     
==========================================
  Files         405      405              
  Lines       14089    14089              
  Branches     4125     4125              
==========================================
+ Hits        12402    12410       +8     
+ Misses       1382     1376       -6     
+ Partials      305      303       -2     
Flag Coverage Δ
unittest 88.08% <ø> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 5 files with indirect coverage changes

Comment on lines 236 to 241
#### ❌ Incorrect for `requireNullish: true`

```ts option='{ "requireNullish": true }'
```ts option='{ "requireNullish": true }' skipValidation
declare const thing1: string | null;
thing1 && thing1.toString();
```
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a bug in the rule: #8487. For now I'll just add skipValidation...

@auvred auvred marked this pull request as ready for review March 4, 2024 05:54
Copy link
Contributor

@rubiesonthesky rubiesonthesky left a comment

Choose a reason for hiding this comment

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

I added one possible documentation change. Otherwise I think this is a great idea and execution 🎉

auvred and others added 3 commits March 6, 2024 10:42
@auvred auvred added the blocked by another PR PRs which are ready to go but waiting on another PR label Mar 6, 2024
@JoshuaKGoldberg
Copy link
Member

🙌 unblocked now, I think!

@JoshuaKGoldberg JoshuaKGoldberg removed the blocked by another PR PRs which are ready to go but waiting on another PR label Apr 1, 2024
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

this looks good to me! Amazing work!
This should go a long way in helping us ensure we don't write bad docs!

Comment on lines +117 to +126
beforeAll(async () => {
// dynamic import('...') is transpiled to the require('...') call,
// but all modules imported below are ESM only, so we cannot require() them
// eslint-disable-next-line @typescript-eslint/no-implied-eval
const dynamicImport = new Function('module', 'return import(module)');
({ fromMarkdown } = await dynamicImport('mdast-util-from-markdown'));
({ mdxjs } = await dynamicImport('micromark-extension-mdxjs'));
({ mdxFromMarkdown } = await dynamicImport('mdast-util-mdx'));
unistUtilVisit = await dynamicImport('unist-util-visit');
});
Copy link
Member

Choose a reason for hiding this comment

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

question: could we change this file's extension to .mts so that we can use ESM and avoid this hack?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I've tried it!

But if we change it to .mts, we get a bunch of other issues:

  • we need to add .js extension to relative imports because of moduleResolution
  • we have to remove these .js extensions in jest via moduleNameMapper (jest does not load these files without moduleNameMapper)
  • these imported files contain all exported members in the default property, so I added interopDefault

Here I tried to address all of them - auvred@020b12c (yarn lint, yarn test and yarn typecheck pass locally)

I'm not sure which solution is better (I don't like both, though 😄)

Copy link
Member

@bradzacher bradzacher Apr 4, 2024

Choose a reason for hiding this comment

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

Ugh jest is becoming a burden.
Might be about time to consider migrating to something else that supports ESM better.

@bradzacher bradzacher added the tests anything to do with testing label Apr 4, 2024
@bradzacher bradzacher merged commit a7bdd1c into typescript-eslint:main Apr 4, 2024
59 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
tests anything to do with testing
Projects
None yet
4 participants