@typescript-eslint/tsconfig-utils 8.32.2-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +12 -0
- package/dist/compilerOptions.d.ts +9 -0
- package/dist/compilerOptions.d.ts.map +1 -0
- package/dist/compilerOptions.js +13 -0
- package/dist/getParsedConfigFile.d.ts +9 -0
- package/dist/getParsedConfigFile.d.ts.map +1 -0
- package/dist/getParsedConfigFile.js +76 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 typescript-eslint and other contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# `@typescript-eslint/tsconfig-utils`
|
|
2
|
+
|
|
3
|
+
> Utilities for collecting TSConfigs for linting scenarios.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@typescript-eslint/tsconfig-utils)
|
|
6
|
+
[](https://www.npmjs.com/package/@typescript-eslint/tsconfig-utils)
|
|
7
|
+
|
|
8
|
+
The utilities in this package are separated from `@typescript-eslint/utils` so that they do not have a dependency on `eslint` or `@typescript-eslint/typescript-estree`.
|
|
9
|
+
|
|
10
|
+
> See https://typescript-eslint.io for general documentation on typescript-eslint, the tooling that allows you to run ESLint and Prettier on TypeScript code.
|
|
11
|
+
|
|
12
|
+
<!-- Local path for docs: docs/packages/TSConfig_Utils.mdx -->
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compilerOptions.d.ts","sourceRoot":"","sources":["../src/compilerOptions.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;CAOJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CORE_COMPILER_OPTIONS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Compiler options required to avoid critical functionality issues
|
|
6
|
+
*/
|
|
7
|
+
exports.CORE_COMPILER_OPTIONS = {
|
|
8
|
+
// Required to avoid parse from causing emit to occur
|
|
9
|
+
noEmit: true,
|
|
10
|
+
// Flags required to make no-unused-vars work
|
|
11
|
+
noUnusedLocals: true,
|
|
12
|
+
noUnusedParameters: true,
|
|
13
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
2
|
+
/**
|
|
3
|
+
* Parses a TSConfig file using the same logic as tsserver.
|
|
4
|
+
*
|
|
5
|
+
* @param configFile the path to the tsconfig.json file, relative to `projectDirectory`
|
|
6
|
+
* @param projectDirectory the project directory to use as the CWD, defaults to `process.cwd()`
|
|
7
|
+
*/
|
|
8
|
+
export declare function getParsedConfigFile(tsserver: typeof ts, configFile: string, projectDirectory?: string): ts.ParsedCommandLine;
|
|
9
|
+
//# sourceMappingURL=getParsedConfigFile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getParsedConfigFile.d.ts","sourceRoot":"","sources":["../src/getParsedConfigFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAO1D;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,OAAO,EAAE,EACnB,UAAU,EAAE,MAAM,EAClB,gBAAgB,CAAC,EAAE,MAAM,GACxB,EAAE,CAAC,iBAAiB,CA6CtB"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getParsedConfigFile = getParsedConfigFile;
|
|
37
|
+
const fs = __importStar(require("node:fs"));
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
|
+
const compilerOptions_1 = require("./compilerOptions");
|
|
40
|
+
/**
|
|
41
|
+
* Parses a TSConfig file using the same logic as tsserver.
|
|
42
|
+
*
|
|
43
|
+
* @param configFile the path to the tsconfig.json file, relative to `projectDirectory`
|
|
44
|
+
* @param projectDirectory the project directory to use as the CWD, defaults to `process.cwd()`
|
|
45
|
+
*/
|
|
46
|
+
function getParsedConfigFile(tsserver, configFile, projectDirectory) {
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/internal/eqeq-nullish
|
|
48
|
+
if (tsserver.sys === undefined) {
|
|
49
|
+
throw new Error('`getParsedConfigFile` is only supported in a Node-like environment.');
|
|
50
|
+
}
|
|
51
|
+
const parsed = tsserver.getParsedCommandLineOfConfigFile(configFile, compilerOptions_1.CORE_COMPILER_OPTIONS, {
|
|
52
|
+
fileExists: fs.existsSync,
|
|
53
|
+
getCurrentDirectory,
|
|
54
|
+
onUnRecoverableConfigFileDiagnostic: diag => {
|
|
55
|
+
throw new Error(formatDiagnostics([diag])); // ensures that `parsed` is defined.
|
|
56
|
+
},
|
|
57
|
+
readDirectory: tsserver.sys.readDirectory,
|
|
58
|
+
readFile: file => fs.readFileSync(path.isAbsolute(file) ? file : path.join(getCurrentDirectory(), file), 'utf-8'),
|
|
59
|
+
useCaseSensitiveFileNames: tsserver.sys.useCaseSensitiveFileNames,
|
|
60
|
+
});
|
|
61
|
+
if (parsed?.errors.length) {
|
|
62
|
+
throw new Error(formatDiagnostics(parsed.errors));
|
|
63
|
+
}
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
65
|
+
return parsed;
|
|
66
|
+
function getCurrentDirectory() {
|
|
67
|
+
return projectDirectory ? path.resolve(projectDirectory) : process.cwd();
|
|
68
|
+
}
|
|
69
|
+
function formatDiagnostics(diagnostics) {
|
|
70
|
+
return tsserver.formatDiagnostics(diagnostics, {
|
|
71
|
+
getCanonicalFileName: f => f,
|
|
72
|
+
getCurrentDirectory,
|
|
73
|
+
getNewLine: () => '\n',
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./compilerOptions"), exports);
|
|
18
|
+
__exportStar(require("./getParsedConfigFile"), exports);
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@typescript-eslint/tsconfig-utils",
|
|
3
|
+
"version": "8.32.2-alpha.12",
|
|
4
|
+
"description": "Utilities for collecting TSConfigs for linting scenarios.",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist",
|
|
7
|
+
"!*.tsbuildinfo",
|
|
8
|
+
"package.json",
|
|
9
|
+
"README.md",
|
|
10
|
+
"LICENSE"
|
|
11
|
+
],
|
|
12
|
+
"type": "commonjs",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./package.json": "./package.json"
|
|
19
|
+
},
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
|
22
|
+
},
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/typescript-eslint/typescript-eslint.git",
|
|
26
|
+
"directory": "packages/tsconfig-utils"
|
|
27
|
+
},
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/typescript-eslint/typescript-eslint/issues"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://typescript-eslint.io",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"keywords": [
|
|
34
|
+
"eslint",
|
|
35
|
+
"typescript",
|
|
36
|
+
"estree"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"//": "These package scripts are mostly here for convenience. Task running is handled by Nx at the root level.",
|
|
40
|
+
"build": "yarn run -BT nx build",
|
|
41
|
+
"clean": "rimraf dist/ coverage/",
|
|
42
|
+
"format": "yarn run -T format",
|
|
43
|
+
"lint": "yarn run -BT nx lint",
|
|
44
|
+
"test": "yarn run -BT nx test",
|
|
45
|
+
"typecheck": "yarn run -BT nx typecheck"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"typescript": ">=4.8.4 <5.9.0"
|
|
49
|
+
},
|
|
50
|
+
"funding": {
|
|
51
|
+
"type": "opencollective",
|
|
52
|
+
"url": "https://opencollective.com/typescript-eslint"
|
|
53
|
+
},
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"access": "public"
|
|
56
|
+
},
|
|
57
|
+
"nx": {
|
|
58
|
+
"name": "tsconfig-utils",
|
|
59
|
+
"includedScripts": [
|
|
60
|
+
"clean"
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
}
|