2 Object.defineProperty(exports, "__esModule", { value: true });
3 exports.getParserServices = void 0;
4 const ERROR_MESSAGE = '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.';
6 * Try to retrieve typescript parser service from context
8 function getParserServices(context, allowWithoutFullTypeInformation = false) {
10 // backwards compatibility check
11 // old versions of the parser would not return any parserServices unless parserOptions.project was set
12 if (!context.parserServices ||
13 !context.parserServices.program ||
14 !context.parserServices.esTreeNodeToTSNodeMap ||
15 !context.parserServices.tsNodeToESTreeNodeMap) {
16 throw new Error(ERROR_MESSAGE);
18 const hasFullTypeInformation = (_a = context.parserServices.hasFullTypeInformation) !== null && _a !== void 0 ? _a :
19 /* backwards compatible */ true;
20 // if a rule requires full type information, then hard fail if it doesn't exist
21 // this forces the user to supply parserOptions.project
22 if (!hasFullTypeInformation && !allowWithoutFullTypeInformation) {
23 throw new Error(ERROR_MESSAGE);
25 return context.parserServices;
27 exports.getParserServices = getParserServices;
28 //# sourceMappingURL=getParserServices.js.map