mirror of
https://github.com/danbulant/oxc
synced 2026-05-25 12:51:57 +00:00
fix(linter): fix panic in no_unescaped_entities (#1103)
This commit is contained in:
parent
a455c81db6
commit
b4739e5540
2 changed files with 8 additions and 2 deletions
|
|
@ -50,8 +50,7 @@ impl Rule for NoUnescapedEntities {
|
|||
fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {
|
||||
if let AstKind::JSXText(jsx_text) = node.kind() {
|
||||
let source = jsx_text.span.source_text(ctx.source_text());
|
||||
|
||||
for (i, char) in source.chars().enumerate() {
|
||||
for (i, char) in source.char_indices() {
|
||||
if let Some(escapes) = DEFAULTS.get(&char) {
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
ctx.diagnostic(NoUnescapedEntitiesDiagnostic(
|
||||
|
|
@ -181,6 +180,7 @@ fn test() {
|
|||
// });
|
||||
// ",
|
||||
r#"<script>window.foo = "bar"</script>"#,
|
||||
r#"<script>测试 " 测试</script>"#,
|
||||
];
|
||||
|
||||
Tester::new_without_config(NoUnescapedEntities::NAME, pass, fail).test_and_snapshot();
|
||||
|
|
|
|||
|
|
@ -46,4 +46,10 @@ expression: no_unescaped_entities
|
|||
· ─
|
||||
╰────
|
||||
|
||||
⚠ eslint-plugin-react(no-unescaped-entities): `"` can be escaped with " or “ or " or ”
|
||||
╭─[no_unescaped_entities.tsx:1:1]
|
||||
1 │ <script>测试 " 测试</script>
|
||||
· ─
|
||||
╰────
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue