-
-
Notifications
You must be signed in to change notification settings - Fork 503
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
🐛 noUnusedImports supports custom jsxFactory #3682
Comments
Is it possible to add a separate configuration? For a very large monorepo, there may not be a tsconfig in the root directory
|
PRs are welcome if anyone wants to help |
I'm new to biome.js but I'm very glad to help if you can bear with me taking a bit longer to fix this ❤️ |
@ematipico Hi! I was wondering if we can support: {
"javascript": {
"jsxRuntime": "reactClassic",
"jsxFactory": "$",
"jsxFragmentFactory": "$"
}
} Note: If we were to support struct type of Do you have any bias on this one? |
Considering that different subprojects in monorepo may have different configurations, it would be nice to read the configurations from the tsconfig files of the subprojects, but there is extends field in tsconfig, and it is not clear if biome supports it. |
@ahaoboy if a project doesn't use TypeScript, how does someone provide those values? |
Yes, this is why I want to add a configuration. Can we use the default configuration for projects without tsconfig?
|
@ematipico Hi! I encountered some problem. BackgroundI dug into the codebase. I found out the original implementation is a little bit simple: The following module does not complain any error even though the identifier binding import React from "react" The other issue I encountered is if function App() {
return <><div>abc</div></>
}
export default <App /> Biome does not complain anything (note that
And at the same time, TypeScript compiler does complain as follows:
So I believe there does have something to improve and I want to focus on this issue first. Possible solutionI would like to improve the binding. // 1
const h = () => {}
const Element = <div></div>
// 2
import { h } from "preact"
const Element = <div></div> Also, jsx runtime should be scope aware, with the same configuration above, the following example should complain: function App() {
const h = () => {}
return <div /> // 1
}
export default <App /> // 2 👈 Cannot find binding `h` Note 1 should not complain as QuestionI took a look at the I don't know if I'm heading towards the right direction. Would you please help me with a little guidance? |
I believe it's intended, because in "classic" react, the old way, the global import React from "react"
export function App() {
return <p>hello</p>
} However, a more modern version of the babel JSX transformer doesn't require it anymore. In lue to that, we decided to ignore the import in case we have a classic (old) transformer.
Please do. Consider that, at the moment, we can't read the Regarding your question, I believe the semantic model already does that 🤔 |
@ematipico AFAIK, they only do bindings for cases like: const App = () => {}
<App /> // App usage But instead, I'd like to add references to |
Environment information
What happened?
https://github.com/ahaoboy/biome-react-jsxFactory
When using a custom renderer, after turning on noUnusedImports, the jsxFactory field configured in tsconfig is not correctly recognized
For example, in the following code, only variable b should not be used.
However, biome will mark both $ and b as unused.
Expected result
biome can handle custom jsxFactory correctly
For the above code, only variable b should not be used.
Code of Conduct
The text was updated successfully, but these errors were encountered: