Skip to content

⬅️ Back to Table of Contents

πŸ“„ getParserServices

πŸ“Š Analysis Summary

Metric Count
πŸ”§ Functions 2
πŸ“¦ Imports 3
πŸ“Š Variables & Constants 2

πŸ“š Table of Contents

πŸ› οΈ File Location:

πŸ“‚ packages/utils/src/eslint-utils/getParserServices.ts

πŸ“¦ Imports

Name Source
ParserServices ../ts-estree
ParserServicesWithTypeInformation ../ts-estree
parserSeemsToBeTSESLint ./parserSeemsToBeTSESLint

Variables & Constants

Name Type Kind Value Exported
ERROR_MESSAGE_REQUIRES_PARS... "You have used a rule which requires ... const "You have used a rule which requires type information, but don't have parserO... βœ—
ERROR_MESSAGE_UNKNOWN_PARSER "Note: detected a parser other than @... const 'Note: detected a parser other than @typescript-eslint/parser. Make sure the ... βœ—

Functions

getParserServices(context: Readonly<TSESLint.RuleContext<MessageId…): ParserServicesWithTypeInformation

Try to retrieve type-aware parser service from context. This will throw if it is not available.

Raw JSDoc

/**
 * Try to retrieve type-aware parser service from context.
 * This **_will_** throw if it is not available.
 */

Code
export function getParserServices<
  MessageIds extends string,
  Options extends readonly unknown[],
>(
  context: Readonly<TSESLint.RuleContext<MessageIds, Options>>,
): ParserServicesWithTypeInformation;

throwError(parser: string | undefined): never

Parameters:

  • parser string | undefined

Returns: never

Calls:

  • [ ERROR_MESSAGE_REQUIRES_PARSER_SERVICES,Parser: ${parser || '(unknown)'}, !parserSeemsToBeTSESLint(parser) && ERROR_MESSAGE_UNKNOWN_PARSER, ].filter
  • parserSeemsToBeTSESLint (from ./parserSeemsToBeTSESLint)
  • messages.join
Code
function throwError(parser: string | undefined): never {
  const messages = [
    ERROR_MESSAGE_REQUIRES_PARSER_SERVICES,
    `Parser: ${parser || '(unknown)'}`,
    !parserSeemsToBeTSESLint(parser) && ERROR_MESSAGE_UNKNOWN_PARSER,
  ].filter(Boolean);

  throw new Error(messages.join('\n'));
}

Generated by Syntax Scribe