Skip to content

Commit ffcc738

Browse files
committed
refactor: update error range
1 parent cc0a128 commit ffcc738

File tree

3 files changed

+22
-31
lines changed

3 files changed

+22
-31
lines changed

rules/prefer-string-raw.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ const create = context => {
9090
: `'${rawQuasi.slice(1, -1).replaceAll('\'', String.raw`\'`)}'`;
9191

9292
return {
93-
node,
93+
node: tag,
9494
messageId: MESSAGE_ID_UNNECESSARY_STRING_RAW,
9595
* fix(fixer) {
9696
const tokenBefore = sourceCode.getTokenBefore(node);

test/snapshots/prefer-string-raw.js.md

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ Generated by [AVA](https://avajs.dev).
148148
149149
`␊
150150
> 1 | a = String.raw\`abc\`␊
151-
| ^^^^^^^^^^^^^^^ Using \`String.raw\` is unnecessary as the string does not contain any \`\\\`.␊
151+
| ^^^^^^^^^^ Using \`String.raw\` is unnecessary as the string does not contain any \`\\\`.␊
152152
`
153153

154154
## invalid(2): a = String.raw`ab${foo}cd`
@@ -169,7 +169,7 @@ Generated by [AVA](https://avajs.dev).
169169
170170
`␊
171171
> 1 | a = String.raw\`ab${foo}cd\`␊
172-
| ^^^^^^^^^^^^^^^^^^^^^^ Using \`String.raw\` is unnecessary as the string does not contain any \`\\\`.␊
172+
| ^^^^^^^^^^ Using \`String.raw\` is unnecessary as the string does not contain any \`\\\`.␊
173173
`
174174

175175
## invalid(3): a = String.raw`ab"c`
@@ -190,7 +190,7 @@ Generated by [AVA](https://avajs.dev).
190190
191191
`␊
192192
> 1 | a = String.raw\`ab"c\`␊
193-
| ^^^^^^^^^^^^^^^^ Using \`String.raw\` is unnecessary as the string does not contain any \`\\\`.␊
193+
| ^^^^^^^^^^ Using \`String.raw\` is unnecessary as the string does not contain any \`\\\`.␊
194194
`
195195

196196
## invalid(4): a = String.raw`ab'c`
@@ -211,7 +211,7 @@ Generated by [AVA](https://avajs.dev).
211211
212212
`␊
213213
> 1 | a = String.raw\`ab'c\`␊
214-
| ^^^^^^^^^^^^^^^^ Using \`String.raw\` is unnecessary as the string does not contain any \`\\\`.␊
214+
| ^^^^^^^^^^ Using \`String.raw\` is unnecessary as the string does not contain any \`\\\`.␊
215215
`
216216

217217
## invalid(5): a = String.raw`ab'"c`
@@ -232,7 +232,7 @@ Generated by [AVA](https://avajs.dev).
232232
233233
`␊
234234
> 1 | a = String.raw\`ab'"c\`␊
235-
| ^^^^^^^^^^^^^^^^^ Using \`String.raw\` is unnecessary as the string does not contain any \`\\\`.␊
235+
| ^^^^^^^^^^ Using \`String.raw\` is unnecessary as the string does not contain any \`\\\`.␊
236236
`
237237

238238
## invalid(6): a = String.raw`ab c`
@@ -255,9 +255,8 @@ Generated by [AVA](https://avajs.dev).
255255
256256
`␊
257257
> 1 | a = String.raw\`ab␊
258-
| ^^^^^^^^^^^^^␊
259-
> 2 | c\`␊
260-
| ^^^ Using \`String.raw\` is unnecessary as the string does not contain any \`\\\`.␊
258+
| ^^^^^^^^^^ Using \`String.raw\` is unnecessary as the string does not contain any \`\\\`.␊
259+
2 | c\`␊
261260
`
262261

263262
## invalid(7): a = String.raw`a bc de`
@@ -282,11 +281,9 @@ Generated by [AVA](https://avajs.dev).
282281
283282
`␊
284283
> 1 | a = String.raw\`a␊
285-
| ^^^^^^^^^^^^␊
286-
> 2 | bc␊
287-
| ^^^␊
288-
> 3 | de\`␊
289-
| ^^^^^ Using \`String.raw\` is unnecessary as the string does not contain any \`\\\`.␊
284+
| ^^^^^^^^^^ Using \`String.raw\` is unnecessary as the string does not contain any \`\\\`.␊
285+
2 | bc␊
286+
3 | de\`␊
290287
`
291288

292289
## invalid(8): a = String.raw` a${foo}b ${bar}cd`
@@ -311,11 +308,9 @@ Generated by [AVA](https://avajs.dev).
311308
312309
`␊
313310
> 1 | a = String.raw\`␊
314-
| ^^^^^^^^^^^␊
315-
> 2 | a${foo}b␊
316-
| ^^^^^^^^␊
317-
> 3 | ${bar}cd\`␊
318-
| ^^^^^^^^^^ Using \`String.raw\` is unnecessary as the string does not contain any \`\\\`.␊
311+
| ^^^^^^^^^^ Using \`String.raw\` is unnecessary as the string does not contain any \`\\\`.␊
312+
2 | a${foo}b␊
313+
3 | ${bar}cd\`␊
319314
`
320315

321316
## invalid(9): a String.raw`abc`
@@ -339,7 +334,7 @@ Generated by [AVA](https://avajs.dev).
339334
`␊
340335
1 | a␊
341336
> 2 | String.raw\`abc\`␊
342-
| ^^^^^^^^^^^^^^^ Using \`String.raw\` is unnecessary as the string does not contain any \`\\\`.␊
337+
| ^^^^^^^^^^ Using \`String.raw\` is unnecessary as the string does not contain any \`\\\`.␊
343338
`
344339

345340
## invalid(10): a String.raw`a${b}`
@@ -363,7 +358,7 @@ Generated by [AVA](https://avajs.dev).
363358
`␊
364359
1 | a␊
365360
> 2 | String.raw\`a${b}\`␊
366-
| ^^^^^^^^^^^^^^^^^ Using \`String.raw\` is unnecessary as the string does not contain any \`\\\`.␊
361+
| ^^^^^^^^^^ Using \`String.raw\` is unnecessary as the string does not contain any \`\\\`.␊
367362
`
368363

369364
## invalid(11): a = String.raw // Comment `ab c`
@@ -390,13 +385,10 @@ Generated by [AVA](https://avajs.dev).
390385
391386
`␊
392387
> 1 | a = String.raw␊
393-
| ^^^^^^^^^^␊
394-
> 2 | // Comment␊
395-
| ^^^^^^^^^^␊
396-
> 3 | \`ab␊
397-
| ^^^^^^^^^^␊
398-
> 4 | c\`␊
399-
| ^^^ Using \`String.raw\` is unnecessary as the string does not contain any \`\\\`.␊
388+
| ^^^^^^^^^^ Using \`String.raw\` is unnecessary as the string does not contain any \`\\\`.␊
389+
2 | // Comment␊
390+
3 | \`ab␊
391+
4 | c\`␊
400392
`
401393

402394
## invalid(12): a = String.raw /* comment */ `ab c`
@@ -419,7 +411,6 @@ Generated by [AVA](https://avajs.dev).
419411
420412
`␊
421413
> 1 | a = String.raw /* comment */ \`ab␊
422-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^␊
423-
> 2 | c\`␊
424-
| ^^^ Using \`String.raw\` is unnecessary as the string does not contain any \`\\\`.␊
414+
| ^^^^^^^^^^ Using \`String.raw\` is unnecessary as the string does not contain any \`\\\`.␊
415+
2 | c\`␊
425416
`
-53 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)