-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
fix(rule-tester): handle window root path #10654
Conversation
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. |
✅ Deploy Preview for typescript-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
View your CI Pipeline Execution ↗ for commit ca95619.
☁️ Nx Cloud last updated this comment at |
@@ -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('..')) |
There was a problem hiding this comment.
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.
typescript-eslint/packages/eslint-plugin-internal/tests/rules/debug-namespace.test.ts
Lines 44 to 46 in ea6fbea
], | |
filename: 'C:\\Code\\typescript-eslint\\packages\\example\\file.ts', | |
output: "const log = debug('typescript-eslint:example:file');", |
There was a problem hiding this comment.
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.
typescript-eslint/packages/rule-tester/src/RuleTester.ts
Lines 997 to 999 in ea6fbea
const hasMessageOfThisRule = messages.some(m => m.ruleId === ruleName); | |
There was a problem hiding this comment.
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 🙂
There was a problem hiding this 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.
Codecov ReportAll modified and coverable lines are covered by tests ✅
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
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this 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
PR Checklist
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. 😄