Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lint): correctly handle old jsx in linter #25902

Merged
merged 2 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
fix(lint): correctly handle old jsx in linter
  • Loading branch information
lucacasonato committed Sep 27, 2024
commit d6083d894ad3062192203e151145513134616ccf
6 changes: 2 additions & 4 deletions cli/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1327,11 +1327,9 @@ impl CliOptions {
)?;

Ok(deno_lint::linter::LintConfig {
default_jsx_factory: transpile_options
.jsx_automatic
default_jsx_factory: (!transpile_options.jsx_automatic)
.then(|| transpile_options.jsx_factory.clone()),
default_jsx_fragment_factory: transpile_options
.jsx_automatic
default_jsx_fragment_factory: (!transpile_options.jsx_automatic)
.then(|| transpile_options.jsx_fragment_factory.clone()),
})
}
Expand Down
14 changes: 7 additions & 7 deletions tests/specs/lint/jsx/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"steps": [
{
"if": "windows",
"args": "lint main.jsx",
"output": "main_windows.out",
"exitCode": 1
"args": "lint",
"cwd": "./react",
"output": "react.out",
"exitCode": 0
},
{
"if": "unix",
"args": "lint main.jsx",
"output": "main_unix.out",
"args": "lint",
"cwd": "./react-jsx",
"output": "react-jsx.out",
"exitCode": 1
}
]
Expand Down
1 change: 0 additions & 1 deletion tests/specs/lint/jsx/main.jsx

This file was deleted.

12 changes: 0 additions & 12 deletions tests/specs/lint/jsx/main_windows.out

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
error[no-unused-vars]: `data` is never used
--> [WILDCARD]lint/jsx/main.jsx:1:7
error[no-unused-vars]: `React` is never used
--> [WILDCARD]mod.tsx:1:7
|
1 | const data = <div>hello</div>;
| ^^^^
= hint: If this is intentional, prefix it with an underscore like `_data`
1 | const React = { createElement() {} };
| ^^^^^
= hint: If this is intentional, prefix it with an underscore like `_React`

docs: https://lint.deno.land/rules/no-unused-vars

Expand Down
5 changes: 5 additions & 0 deletions tests/specs/lint/jsx/react-jsx/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"jsx": "react-jsx"
}
}
3 changes: 3 additions & 0 deletions tests/specs/lint/jsx/react-jsx/mod.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const React = { createElement() {} };

const _div = <div />;
1 change: 1 addition & 0 deletions tests/specs/lint/jsx/react.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Checked 1 file
1 change: 1 addition & 0 deletions tests/specs/lint/jsx/react/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
3 changes: 3 additions & 0 deletions tests/specs/lint/jsx/react/mod.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const React = { createElement() {} };

const _div = <div />;
Loading