mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00: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:
parent
3134abefa4
commit
6f0fbceaf2
10 changed files with 27 additions and 29 deletions
|
@ -1327,11 +1327,9 @@ impl CliOptions {
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok(deno_lint::linter::LintConfig {
|
Ok(deno_lint::linter::LintConfig {
|
||||||
default_jsx_factory: transpile_options
|
default_jsx_factory: (!transpile_options.jsx_automatic)
|
||||||
.jsx_automatic
|
|
||||||
.then(|| transpile_options.jsx_factory.clone()),
|
.then(|| transpile_options.jsx_factory.clone()),
|
||||||
default_jsx_fragment_factory: transpile_options
|
default_jsx_fragment_factory: (!transpile_options.jsx_automatic)
|
||||||
.jsx_automatic
|
|
||||||
.then(|| transpile_options.jsx_fragment_factory.clone()),
|
.then(|| transpile_options.jsx_fragment_factory.clone()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
{
|
{
|
||||||
"steps": [
|
"steps": [
|
||||||
{
|
{
|
||||||
"if": "windows",
|
"args": "lint",
|
||||||
"args": "lint main.jsx",
|
"cwd": "./react",
|
||||||
"output": "main_windows.out",
|
"output": "react.out",
|
||||||
"exitCode": 1
|
"exitCode": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"if": "unix",
|
"args": "lint",
|
||||||
"args": "lint main.jsx",
|
"cwd": "./react-jsx",
|
||||||
"output": "main_unix.out",
|
"output": "react-jsx.out",
|
||||||
"exitCode": 1
|
"exitCode": 1
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
const data = <div>hello</div>;
|
|
|
@ -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
|
|
|
@ -1,9 +1,9 @@
|
||||||
error[no-unused-vars]: `data` is never used
|
error[no-unused-vars]: `React` is never used
|
||||||
--> [WILDCARD]lint/jsx/main.jsx:1:7
|
--> [WILDCARD]mod.tsx:1:7
|
||||||
|
|
|
|
||||||
1 | const data = <div>hello</div>;
|
1 | const React = { createElement() {} };
|
||||||
| ^^^^
|
| ^^^^^
|
||||||
= hint: If this is intentional, prefix it with an underscore like `_data`
|
= hint: If this is intentional, prefix it with an underscore like `_React`
|
||||||
|
|
||||||
docs: https://lint.deno.land/rules/no-unused-vars
|
docs: https://lint.deno.land/rules/no-unused-vars
|
||||||
|
|
5
tests/specs/lint/jsx/react-jsx/deno.json
Normal file
5
tests/specs/lint/jsx/react-jsx/deno.json
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"jsx": "react-jsx"
|
||||||
|
}
|
||||||
|
}
|
3
tests/specs/lint/jsx/react-jsx/mod.tsx
Normal file
3
tests/specs/lint/jsx/react-jsx/mod.tsx
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
const React = { createElement() {} };
|
||||||
|
|
||||||
|
const _div = <div />;
|
1
tests/specs/lint/jsx/react.out
Normal file
1
tests/specs/lint/jsx/react.out
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Checked 1 file
|
1
tests/specs/lint/jsx/react/deno.json
Normal file
1
tests/specs/lint/jsx/react/deno.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{}
|
3
tests/specs/lint/jsx/react/mod.tsx
Normal file
3
tests/specs/lint/jsx/react/mod.tsx
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
const React = { createElement() {} };
|
||||||
|
|
||||||
|
const _div = <div />;
|
Loading…
Add table
Add a link
Reference in a new issue