.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / @typescript-eslint / experimental-utils / dist / eslint-utils / getParserServices.js
1 "use strict";
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.';
5 /**
6  * Try to retrieve typescript parser service from context
7  */
8 function getParserServices(context, allowWithoutFullTypeInformation = false) {
9     var _a;
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);
17     }
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);
24     }
25     return context.parserServices;
26 }
27 exports.getParserServices = getParserServices;
28 //# sourceMappingURL=getParserServices.js.map