8000 Bug: `RuleTester`: cannot read properties of `undefined` (reading `'parse'` ) · Issue #10191 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

Bug: RuleTester: cannot read properties of undefined (reading 'parse' ) #10191

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

Closed
4 tasks done
jeremybanka opened this issue Oct 21, 2024 · 4 comments · Fixed by #10201
Closed
4 tasks done

Bug: RuleTester: cannot read properties of undefined (reading 'parse' ) #10191

jeremybanka opened this issue Oct 21, 2024 · 4 comments · Fixed by #10201
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.

Comments

@jeremybanka
Copy link
jeremybanka commented Oct 21, 2024

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Issue Description

RuleTester is no longer able to function in any test case I have been able to find, always throwing a type error before handling the test case.

Looking into the issue, it seems to stem from providedConfig always being undefined. I suspect the issue was introduced by #10147 .

At some point, a property is accessed and we get the TypeError given in the title. In detail, it looks like

 FAIL  lint.test.ts > only-ever-use-literal-number-type > valid > type is number
Error: Caught an error while linting
 ❯ Linter.RuleTester.#linter.linter.verify node_modules/@typescript-eslint/rule-tester/src/RuleTester.ts:204:17
 ❯ RuleTester.runRuleForItem node_modules/@typescript-eslint/rule-tester/src/RuleTester.ts:770:33
 ❯ RuleTester.#testValidTemplate node_modules/@typescript-eslint/rule-tester/src/RuleTester.ts:863:25
 ❯ node_modules/@typescript-eslint/rule-tester/src/RuleTester.ts:541:40

Caused by: TypeError: Cannot read properties of undefined (reading 'parse')
 ❯ ParserService.parseSync node_modules/eslint/lib/services/parser-service.js:36:33
 ❯ Linter.#flatVerifyWithoutProcessors node_modules/eslint/lib/linter/linter.js:1680:47
 ❯ Linter._verifyWithFlatConfigArrayAndWithoutProcessors node_modules/eslint/lib/linter/linter.js:1992:49
 ❯ Linter._verifyWithFlatConfigArray node_modules/eslint/lib/linter/linter.js:2081:21
 ❯ Linter.verify node_modules/eslint/lib/linter/linter.js:1528:61
 ❯ Linter.RuleTester.#linter.linter.verify node_modules/@typescript-eslint/rule-tester/src/RuleTester.ts:202:18
 ❯ RuleTester.runRuleForItem node_modules/@typescript-eslint/rule-tester/src/RuleTester.ts:770:33
 ❯ RuleTester.#testValidTemplate node_modules/@typescript-eslint/rule-tester/src/RuleTester.ts:863:25
 ❯ node_modules/@typescript-eslint/rule-tester/src/RuleTester.ts:541:40 

Reproduction Repository Link

https://github.com/jeremybanka/tseslint-parsing-bug

Repro Steps

# 1. clone the repo
git clone https://github.com/jeremybanka/tseslint-parsing-bug.git
# 2. install dependencies
npm install
# 3. run tests
npm test

You will see the error shown above.

To verify that it does not occur with the previous version 8.10.0, simply revert my most recent commit:

# 1. go back one commit without leaving any staged changes
git reset --hard HEAD^
# 2. reinstall deps
npm install
# 3. rerun tests
npm test

Versions

package version
@typescript-eslint/eslint-plugin 8.11.0
@typescript-eslint/parser 8.11.0
@typescript-eslint/rule-tester 8.11.0
TypeScript 5.6.3
ESLint 9.13.0
node 22.10.0
@jeremybanka jeremybanka added bug Something isn't working triage Waiting for team members to take a look labels Oct 21, 2024
@kirkwaiblinger kirkwaiblinger added accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for team members to take a look labels Oct 21, 2024
@kirkwaiblinger
Copy link
Member

Noting for debugging that this depends on the version of eslint used. For me, it worked with 8.57 and up to eslint 9.4, but we get the error starting with eslint 9.5.

@kirkwaiblinger
Copy link
Member

Thanks @jeremybanka for making this very nice repro repo!

@RobinTail

This comment was marked as off-topic.

obulat added a commit to WordPress/openverse that referenced this issue Oct 26, 2024
Signed-off-by: Olga Bulat <obulat@gmail.com>
@kirkwaiblinger
Copy link
Member
kirkwaiblinger commented Oct 26, 2024

@RobinTail We are aware of this issue. There is also already a PR open to fix the issue in #10201 (I'd even encourage you to try it out and validate if it fixes your use case, or report on the PR if you find bugs with it!). Most likely either it or a revert will go out with our Monday release. No need to bump this issue with an "I have this issue too" comment. Thanks for understanding!

obulat added a commit to WordPress/openverse that referenced this issue Oct 28, 2024
Signed-off-by: Olga Bulat <obulat@gmail.com>
obulat added a commit to WordPress/openverse that referenced this issue Oct 29, 2024
Signed-off-by: Olga Bulat <obulat@gmail.com>
obulat added a commit to WordPress/openverse that referenced this issue Oct 30, 2024
Signed-off-by: Olga Bulat <obulat@gmail.com>
obulat added a commit to WordPress/openverse that referenced this issue Oct 31, 2024
Signed-off-by: Olga Bulat <obulat@gmail.com>
obulat added a commit to WordPress/openverse that referenced this issue Oct 31, 2024
Signed-off-by: Olga Bulat <obulat@gmail.com>
obulat added a commit to WordPress/openverse that referenced this issue Oct 31, 2024
Signed-off-by: Olga Bulat <obulat@gmail.com>
obulat added a commit to WordPress/openverse that referenced this issue Oct 31, 2024
* Migrate the plugin to ESLint v9
* Fix auto-fixable problems
* Fix other problems
* Update code owners
* Use ts config for js files
* Simplify gitignore handling
* Re-add vitest eslint rules to tests
* Downgrade ESLint to fix typescript-eslint/typescript-eslint#10191
* Add suggestions from the code review
* Update dependencies
---------

Signed-off-by: Olga Bulat <obulat@gmail.com>
@github-actions github-actions bot added the locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. label Nov 5, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.
Projects
None yet
3 participants
0