@tsslint/typescript-plugin 1.0.9 → 1.0.10
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/index.js +43 -26
- package/package.json +4 -4
package/index.js
CHANGED
|
@@ -22,6 +22,7 @@ const init = modules => {
|
|
|
22
22
|
};
|
|
23
23
|
function decorateLanguageService(ts, tsconfig, info) {
|
|
24
24
|
const { getSemanticDiagnostics, getCodeFixesAtPosition, getCombinedCodeFix, } = info.languageService;
|
|
25
|
+
const projectFileNameKeys = new Set();
|
|
25
26
|
let configFile;
|
|
26
27
|
let configFileBuildContext;
|
|
27
28
|
let configFileDiagnostics = [];
|
|
@@ -29,34 +30,36 @@ function decorateLanguageService(ts, tsconfig, info) {
|
|
|
29
30
|
let linter;
|
|
30
31
|
info.languageService.getSemanticDiagnostics = fileName => {
|
|
31
32
|
let result = getSemanticDiagnostics(fileName);
|
|
32
|
-
if (!
|
|
33
|
+
if (!isProjectFileName(fileName)) {
|
|
33
34
|
return result;
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
36
|
+
if (configFileDiagnostics.length || config?.debug) {
|
|
37
|
+
const sourceFile = info.languageService.getProgram()?.getSourceFile(fileName);
|
|
38
|
+
if (sourceFile) {
|
|
39
|
+
if (configFileDiagnostics.length) {
|
|
40
|
+
result = result.concat(configFileDiagnostics.map(diagnostic => ({
|
|
41
|
+
...diagnostic,
|
|
42
|
+
file: sourceFile,
|
|
43
|
+
start: 0,
|
|
44
|
+
length: 0,
|
|
45
|
+
})));
|
|
46
|
+
}
|
|
47
|
+
if (config?.debug) {
|
|
48
|
+
result.push({
|
|
49
|
+
category: ts.DiagnosticCategory.Suggestion,
|
|
50
|
+
source: 'tsslint',
|
|
51
|
+
code: 'debug-info',
|
|
52
|
+
messageText: JSON.stringify({
|
|
53
|
+
rules: Object.keys(config?.rules ?? {}),
|
|
54
|
+
plugins: config.plugins?.length,
|
|
55
|
+
configFile,
|
|
56
|
+
tsconfig,
|
|
57
|
+
}, null, 2),
|
|
58
|
+
file: sourceFile,
|
|
59
|
+
start: 0,
|
|
60
|
+
length: 0,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
if (linter) {
|
|
@@ -84,6 +87,20 @@ function decorateLanguageService(ts, tsconfig, info) {
|
|
|
84
87
|
return getCombinedCodeFix(scope, fixId, formatOptions, preferences);
|
|
85
88
|
};
|
|
86
89
|
return { update };
|
|
90
|
+
function isProjectFileName(fileName) {
|
|
91
|
+
fileName = fileName.replace(/\\/g, '/');
|
|
92
|
+
const projectFileNames = info.languageServiceHost.getScriptFileNames();
|
|
93
|
+
if (projectFileNames.length !== projectFileNameKeys.size) {
|
|
94
|
+
projectFileNameKeys.clear();
|
|
95
|
+
for (const fileName of projectFileNames) {
|
|
96
|
+
projectFileNameKeys.add(getFileKey(fileName));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return projectFileNameKeys.has(getFileKey(fileName));
|
|
100
|
+
}
|
|
101
|
+
function getFileKey(fileName) {
|
|
102
|
+
return info.languageServiceHost.useCaseSensitiveFileNames?.() ? fileName : fileName.toLowerCase();
|
|
103
|
+
}
|
|
87
104
|
async function update(pluginConfig) {
|
|
88
105
|
let configOptionSpan = { start: 0, length: 0 };
|
|
89
106
|
let newConfigFile;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsslint/typescript-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"directory": "packages/typescript-plugin"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@tsslint/core": "1.0.
|
|
15
|
+
"@tsslint/core": "1.0.10"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@tsslint/config": "1.0.
|
|
18
|
+
"@tsslint/config": "1.0.10"
|
|
19
19
|
},
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "075fc3bf0058d41b4131345ab3634ad059562223"
|
|
21
21
|
}
|