Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(rule-tester): use cwd option to set base path for tests with file name#10201

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
bradzacher merged 5 commits intotypescript-eslint:mainfromreduckted:bugfix/10191
Oct 28, 2024

Conversation

reduckted
Copy link
Contributor

@reducktedreduckted commentedOct 23, 2024
edited
Loading

PR Checklist

Overview

If thefilename specified in a test is absolute or steps up at least one directory, then theLinter'scwd option is used to specify the base path.

When creating aFlatConfigArray, ESLint uses the linter'scwd option to specify the base path:
https://github.com/eslint/eslint/blob/725962731538eaa38d5d78b9e82ce3fccc9762d0/lib/linter/linter.js#L1524

Thecwd option is specified when creating theLinter object:
https://github.com/eslint/eslint/blob/3a4eaf921543b1cd5d1df4ea9dec02fab396af2a/lib/linter/linter.js#L1304

That means theRuleTester may need to create multipleLinter objects. I've created a Map ofLinter objects keyed by their base path.

For absolute paths and paths that step up a directory, the base path is calculated by resolving the file name relative to either thetsconfigRootDir specified in the parser options, orprocess.cwd(). The root of that path is used as the base path. This is equivalent to what#10174 was fixing. For any other paths, the filename does not affect the base path, meaning the behavior prior to#10174 is used.

Warning

