@tsslint/config 1.5.3 → 1.5.5

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
  }
@@ -162,26 +169,21 @@ function create(cmdOption, reportsUnusedComments) {
162
169
  reportedRules.push([error.code, line]);
163
170
  for (const code of [undefined, error.code]) {
164
171
  const states = comments.get(code);
165
- if (states) {
166
- if (mode === 'singleLine') {
167
- if (states.some(({ nextLine }) => nextLine === line)) {
168
- for (const state of states) {
169
- if (state.nextLine === line) {
170
- state.used = true;
171
- break;
172
- }
173
- }
172
+ if (!states) {
173
+ continue;
174
+ }
175
+ if (mode === 'singleLine') {
176
+ for (const state of states) {
177
+ if (state.startLine === line) {
178
+ state.used = true;
174
179
  return false;
175
180
  }
176
181
  }
177
- else {
178
- if (states.some(({ nextLine, lastLine }) => line >= nextLine && line <= (lastLine ?? Number.MAX_VALUE))) {
179
- for (const state of states) {
180
- if (line >= state.nextLine && line <= (state.lastLine ?? Number.MAX_VALUE)) {
181
- state.used = true;
182
- break;
183
- }
184
- }
182
+ }
183
+ else {
184
+ for (const state of states) {
185
+ if (line >= state.startLine && line <= (state.endLine ?? Number.MAX_VALUE)) {
186
+ state.used = true;
185
187
  return false;
186
188
  }
187
189
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsslint/config",
3
- "version": "1.5.3",
3
+ "version": "1.5.5",
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.5",
16
16
  "ts-api-utils": "^2.0.0"
17
17
  },
18
- "gitHead": "563035c62d04ff2a5c393f4a37ab9635960de1d6"
18
+ "gitHead": "aa1bd7ed5b26cab99048001d1efa8880260f0c6e"
19
19
  }