1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

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

Previously the CLI was incorrectly reporting `React` as unused in a JSX
file that uses the "old" transform.

The LSP was already handling this correctly.
This commit is contained in:
Luca Casonato 2024-09-27 16:14:17 +02:00 committed by GitHub
parent 3134abefa4
commit 6f0fbceaf2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 27 additions and 29 deletions

View file

@ -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()),
})
}

View file

@ -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
}
]

View file

@ -1 +0,0 @@
const data = <div>hello</div>;

View file

@ -1,12 +0,0 @@
error[no-unused-vars]: `data` is never used
--> [WILDCARD]lint\jsx\main.jsx:1:7
|
1 | const data = <div>hello</div>;
| ^^^^
= hint: If this is intentional, prefix it with an underscore like `_data`
docs: https://lint.deno.land/rules/no-unused-vars
Found 1 problem
Checked 1 file

View file

@ -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

View file

@ -0,0 +1,5 @@
{
"compilerOptions": {
"jsx": "react-jsx"
}
}

View file

@ -0,0 +1,3 @@
const React = { createElement() {} };
const _div = <div />;

View file

@ -0,0 +1 @@
Checked 1 file

View file

@ -0,0 +1 @@
{}

View file

@ -0,0 +1,3 @@
const React = { createElement() {} };
const _div = <div />;