@tsslint/typescript-plugin 1.0.14 → 1.0.16

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.
Files changed (2) hide show
  1. package/index.js +50 -69
  2. package/package.json +4 -4
package/index.js CHANGED
@@ -33,7 +33,7 @@ function decorateLanguageService(ts, tsconfig, info) {
33
33
  if (!isProjectFileName(fileName)) {
34
34
  return result;
35
35
  }
36
- if (configFileDiagnostics.length || config?.debug) {
36
+ if (configFileDiagnostics.length) {
37
37
  const sourceFile = info.languageService.getProgram()?.getSourceFile(fileName);
38
38
  if (sourceFile) {
39
39
  if (configFileDiagnostics.length) {
@@ -44,22 +44,6 @@ function decorateLanguageService(ts, tsconfig, info) {
44
44
  length: 0,
45
45
  })));
46
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
- }
63
47
  }
64
48
  }
65
49
  if (linter) {
@@ -160,22 +144,6 @@ function decorateLanguageService(ts, tsconfig, info) {
160
144
  if (!configFile) {
161
145
  return;
162
146
  }
163
- let configImportPath;
164
- try {
165
- configImportPath = require.resolve('@tsslint/config/lib/watch', { paths: [path.dirname(configFile)] });
166
- }
167
- catch (err) {
168
- configFileDiagnostics = [{
169
- category: ts.DiagnosticCategory.Error,
170
- code: 0,
171
- messageText: String(err),
172
- file: jsonConfigFile,
173
- start: 0,
174
- length: 0,
175
- }];
176
- return;
177
- }
178
- const { watchConfigFile } = require(configImportPath);
179
147
  const projectContext = {
180
148
  configFile,
181
149
  tsconfig,
@@ -183,44 +151,57 @@ function decorateLanguageService(ts, tsconfig, info) {
183
151
  languageService: info.languageService,
184
152
  typescript: ts,
185
153
  };
186
- configFileBuildContext = await watchConfigFile(configFile, (_config, { errors, warnings }) => {
187
- config = _config;
188
- configFileDiagnostics = [
189
- ...errors.map(error => [error, ts.DiagnosticCategory.Error]),
190
- ...warnings.map(error => [error, ts.DiagnosticCategory.Warning]),
191
- ].map(([error, category]) => {
192
- const diag = {
193
- category,
194
- source: 'tsslint',
195
- code: 0,
196
- messageText: 'Failed to build TSSLint config.',
197
- file: jsonConfigFile,
198
- start: configOptionSpan.start,
199
- length: configOptionSpan.length,
200
- };
201
- if (error.location) {
202
- const fileName = path.resolve(error.location.file);
203
- const fileText = ts.sys.readFile(error.location.file);
204
- const sourceFile = ts.createSourceFile(fileName, fileText ?? '', ts.ScriptTarget.Latest, true);
205
- diag.relatedInformation = [{
206
- category,
207
- code: error.id,
208
- messageText: error.text,
209
- file: sourceFile,
210
- start: sourceFile.getPositionOfLineAndCharacter(error.location.line - 1, error.location.column),
211
- length: error.location.lineText.length,
212
- }];
213
- }
214
- else {
215
- diag.messageText += `\n\n${error.text}`;
154
+ try {
155
+ configFileBuildContext = await (0, core_1.watchConfigFile)(configFile, (_config, { errors, warnings }) => {
156
+ config = _config;
157
+ configFileDiagnostics = [
158
+ ...errors.map(error => [error, ts.DiagnosticCategory.Error]),
159
+ ...warnings.map(error => [error, ts.DiagnosticCategory.Warning]),
160
+ ].map(([error, category]) => {
161
+ const diag = {
162
+ category,
163
+ source: 'tsslint',
164
+ code: 0,
165
+ messageText: 'Failed to build/load TSSLint config.',
166
+ file: jsonConfigFile,
167
+ start: configOptionSpan.start,
168
+ length: configOptionSpan.length,
169
+ };
170
+ if (error.location) {
171
+ const fileName = path.resolve(error.location.file);
172
+ const fileText = ts.sys.readFile(error.location.file);
173
+ const sourceFile = ts.createSourceFile(fileName, fileText ?? '', ts.ScriptTarget.Latest, true);
174
+ diag.relatedInformation = [{
175
+ category,
176
+ code: error.id,
177
+ messageText: error.text,
178
+ file: sourceFile,
179
+ start: sourceFile.getPositionOfLineAndCharacter(error.location.line - 1, error.location.column),
180
+ length: error.location.lineText.length,
181
+ }];
182
+ }
183
+ else {
184
+ diag.messageText += `\n\n${error.text}`;
185
+ }
186
+ return diag;
187
+ });
188
+ if (config) {
189
+ linter = (0, core_1.createLinter)(projectContext, config, true);
216
190
  }
217
- return diag;
191
+ info.project.refreshDiagnostics();
192
+ }, true, ts.sys.createHash);
193
+ }
194
+ catch (err) {
195
+ configFileDiagnostics.push({
196
+ category: ts.DiagnosticCategory.Error,
197
+ source: 'tsslint',
198
+ code: 'config-build-error',
199
+ messageText: String(err),
200
+ file: jsonConfigFile,
201
+ start: configOptionSpan.start,
202
+ length: configOptionSpan.length,
218
203
  });
219
- if (config) {
220
- linter = (0, core_1.createLinter)(projectContext, config, true);
221
- }
222
- info.project.refreshDiagnostics();
223
- }, true, ts.sys.createHash);
204
+ }
224
205
  }
225
206
  }
226
207
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsslint/typescript-plugin",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
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.14"
15
+ "@tsslint/core": "1.0.16"
16
16
  },
17
17
  "devDependencies": {
18
- "@tsslint/config": "1.0.14"
18
+ "@tsslint/config": "1.0.16"
19
19
  },
20
- "gitHead": "84ea99432b44827a79ac034896202652bf21c912"
20
+ "gitHead": "e430814fd394da5afbcd3157d02c246592162f75"
21
21
  }