mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -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:
parent
3134abefa4
commit
6f0fbceaf2
10 changed files with 27 additions and 29 deletions
|
@ -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()),
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
]
|
||||
|
|
|
@ -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
|
||||
--> [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
|
||||
|
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…
Reference in a new issue