@tsslint/core 1.0.1 → 1.0.2

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 +42 -28
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -54,16 +54,16 @@ function createLinter(ctx, config, withStack) {
54
54
  }
55
55
  }
56
56
  return result;
57
- function reportError(message, start, end, trace = true) {
58
- return report(ts.DiagnosticCategory.Error, message, start, end, trace);
57
+ function reportError(message, start, end, traceOffset = 0) {
58
+ return report(ts.DiagnosticCategory.Error, message, start, end, traceOffset);
59
59
  }
60
- function reportWarning(message, start, end, trace = true) {
61
- return report(ts.DiagnosticCategory.Warning, message, start, end, trace);
60
+ function reportWarning(message, start, end, traceOffset = 0) {
61
+ return report(ts.DiagnosticCategory.Warning, message, start, end, traceOffset);
62
62
  }
63
- function reportSuggestion(message, start, end, trace = true) {
64
- return report(ts.DiagnosticCategory.Suggestion, message, start, end, trace);
63
+ function reportSuggestion(message, start, end, traceOffset = 0) {
64
+ return report(ts.DiagnosticCategory.Suggestion, message, start, end, traceOffset);
65
65
  }
66
- function report(category, message, start, end, trace) {
66
+ function report(category, message, start, end, traceOffset) {
67
67
  const error = {
68
68
  category,
69
69
  code: currentRuleId,
@@ -74,9 +74,33 @@ function createLinter(ctx, config, withStack) {
74
74
  source: 'tsslint',
75
75
  relatedInformation: [],
76
76
  };
77
- const stacks = trace ? ErrorStackParser.parse(new Error()) : [];
78
- if (stacks.length >= 3) {
79
- pushRelatedInformation(error, stacks[2]);
77
+ if (withStack) {
78
+ const stacks = traceOffset === false
79
+ ? []
80
+ : ErrorStackParser.parse(new Error());
81
+ if (typeof traceOffset === 'number') {
82
+ const baseOffset = 2 + traceOffset;
83
+ if (config.debug) {
84
+ for (let i = baseOffset; i < stacks.length; i++) {
85
+ pushRelatedInformation(error, stacks[i]);
86
+ }
87
+ }
88
+ else {
89
+ if (stacks.length > baseOffset) {
90
+ pushRelatedInformation(error, stacks[baseOffset]);
91
+ }
92
+ }
93
+ }
94
+ if (withStack) {
95
+ error.relatedInformation?.push({
96
+ category: ts.DiagnosticCategory.Message,
97
+ code: 0,
98
+ file: configSourceFile,
99
+ start: 0,
100
+ length: 0,
101
+ messageText: 'TSSLint configuration file',
102
+ });
103
+ }
80
104
  }
81
105
  result.push(error);
82
106
  return {
@@ -122,24 +146,14 @@ function createLinter(ctx, config, withStack) {
122
146
  pos = stackFile?.getPositionOfLineAndCharacter(stack.lineNumber - 1, stack.columnNumber - 1) ?? 0;
123
147
  }
124
148
  catch { }
125
- if (withStack) {
126
- error.relatedInformation?.push({
127
- category: ts.DiagnosticCategory.Message,
128
- code: 0,
129
- file: stackFile,
130
- start: pos,
131
- length: 0,
132
- messageText: '',
133
- });
134
- error.relatedInformation?.push({
135
- category: ts.DiagnosticCategory.Message,
136
- code: 0,
137
- file: configSourceFile,
138
- start: 0,
139
- length: 0,
140
- messageText: '',
141
- });
142
- }
149
+ error.relatedInformation?.push({
150
+ category: ts.DiagnosticCategory.Message,
151
+ code: 0,
152
+ file: stackFile,
153
+ start: pos,
154
+ length: 0,
155
+ messageText: 'Reported at',
156
+ });
143
157
  }
144
158
  }
145
159
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsslint/core",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -16,7 +16,7 @@
16
16
  "source-map-support": "^0.5.21"
17
17
  },
18
18
  "devDependencies": {
19
- "@tsslint/config": "1.0.1"
19
+ "@tsslint/config": "1.0.2"
20
20
  },
21
- "gitHead": "124aa300b4fb4d4c414f585cc0d4afddc4f343bf"
21
+ "gitHead": "e9bbdd4eba295de6bcb663e02c305f2b48893d6f"
22
22
  }