Skip to content

fix(rule-tester): handle window root path #10654

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

Merged
merged 1 commit into from
Jan 19, 2025

Conversation

yeonjuan
Copy link
Contributor

@yeonjuan yeonjuan commented Jan 14, 2025

PR Checklist

  • Addresses an existing open issue: fixes #000 (There is no open issue, let me know if I should create one.)
  • That issue was marked as accepting prs
  • Steps in Contributing were taken

Overview

While testing, I accidentally raised the wrong PRs to this repository. Sorry for the unnecessary notifications. 😢
Eventually, I figured out the cause using a PC with window OS that I hadn't used in a long time. 😄

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @yeonjuan!

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 Jan 14, 2025

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit ca95619
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/67869e863c45d10008d9a721
😎 Deploy Preview https://deploy-preview-10654--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: 97 (🔴 down 1 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

nx-cloud bot commented Jan 14, 2025

View your CI Pipeline Execution ↗ for commit ca95619.

Command Status Duration Result
nx run-many --target=build --exclude website --... ✅ Succeeded 2s View ↗
nx run-many --target=clean ✅ Succeeded 12s View ↗

☁️ Nx Cloud last updated this comment at 2025-01-14 17:48:03 UTC

@@ -210,7 +210,7 @@ export class RuleTester extends TestFramework {
// file name (`foo.ts`), don't change the base path.
if (
filename != null &&
(filename.startsWith('/') || filename.startsWith('..'))
(path.isAbsolute(filename) || filename.startsWith('..'))
Copy link
Contributor Author

@yeonjuan yeonjuan Jan 14, 2025

Choose a reason for hiding this comment

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

If a window file path format is used in the filename of the test case, such as C:\\, the basePath must be changed so that the linter can find the cofnig file.

],
filename: 'C:\\Code\\typescript-eslint\\packages\\example\\file.ts',
output: "const log = debug('typescript-eslint:example:file');",

Copy link
Contributor Author

@yeonjuan yeonjuan Jan 14, 2025

Choose a reason for hiding this comment

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

BTW, the value of the messages when Linter does not find a config for a given filename is as follows

[
 { "ruleId": null, "severity": 1, "message": "No matching configuration found for C:\\Code....", "line": 0, "column": 0 }
]

@ronami, I think it would be nice to print an error message when this happens, or have an assertion for that. What do you think? If you agree, I'll open a new issue.

I'm thinking of adding an assertion or logging before this.

const hasMessageOfThisRule = messages.some(m => m.ruleId === ruleName);

Copy link
Member

Choose a reason for hiding this comment

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

FWIW I think I'm in favor 🙂

@yeonjuan yeonjuan marked this pull request as ready for review January 14, 2025 17:37
Copy link
Member

@ronami ronami left a comment

Choose a reason for hiding this comment

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

Thanks! ❤️

This would help make the main branch green.

@ronami ronami added the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Jan 14, 2025
Copy link

codecov bot commented Jan 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.00%. Comparing base (a175189) to head (ca95619).
Report is 15 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10654   +/-   ##
=======================================
  Coverage   87.00%   87.00%           
=======================================
  Files         447      448    +1     
  Lines       15586    15618   +32     
  Branches     4542     4551    +9     
=======================================
+ Hits        13560    13589   +29     
- Misses       1671     1673    +2     
- Partials      355      356    +1     
Flag Coverage Δ
unittest 87.00% <ø> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
packages/rule-tester/src/RuleTester.ts 74.57% <ø> (ø)

... and 1 file with indirect coverage changes

Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

shakes fist at Windows paths

@JoshuaKGoldberg JoshuaKGoldberg merged commit c9b7e6a into typescript-eslint:main Jan 19, 2025
89 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants