@tsslint/config 1.5.3 → 1.5.4

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.
@@ -121,29 +121,36 @@ function create(cmdOption, reportsUnusedComments) {
121
121
  const startComment = commentText.match(reg);
122
122
  if (startComment?.index !== undefined) {
123
123
  const index = startComment.index + pos;
124
- const nextLine = sourceFile.getLineAndCharacterOfPosition(index).line + 1;
125
124
  const ruleId = startComment.groups?.ruleId;
126
125
  if (!comments.has(ruleId)) {
127
126
  comments.set(ruleId, []);
128
127
  }
129
128
  const disabledLines = comments.get(ruleId);
129
+ const line = sourceFile.getLineAndCharacterOfPosition(index).line;
130
+ let startLine = line;
131
+ if (mode === 'singleLine') {
132
+ const startWithComment = sourceFile.text.slice(sourceFile.getPositionOfLineAndCharacter(line, 0), index - 2).trim() === '';
133
+ if (startWithComment) {
134
+ startLine = line + 1; // If the comment is at the start of the line, the error is in the next line
135
+ }
136
+ }
130
137
  disabledLines.push({
131
138
  commentRange: [
132
139
  index - 2,
133
140
  index + startComment[0].length,
134
141
  ],
135
- nextLine,
142
+ startLine,
136
143
  });
137
144
  }
138
145
  else if (endReg) {
139
146
  const endComment = commentText.match(endReg);
140
147
  if (endComment?.index !== undefined) {
141
148
  const index = endComment.index + pos;
142
- const prevLine = sourceFile.getLineAndCharacterOfPosition(index).line - 1;
149
+ const prevLine = sourceFile.getLineAndCharacterOfPosition(index).line;
143
150
  const ruleId = endComment.groups?.ruleId;
144
151
  const disabledLines = comments.get(ruleId);
145
152
  if (disabledLines) {
146
- disabledLines[disabledLines.length - 1].lastLine = prevLine;
153
+ disabledLines[disabledLines.length - 1].endLine = prevLine;
147
154
  }
148
155
  }
149
156
  }
@@ -164,9 +171,9 @@ function create(cmdOption, reportsUnusedComments) {
164
171
  const states = comments.get(code);
165
172
  if (states) {
166
173
  if (mode === 'singleLine') {
167
- if (states.some(({ nextLine }) => nextLine === line)) {
174
+ if (states.some(comment => comment.startLine === line)) {
168
175
  for (const state of states) {
169
- if (state.nextLine === line) {
176
+ if (state.startLine === line) {
170
177
  state.used = true;
171
178
  break;
172
179
  }
@@ -175,9 +182,9 @@ function create(cmdOption, reportsUnusedComments) {
175
182
  }
176
183
  }
177
184
  else {
178
- if (states.some(({ nextLine, lastLine }) => line >= nextLine && line <= (lastLine ?? Number.MAX_VALUE))) {
185
+ if (states.some((comment => line >= comment.startLine && line <= (comment.endLine ?? Number.MAX_VALUE)))) {
179
186
  for (const state of states) {
180
- if (line >= state.nextLine && line <= (state.lastLine ?? Number.MAX_VALUE)) {
187
+ if (line >= state.startLine && line <= (state.endLine ?? Number.MAX_VALUE)) {
181
188
  state.used = true;
182
189
  break;
183
190
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsslint/config",
3
- "version": "1.5.3",
3
+ "version": "1.5.4",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -12,8 +12,8 @@
12
12
  "directory": "packages/config"
13
13
  },
14
14
  "dependencies": {
15
- "@tsslint/types": "1.5.3",
15
+ "@tsslint/types": "1.5.4",
16
16
  "ts-api-utils": "^2.0.0"
17
17
  },
18
- "gitHead": "563035c62d04ff2a5c393f4a37ab9635960de1d6"
18
+ "gitHead": "02cbc403c85b4224b5ccd732dc96f7a0991a6ae2"
19
19
  }