@tsslint/typescript-plugin 3.0.0-alpha.0 → 3.0.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.
- package/index.js +34 -46
- package/package.json +5 -5
package/index.js
CHANGED
|
@@ -119,62 +119,50 @@ function decorateLanguageService(ts, projectRoot, info) {
|
|
|
119
119
|
return;
|
|
120
120
|
}
|
|
121
121
|
const projectContext = {
|
|
122
|
-
|
|
123
|
-
languageService: info.languageService,
|
|
122
|
+
...info,
|
|
124
123
|
typescript: ts,
|
|
125
124
|
};
|
|
126
125
|
try {
|
|
127
|
-
config =
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if (relatedInfo) {
|
|
133
|
-
diag.relatedInformation.push(relatedInfo);
|
|
134
|
-
}
|
|
135
|
-
});
|
|
126
|
+
config = (await import(configFile)).default;
|
|
127
|
+
linter = core.createLinter(projectContext, path.dirname(configFile), config, (err, stackIndex) => {
|
|
128
|
+
const stacks = ErrorStackParser.parse(err);
|
|
129
|
+
if (stacks.length <= stackIndex) {
|
|
130
|
+
return [];
|
|
136
131
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const prevLength = configFileDiagnostics.length;
|
|
141
|
-
if (err instanceof Error) {
|
|
142
|
-
const relatedInfo = createRelatedInformation(ts, err, 0);
|
|
143
|
-
if (relatedInfo) {
|
|
144
|
-
configFileDiagnostics.push({
|
|
145
|
-
category: ts.DiagnosticCategory.Message,
|
|
146
|
-
code: 0,
|
|
147
|
-
messageText: err.message,
|
|
148
|
-
relatedInformation: [relatedInfo],
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
if (prevLength === configFileDiagnostics.length) {
|
|
153
|
-
configFileDiagnostics.push({
|
|
154
|
-
category: ts.DiagnosticCategory.Message,
|
|
155
|
-
code: 0,
|
|
156
|
-
messageText: String(err),
|
|
157
|
-
});
|
|
158
|
-
}
|
|
132
|
+
const relatedInfo = createRelatedInformation(ts, stacks[stackIndex]);
|
|
133
|
+
if (relatedInfo) {
|
|
134
|
+
return [relatedInfo];
|
|
159
135
|
}
|
|
160
|
-
|
|
136
|
+
return [];
|
|
137
|
+
});
|
|
161
138
|
}
|
|
162
139
|
catch (err) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
140
|
+
config = undefined;
|
|
141
|
+
linter = undefined;
|
|
142
|
+
const prevLength = configFileDiagnostics.length;
|
|
143
|
+
if (err instanceof Error) {
|
|
144
|
+
const relatedInfo = createRelatedInformation(ts, ErrorStackParser.parse(err)[0]);
|
|
145
|
+
if (relatedInfo) {
|
|
146
|
+
configFileDiagnostics.push({
|
|
147
|
+
category: ts.DiagnosticCategory.Message,
|
|
148
|
+
code: 0,
|
|
149
|
+
messageText: err.message,
|
|
150
|
+
relatedInformation: [relatedInfo],
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (prevLength === configFileDiagnostics.length) {
|
|
155
|
+
configFileDiagnostics.push({
|
|
156
|
+
category: ts.DiagnosticCategory.Message,
|
|
157
|
+
code: 0,
|
|
158
|
+
messageText: String(err),
|
|
159
|
+
});
|
|
160
|
+
}
|
|
168
161
|
}
|
|
169
162
|
}
|
|
170
163
|
}
|
|
171
164
|
}
|
|
172
|
-
function createRelatedInformation(ts,
|
|
173
|
-
const stacks = ErrorStackParser.parse(err);
|
|
174
|
-
if (stacks.length <= stackOffset) {
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
const stack = stacks[stackOffset];
|
|
165
|
+
function createRelatedInformation(ts, stack) {
|
|
178
166
|
if (stack.fileName && stack.lineNumber !== undefined && stack.columnNumber !== undefined) {
|
|
179
167
|
let fileName = stack.fileName.replace(/\\/g, '/');
|
|
180
168
|
if (fileName.startsWith('file://')) {
|
|
@@ -190,7 +178,7 @@ function createRelatedInformation(ts, err, stackOffset) {
|
|
|
190
178
|
fsFiles.set(fileName, [
|
|
191
179
|
text !== undefined,
|
|
192
180
|
mtime,
|
|
193
|
-
ts.createSourceFile(fileName, text ?? '', ts.ScriptTarget.Latest, true)
|
|
181
|
+
ts.createSourceFile(fileName, text ?? '', ts.ScriptTarget.Latest, true),
|
|
194
182
|
]);
|
|
195
183
|
}
|
|
196
184
|
const [exist, _mtime, relatedFile] = fsFiles.get(fileName);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsslint/typescript-plugin",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
"directory": "packages/typescript-plugin"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@tsslint/core": "3.0.0
|
|
15
|
+
"@tsslint/core": "3.0.0",
|
|
16
16
|
"error-stack-parser": "^2.1.4"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@tsslint/config": "3.0.0
|
|
19
|
+
"@tsslint/config": "3.0.0"
|
|
20
20
|
},
|
|
21
|
-
"gitHead": "
|
|
22
|
-
}
|
|
21
|
+
"gitHead": "69bc86cf2dd81f9e48fc15ed9b9f0351fa2fc19e"
|
|
22
|
+
}
|