@tsslint/typescript-plugin 0.0.7 → 0.0.8

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 +33 -23
  2. package/package.json +4 -4
package/index.js CHANGED
@@ -21,9 +21,7 @@ const init = (modules) => {
21
21
  return pluginModule;
22
22
  };
23
23
  function decorateLanguageService(ts, tsconfig, info) {
24
- const getCompilerOptionsDiagnostics = info.languageService.getCompilerOptionsDiagnostics;
25
- const getSyntacticDiagnostics = info.languageService.getSyntacticDiagnostics;
26
- const getCodeFixesAtPosition = info.languageService.getCodeFixesAtPosition;
24
+ const { getCompilerOptionsDiagnostics, getSyntacticDiagnostics, getCodeFixesAtPosition, getCombinedCodeFix, } = info.languageService;
27
25
  let configFile;
28
26
  let configFileBuildContext;
29
27
  let configFileDiagnostics = [];
@@ -34,26 +32,25 @@ function decorateLanguageService(ts, tsconfig, info) {
34
32
  };
35
33
  info.languageService.getSyntacticDiagnostics = fileName => {
36
34
  let result = getSyntacticDiagnostics(fileName);
37
- if (info.languageServiceHost.getScriptFileNames().includes(fileName)) {
38
- if (linter) {
39
- result = result.concat(linter.lint(fileName));
40
- }
41
- if (config?.debug) {
42
- result.push({
43
- category: ts.DiagnosticCategory.Warning,
44
- source: 'tsslint',
45
- code: 'debug-info',
46
- messageText: JSON.stringify({
47
- rules: Object.keys(config?.rules ?? {}),
48
- plugins: config.plugins?.length,
49
- configFile,
50
- tsconfig,
51
- }, null, 2),
52
- file: info.languageService.getProgram().getSourceFile(fileName),
53
- start: 0,
54
- length: 0,
55
- });
56
- }
35
+ if (!linter || !info.languageServiceHost.getScriptFileNames().includes(fileName)) {
36
+ return result;
37
+ }
38
+ result = result.concat(linter.lint(fileName));
39
+ if (config?.debug) {
40
+ result.push({
41
+ category: ts.DiagnosticCategory.Warning,
42
+ source: 'tsslint',
43
+ code: 'debug-info',
44
+ messageText: JSON.stringify({
45
+ rules: Object.keys(config?.rules ?? {}),
46
+ plugins: config.plugins?.length,
47
+ configFile,
48
+ tsconfig,
49
+ }, null, 2),
50
+ file: info.languageService.getProgram().getSourceFile(fileName),
51
+ start: 0,
52
+ length: 0,
53
+ });
57
54
  }
58
55
  return result;
59
56
  };
@@ -63,6 +60,19 @@ function decorateLanguageService(ts, tsconfig, info) {
63
60
  ...linter?.getCodeFixes(fileName, start, end) ?? [],
64
61
  ];
65
62
  };
63
+ info.languageService.getCombinedCodeFix = (scope, fixId, formatOptions, preferences) => {
64
+ if (fixId === 'tsslint' && linter) {
65
+ const fixes = linter.getCodeFixes(scope.fileName, 0, Number.MAX_VALUE);
66
+ const changes = (0, core_1.combineCodeFixes)(scope.fileName, fixes);
67
+ return {
68
+ changes: [{
69
+ fileName: scope.fileName,
70
+ textChanges: changes,
71
+ }],
72
+ };
73
+ }
74
+ return getCombinedCodeFix(scope, fixId, formatOptions, preferences);
75
+ };
66
76
  return { update };
67
77
  async function update(pluginConfig) {
68
78
  let configOptionSpan = { start: 0, length: 0 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsslint/typescript-plugin",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
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": "0.0.7"
15
+ "@tsslint/core": "0.0.8"
16
16
  },
17
17
  "devDependencies": {
18
- "@tsslint/config": "0.0.7"
18
+ "@tsslint/config": "0.0.8"
19
19
  },
20
- "gitHead": "ed1086b1f11469e0a9d6a14199c7e027eb28b488"
20
+ "gitHead": "6fc30164bf7d50722f3fdb565f178b13821be692"
21
21
  }