Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / @typescript-eslint / typescript-estree / dist / create-program / shared.js
1 "use strict";
2 var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3     if (k2 === undefined) k2 = k;
4     Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5 }) : (function(o, m, k, k2) {
6     if (k2 === undefined) k2 = k;
7     o[k2] = m[k];
8 }));
9 var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10     Object.defineProperty(o, "default", { enumerable: true, value: v });
11 }) : function(o, v) {
12     o["default"] = v;
13 });
14 var __importStar = (this && this.__importStar) || function (mod) {
15     if (mod && mod.__esModule) return mod;
16     var result = {};
17     if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18     __setModuleDefault(result, mod);
19     return result;
20 };
21 var __importDefault = (this && this.__importDefault) || function (mod) {
22     return (mod && mod.__esModule) ? mod : { "default": mod };
23 };
24 Object.defineProperty(exports, "__esModule", { value: true });
25 exports.getTsconfigPath = exports.getScriptKind = exports.getCanonicalFileName = exports.ensureAbsolutePath = exports.createDefaultCompilerOptionsFromExtra = exports.canonicalDirname = void 0;
26 const path_1 = __importDefault(require("path"));
27 const ts = __importStar(require("typescript"));
28 /**
29  * Default compiler options for program generation from single root file
30  */
31 const DEFAULT_COMPILER_OPTIONS = {
32     allowNonTsExtensions: true,
33     allowJs: true,
34     checkJs: true,
35     noEmit: true,
36     // extendedDiagnostics: true,
37     /**
38      * Flags required to make no-unused-vars work
39      */
40     noUnusedLocals: true,
41     noUnusedParameters: true,
42 };
43 function createDefaultCompilerOptionsFromExtra(extra) {
44     if (extra.debugLevel.has('typescript')) {
45         return Object.assign(Object.assign({}, DEFAULT_COMPILER_OPTIONS), { extendedDiagnostics: true });
46     }
47     return DEFAULT_COMPILER_OPTIONS;
48 }
49 exports.createDefaultCompilerOptionsFromExtra = createDefaultCompilerOptionsFromExtra;
50 // typescript doesn't provide a ts.sys implementation for browser environments
51 const useCaseSensitiveFileNames = ts.sys !== undefined ? ts.sys.useCaseSensitiveFileNames : true;
52 const correctPathCasing = useCaseSensitiveFileNames
53     ? (filePath) => filePath
54     : (filePath) => filePath.toLowerCase();
55 function getCanonicalFileName(filePath) {
56     let normalized = path_1.default.normalize(filePath);
57     if (normalized.endsWith(path_1.default.sep)) {
58         normalized = normalized.substr(0, normalized.length - 1);
59     }
60     return correctPathCasing(normalized);
61 }
62 exports.getCanonicalFileName = getCanonicalFileName;
63 function ensureAbsolutePath(p, extra) {
64     return path_1.default.isAbsolute(p)
65         ? p
66         : path_1.default.join(extra.tsconfigRootDir || process.cwd(), p);
67 }
68 exports.ensureAbsolutePath = ensureAbsolutePath;
69 function getTsconfigPath(tsconfigPath, extra) {
70     return getCanonicalFileName(ensureAbsolutePath(tsconfigPath, extra));
71 }
72 exports.getTsconfigPath = getTsconfigPath;
73 function canonicalDirname(p) {
74     return path_1.default.dirname(p);
75 }
76 exports.canonicalDirname = canonicalDirname;
77 function getScriptKind(extra, filePath = extra.filePath) {
78     const extension = path_1.default.extname(filePath).toLowerCase();
79     // note - we respect the user's extension when it is known  we could override it and force it to match their
80     // jsx setting, but that could create weird situations where we throw parse errors when TSC doesn't
81     switch (extension) {
82         case '.ts':
83             return ts.ScriptKind.TS;
84         case '.tsx':
85             return ts.ScriptKind.TSX;
86         case '.js':
87             return ts.ScriptKind.JS;
88         case '.jsx':
89             return ts.ScriptKind.JSX;
90         case '.json':
91             return ts.ScriptKind.JSON;
92         default:
93             // unknown extension, force typescript to ignore the file extension, and respect the user's setting
94             return extra.jsx ? ts.ScriptKind.TSX : ts.ScriptKind.TS;
95     }
96 }
97 exports.getScriptKind = getScriptKind;
98 //# sourceMappingURL=shared.js.map