Skip to content

Commit cb080de

Browse files
committed
test(linter/no-unused-vars): add test for non ASCII chars in JSX components (#13820)
adds a test based on the above PR in the stack
1 parent 18ba2eb commit cb080de

File tree

1 file changed

+16
-0
lines changed
  • crates/oxc_linter/src/rules/eslint/no_unused_vars/tests

1 file changed

+16
-0
lines changed

crates/oxc_linter/src/rules/eslint/no_unused_vars/tests/oxc.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,6 +1361,22 @@ import Layout from '../layouts/Layout.astro';
13611361
.test();
13621362
}
13631363

1364+
#[test]
1365+
fn test_jsx_non_ascii() {
1366+
// Test that non-ASCII component names (e.g., Korean characters) are correctly recognized
1367+
// as references in JSX, ensuring they don't trigger false positives for unused variables.
1368+
// Non-ASCII identifiers are always treated as component references in JSX.
1369+
let pass = vec![
1370+
("const 테스트 = () => <div>Hello</div>; <테스트 />;"),
1371+
("const $foo = () => <div>Hello</div>; <$foo />;"),
1372+
("const _foo = () => <div>Hello</div>; <_foo />;"),
1373+
];
1374+
let fail = vec![("const foo = () => <div>Hello</div>; <foo />;")];
1375+
Tester::new(NoUnusedVars::NAME, NoUnusedVars::PLUGIN, pass, fail)
1376+
.intentionally_allow_no_fix_tests()
1377+
.test();
1378+
}
1379+
13641380
// #[test]
13651381
// fn test_template() {
13661382
// let pass = vec![];

0 commit comments

Comments
 (0)