Skip to content

Commit

Permalink
prefer-string-raw: Ignore ImportAttribute (#2551)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker authored Feb 6, 2025
1 parent 4a677c6 commit d963ccd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions rules/prefer-string-raw.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const create = context => {
|| (node.parent.type === 'Property' && !node.parent.computed && node.parent.key === node)
|| (node.parent.type === 'JSXAttribute' && node.parent.value === node)
|| (node.parent.type === 'TSEnumMember' && (node.parent.initializer === node || node.parent.id === node))
|| (node.parent.type === 'ImportAttribute' && (node.parent.key === node || node.parent.value === node))
) {
return;
}
Expand Down
4 changes: 4 additions & 0 deletions test/prefer-string-raw.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ test.snapshot({
},
},
},
String.raw`import {} from "foo" with {key: "value\\value"}`,
String.raw`import {} from "foo" with {"key\\key": "value"}`,
String.raw`export {} from "foo" with {key: "value\\value"}`,
String.raw`export {} from "foo" with {"key\\key": "value"}`,
],
invalid: [
String.raw`a = 'a\\b'`,
Expand Down

0 comments on commit d963ccd

Please sign in to comment.