@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.
Files changed (2) hide show
  1. package/index.js +43 -26
  2. 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 (!info.languageServiceHost.getScriptFileNames().includes(fileName)) {
33
+ if (!isProjectFileName(fileName)) {
33
34
  return result;
34
35
  }
35
- const sourceFile = info.languageService.getProgram()?.getSourceFile(fileName);
36
- if (sourceFile) {
37
- if (configFileDiagnostics.length) {
38
- result = result.concat(configFileDiagnostics.map(diagnostic => ({
39
- ...diagnostic,
40
- file: sourceFile,
41
- start: 0,
42
- length: 0,
43
- })));
44
- }
45
- if (config?.debug) {
46
- result.push({
47
- category: ts.DiagnosticCategory.Suggestion,
48
- source: 'tsslint',
49
- code: 'debug-info',
50
- messageText: JSON.stringify({
51
- rules: Object.keys(config?.rules ?? {}),
52
- plugins: config.plugins?.length,
53
- configFile,
54
- tsconfig,
55
- }, null, 2),
56
- file: sourceFile,
57
- start: 0,
58
- length: 0,
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.9",
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.9"
15
+ "@tsslint/core": "1.0.10"
16
16
  },
17
17
  "devDependencies": {
18
- "@tsslint/config": "1.0.9"
18
+ "@tsslint/config": "1.0.10"
19
19
  },
20
- "gitHead": "8e531c2a5ad3589cdcb0be75d0cacee0e4184c85"
20
+ "gitHead": "075fc3bf0058d41b4131345ab3634ad059562223"
21
21
  }