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

Appearance settings

Feature: getParserServices should throw informative error when used with non-typescript-eslint parser #6814

Copy link
Copy link
Closed
@RebeccaStevens

Description

@RebeccaStevens
Issue body actions

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.

Relevant Package

utils

Playground Link

No response

Repro Code

const parserServices = getParserServices(context, true);

ESLint Config

{
  "parser": "@babel/eslint-parser",
  "parserOptions": {
    "ecmaVersion": "latest",
    "requireConfigFile": false,
    "babelOptions": {
      "babelrc": false,
      "configFile": false
    }
  }
}

tsconfig

{
  "compilerOptions": {
    "lib": ["ESNext"],
    "module": "commonjs",
    "moduleResolution": "node",
    "skipLibCheck": true,
    "target": "ESNext"
  },
  "files": ["file.ts"]
}

Expected Result

typeof parserServices should be ParserServicesWithoutTypeInformation

Actual Result

An error is thrown:

You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.

Additional Info

This check is testing for null or undefined but my context.parserServices is an empty object and thus the error is thrown.

https://github.com/typescript-eslint/typescript-eslint/blob/v6/packages/utils/src/eslint-utils/getParserServices.ts#L35-L39

Edit: Looks like parserServices isn't actually set directly on the context object but is instead being inherited through its prototype chain.

Versions

package version
@typescript-eslint/eslint-plugin 6.0.0-alpha.106
@typescript-eslint/parser 6.0.0-alpha.106
@typescript-eslint/scope-manager 6.0.0-alpha.106
@typescript-eslint/typescript-estree 6.0.0-alpha.106
@typescript-eslint/type-utils 6.0.0-alpha.106
@typescript-eslint/utils 6.0.0-alpha.106
TypeScript 5.0.3
ESLint 8.36.0
node 18.15.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issueenhancementNew feature or requestNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.