This bug only exists after ESLint v9.5 (see#10191 (comment)).

I have tested these changes locally against ESLint v9.13.0, but haven't updated the version in this PR. I'm not sure what the desired solution is in regards to testing against multiple ESLint versions.

Zamiell, owjs3901, and johndalvik reacted with thumbs up emojiZamiell reacted with heart emojijeremybanka reacted with eyes emoji
@typescript-eslint
Copy link
Contributor

Thanks for the PR,@reduckted!

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 onhttps://opencollective.com/typescript-eslint.

@netlifyNetlify
Copy link

netlifybot commentedOct 23, 2024
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commit1e47a9e
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/671f7880d489ee0008e9f9db
😎 Deploy Previewhttps://deploy-preview-10201--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 5 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 yourNetlify site configuration.

@nx-cloudNx Cloud
Copy link

nx-cloudbot commentedOct 23, 2024
edited
Loading

☁️ Nx Cloud Report

CI is running/has finished running commands for commit1e47a9e. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 2 targets

Sent with 💌 fromNxCloud.

@reducktedreduckted changed the titlefix(rule-tester) use cwd option to set base path for tests with file namefix(rule-tester): use cwd option to set base path for tests with file nameOct 23, 2024
@codecovCodecov
Copy link

codecovbot commentedOct 23, 2024
edited
Loading

Codecov Report

Attention: Patch coverage is95.83333% with1 line in your changes missing coverage. Please review.

Project coverage is 86.50%. Comparing base(79c27a8) to head(1e47a9e).
Report is 12 commits behind head on main.

Files with missing linesPatch %Lines
packages/rule-tester/src/RuleTester.ts95.83%1 Missing⚠️
Additional details and impacted files
@@            Coverage Diff             @@##             main   #10201      +/-   ##==========================================+ Coverage   86.18%   86.50%   +0.32%==========================================  Files         430      430                Lines       15029    15088      +59       Branches     4360     4380      +20     ==========================================+ Hits        12952    13052     +100+ Misses       1725     1679      -46- Partials      352      357       +5
FlagCoverage Δ
unittest86.50% <95.83%> (+0.32%)⬆️

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

Files with missing linesCoverage Δ
packages/rule-tester/src/RuleTester.ts73.67% <95.83%> (+9.96%)⬆️

... and6 files with indirect coverage changes

@reduckted
Copy link
ContributorAuthor

Is the code coverage sufficient to get this merged? I feel like what it's reporting is wrong because it says that this statement is uncovered:

basePath=path.parse(path.resolve(basePath??process.cwd(),filename),).root;

But that statement is definitely being hit because the tests would fail if it wasn't. 😕

@jeremybanka
Copy link

jeremybanka commentedOct 24, 2024
edited
Loading

Is the code coverage sufficient to get this merged? I feel like what it's reporting is wrong because it says that this statement is uncovered:

basePath=path.parse(path.resolve(basePath??process.cwd(),filename),).root;

But that statement is definitely being hit because the tests would fail if it wasn't. 😕

Hey thank you for taking a look at this. You're right, this lineshould be covered. But it's not being run at all somehow. It seems to me that the reason that it's not is this one line infilename.test.ts:

import{RuleTester}from'@typescript-eslint/rule-tester';

This appears to resolve to a built asset in the dist/ folder and should be replaced with

import{RuleTester}from'../src/RuleTester';

That's whatRuleTester.test.ts does anyway.

See if this fixes the missing coverage issue!

kirkwaiblinger and Zamiell reacted with thumbs up emojireduckted and Zamiell reacted with heart emoji

@reduckted
Copy link
ContributorAuthor

This appears to resolve to a built asset in the dist/ folder and should be replaced with

Ah, brilliant! That's exactly what the problem was. Thanks!

kirkwaiblinger, jeremybanka, and Zamiell reacted with thumbs up emoji

@lotmek
Copy link
Contributor

Thank you@reduckted for this amazing fix !

I'm the one who introduced that regression with my changes and I sincerely apologize for any inconvenience it caused... 😔

Zamiell and jeremybanka reacted with heart emoji

@kirkwaiblinger
Copy link
Member

Warning

This bug only exists after ESLint v9.5 (see#10191 (comment)).

I have tested these changes locally against ESLint v9.13.0, but haven't updated the version in this PR. I'm not sure what the desired solution is in regards to testing against multiple ESLint versions.

I think for now, let's just go with "I tested it on my machine and it worked" (infamous last words) rather than upgrade eslint for this PR. Related,#1752.

kirkwaiblinger
kirkwaiblinger previously approved these changesOct 26, 2024
Copy link
Member

@kirkwaiblingerkirkwaiblinger left a comment

Choose a reason for hiding this comment

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

thank you for sending this in!!

@kirkwaiblingerkirkwaiblinger added the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelOct 26, 2024
@kirkwaiblingerkirkwaiblinger requested a review froma teamOctober 26, 2024 21:51
@github-actionsgithub-actionsbot removed the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelOct 26, 2024
@kirkwaiblingerkirkwaiblinger added the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelOct 26, 2024
Copy link
Member

@bradzacherbradzacher left a comment

Choose a reason for hiding this comment

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

mostly LGTM -- let's just get the test coverage up for that one extraundefined branch

errors: [
{
messageId: 'foo',
suggestions: [{ messageId: 'createError', output: '//' }],
Copy link
Member

Choose a reason for hiding this comment

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

This isn't a syntax error, right? Cos a line comment is valid. We need something invalid like( that will truly crash out the parser.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@bradzacherbradzacher merged commitbda3444 intotypescript-eslint:mainOct 28, 2024
62 checks passed
@bradzacher
Copy link
Member

Thanks for your work here!

@jtbandes
Copy link
Contributor

Awesome! Any chance of a patch release for this? :)

@Zamiell
Copy link
Contributor

@jtbandes Yes, there will be a release, read this page, which explains:https://typescript-eslint.io/users/releases/

@bradzacher
Copy link
Member

I meant to get to this before the release but baby stuff got in the way.
I've done an out-of-band release to get this out.

https://github.com/typescript-eslint/typescript-eslint/releases/tag/v8.12.1

maplesteve reacted with thumbs up emojijtbandes, kirkwaiblinger, albanlorillard, and reduckted reacted with heart emoji

@reducktedreduckted deleted the bugfix/10191 branchOctober 29, 2024 08:58
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsNov 6, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@bradzacherbradzacherbradzacher approved these changes

@kirkwaiblingerkirkwaiblingerkirkwaiblinger left review comments

Assignees
No one assigned
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
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Bug:RuleTester: cannot read properties ofundefined (reading'parse' )
7 participants
@reduckted@jeremybanka@lotmek@kirkwaiblinger@bradzacher@jtbandes@Zamiell

[8]ページ先頭

©2009-2025 Movatter.jp