@typescript-eslint/project-service 8.70.2-alpha.9 → 8.71.1-alpha.0
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.
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.createProjectService = createProjectService;
|
|
7
7
|
const debug_1 = __importDefault(require("debug"));
|
|
8
8
|
const getParsedConfigFileFromTSServer_js_1 = require("./getParsedConfigFileFromTSServer.js");
|
|
9
|
+
const throttleOpenedFileCleanup_js_1 = require("./throttleOpenedFileCleanup.js");
|
|
9
10
|
const DEFAULT_PROJECT_MATCHED_FILES_THRESHOLD = 8;
|
|
10
11
|
const log = (0, debug_1.default)('typescript-eslint:project-service:createProjectService');
|
|
11
12
|
const logTsserverErr = (0, debug_1.default)('typescript-eslint:project-service:tsserver:err');
|
|
@@ -111,6 +112,7 @@ function createProjectService({ host, jsDocParsingMode, options: optionsRaw = {}
|
|
|
111
112
|
useInferredProjectPerProjectRoot: false,
|
|
112
113
|
useSingleInferredProject: false,
|
|
113
114
|
});
|
|
115
|
+
(0, throttleOpenedFileCleanup_js_1.throttleOpenedFileCleanup)(service);
|
|
114
116
|
service.setHostConfiguration({
|
|
115
117
|
preferences: {
|
|
116
118
|
includePackageJsonAutoImports: 'off',
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
2
|
+
/**
|
|
3
|
+
* Opening a file scans every open file and script info for cleanup.
|
|
4
|
+
* ESLint opens every linted file and never closes them, making that quadratic.
|
|
5
|
+
* @see https://github.com/typescript-eslint/typescript-eslint/issues/12936
|
|
6
|
+
*/
|
|
7
|
+
export declare function throttleOpenedFileCleanup(service: ts.server.ProjectService): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.throttleOpenedFileCleanup = throttleOpenedFileCleanup;
|
|
4
|
+
const OPENED_FILE_CLEANUP_THROTTLE_MS = 250;
|
|
5
|
+
/**
|
|
6
|
+
* Opening a file scans every open file and script info for cleanup.
|
|
7
|
+
* ESLint opens every linted file and never closes them, making that quadratic.
|
|
8
|
+
* @see https://github.com/typescript-eslint/typescript-eslint/issues/12936
|
|
9
|
+
*/
|
|
10
|
+
function throttleOpenedFileCleanup(service) {
|
|
11
|
+
const serviceInternals = service;
|
|
12
|
+
const cleanupKey = 'cleanupProjectsAndScriptInfos' in service
|
|
13
|
+
? 'cleanupProjectsAndScriptInfos'
|
|
14
|
+
: 'cleanupAfterOpeningFile';
|
|
15
|
+
const cleanup = serviceInternals[cleanupKey];
|
|
16
|
+
const open = service.openClientFileWithNormalizedPath;
|
|
17
|
+
let lastCleanup = -Infinity;
|
|
18
|
+
let opening = false;
|
|
19
|
+
serviceInternals[cleanupKey] = (...args) => {
|
|
20
|
+
const now = performance.now();
|
|
21
|
+
if (opening && now - lastCleanup < OPENED_FILE_CLEANUP_THROTTLE_MS) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
lastCleanup = now;
|
|
25
|
+
cleanup.apply(service, args);
|
|
26
|
+
};
|
|
27
|
+
service.openClientFileWithNormalizedPath = (...args) => {
|
|
28
|
+
opening = true;
|
|
29
|
+
try {
|
|
30
|
+
return open.apply(service, args);
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
opening = false;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=throttleOpenedFileCleanup.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/project-service",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.71.1-alpha.0",
|
|
4
4
|
"description": "Standalone TypeScript project service wrapper for linting.",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"typescript": ">=4.8.4 <6.1.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@typescript-eslint/tsconfig-utils": "^8.
|
|
42
|
-
"@typescript-eslint/types": "^8.
|
|
41
|
+
"@typescript-eslint/tsconfig-utils": "^8.71.1-alpha.0",
|
|
42
|
+
"@typescript-eslint/types": "^8.71.1-alpha.0",
|
|
43
43
|
"debug": "^4.4.3"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|