Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions crates/oxc_codegen/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2578,8 +2578,9 @@ impl Gen for JSXText<'_> {

impl Gen for JSXSpreadChild<'_> {
fn r#gen(&self, p: &mut Codegen, _ctx: Context) {
p.print_str("...");
p.print_str("{...");
p.print_expression(&self.expression);
p.print_ascii_byte(b'}');
}
}

Expand All @@ -2588,7 +2589,7 @@ impl Gen for JSXChild<'_> {
match self {
Self::Fragment(fragment) => fragment.print(p, ctx),
Self::Element(el) => el.print(p, ctx),
Self::Spread(spread) => p.print_expression(&spread.expression),
Self::Spread(spread) => spread.print(p, ctx),
Self::ExpressionContainer(expr_container) => expr_container.print(p, ctx),
Self::Text(text) => text.print(p, ctx),
}
Expand Down
24 changes: 12 additions & 12 deletions crates/oxc_linter/src/rules/eslint/no_unused_expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ fn test() {
"
namespace Foo {
'use strict';

export class Foo {}
export class Bar {}
}
Expand All @@ -303,7 +303,7 @@ fn test() {
"
function foo() {
'use strict';

return null;
}
",
Expand Down Expand Up @@ -383,7 +383,7 @@ fn test() {
("<></>", Some(serde_json::json!([{ "enforceForJSX": true }]))), // { "parserOptions": { "ecmaFeatures": { "jsx": true } } },
("class C { static { 'use strict'; } }", None), // { "ecmaVersion": 2022 },
(
"class C { static {
"class C { static {
'foo'
'bar'
} }",
Expand Down Expand Up @@ -479,7 +479,7 @@ fn test() {
namespace Foo {
export class Foo {}
export class Bar {}

'use strict';
}
",
Expand All @@ -489,7 +489,7 @@ fn test() {
"
function foo() {
const foo = true;

'use strict';
}
",
Expand Down Expand Up @@ -519,13 +519,13 @@ fn test() {
",
None,
),
(
"
declare const foo: number | undefined;
<any>foo;
",
None,
),
// (
// "
// declare const foo: number | undefined;
// <any>foo;
// ",
// None,
// ),
(
"
declare const foo: number | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,11 @@ impl Rule for NoUnescapedEntities {
}

// NOTE: If we add substantially more characters, we should consider using a hash set instead.
pub const CHARS: [char; 4] = ['>', '"', '\'', '}'];
pub const CHARS: [char; 2] = ['"', '\''];

pub const DEFAULTS: Map<char, &'static [&'static str]> = phf_map! {
'>' => &["&gt;"],
'"' => &["&quot;", "&ldquo;", "&#34;", "&rdquo;"],
'\'' => &["&apos;", "&lsquo;", "&#39;", "&rsquo;"],
'}' => &["&#125;"],
};

#[test]
Expand Down
15 changes: 9 additions & 6 deletions crates/oxc_linter/src/rules/typescript/array_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1011,10 +1011,10 @@ fn test() {
"let x: Array<undefined> = [undefined] as undefined[];",
Some(serde_json::json!([{"default":"array-simple"}])),
),
(
"let y: string[] = <Array<string>>['2'];",
Some(serde_json::json!([{"default":"array-simple"}])),
),
// (
// "let y: string[] = <Array<string>>['2'];",
// Some(serde_json::json!([{"default":"array-simple"}])),
// ),
("let z: Array = [3, '4'];", Some(serde_json::json!([{"default":"array-simple"}]))),
(
"let ya = [[1, '2']] as [number, string][];",
Expand Down Expand Up @@ -1062,7 +1062,7 @@ fn test() {
"let x: Array<undefined> = [undefined] as undefined[];",
Some(serde_json::json!([{"default":"array"}])),
),
("let y: string[] = <Array<string>>['2'];", Some(serde_json::json!([{"default":"array"}]))),
// ("let y: string[] = <Array<string>>['2'];", Some(serde_json::json!([{"default":"array"}]))),
("let z: Array = [3, '4'];", Some(serde_json::json!([{"default":"array"}]))),
("type Arr<T> = Array<T>;", Some(serde_json::json!([{"default":"array"}]))),
// ("
Expand Down Expand Up @@ -1706,5 +1706,8 @@ fn test() {
),
];

Tester::new(ArrayType::NAME, ArrayType::PLUGIN, pass, fail).expect_fix(fix).test_and_snapshot();
Tester::new(ArrayType::NAME, ArrayType::PLUGIN, pass, fail)
.change_rule_path_extension("ts")
.expect_fix(fix)
.test_and_snapshot();
}
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ source: crates/oxc_linter/src/tester.rs

⚠ eslint(no-unused-expressions): Disallow unused expressions
╭─[no_unused_expressions.tsx:2:4]
1 │ class C { static {
1 │ class C { static {
2 │ 'foo'
· ─────
3 │ 'bar'
Expand Down Expand Up @@ -378,7 +378,7 @@ source: crates/oxc_linter/src/tester.rs

⚠ eslint(no-unused-expressions): Disallow unused expressions
╭─[no_unused_expressions.tsx:6:6]
5 │
5 │
6 │ 'use strict';
· ─────────────
7 │ }
Expand All @@ -387,7 +387,7 @@ source: crates/oxc_linter/src/tester.rs

⚠ eslint(no-unused-expressions): Disallow unused expressions
╭─[no_unused_expressions.tsx:5:6]
4 │
4 │
5 │ 'use strict';
· ─────────────
6 │ }
Expand Down Expand Up @@ -442,12 +442,6 @@ source: crates/oxc_linter/src/tester.rs
╰────
help: Consider removing this expression

× Expected `<` but found `EOF`
╭─[no_unused_expressions.tsx:4:10]
3 │ <any>foo;
4 │
╰────

⚠ eslint(no-unused-expressions): Disallow unused expressions
╭─[no_unused_expressions.tsx:3:4]
2 │ declare const foo: number | undefined;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
---
source: crates/oxc_linter/src/tester.rs
---
⚠ eslint-plugin-react(no-unescaped-entities): `>` can be escaped with &gt;
× Unexpected token. Did you mean `{'>'}` or `&gt;`?
╭─[no_unescaped_entities.tsx:3:24]
2 │ render: function() {
3 │ return <>> babel-eslint</>;
·
·
4 │ }
╰────

⚠ eslint-plugin-react(no-unescaped-entities): `>` can be escaped with &gt;
× Unexpected token. Did you mean `{'>'}` or `&gt;`?
╭─[no_unescaped_entities.tsx:5:47]
4 │ so is second
5 │ and here are some bad entities: ></>
·
·
6 │ }
╰────

Expand All @@ -25,11 +25,11 @@ source: crates/oxc_linter/src/tester.rs
5 │ }
╰────

⚠ eslint-plugin-react(no-unescaped-entities): `}` can be escaped with &#125;
× Unexpected token. Did you mean `{'}'}` or `&rbrace;`?
╭─[no_unescaped_entities.tsx:4:60]
3 │ render: function() {
4 │ return <>{"Unbalanced braces - babel-eslint"}}</>;
·
·
5 │ }
╰────

Expand Down
Loading
Loading