detect uses of jsxFactory and jsxFragmentFactory in js/unused-local-variable

This commit is contained in:
Erik Krogh Kristensen
2020-10-06 12:23:15 +02:00
parent 8d09885ae6
commit 99213b94f5
3 changed files with 21 additions and 0 deletions

View File

@@ -58,6 +58,16 @@ predicate isReactForJSX(UnusedLocal v) {
plugin.getJsxFactoryVariableName() = v.getName()
)
)
or
exists(JSONObject tsconfig |
tsconfig.isTopLevel() and tsconfig.getFile().getBaseName() = "tsconfig.json"
|
v.getName() =
tsconfig
.getPropValue("compilerOptions")
.(JSONObject)
.getPropStringValue(["jsxFactory", "jsxFragmentFactory"])
)
)
}

View File

@@ -0,0 +1,6 @@
{
"compilerOptions": {
"jsx": "react",
"jsxFactory": "m"
}
}

View File

@@ -0,0 +1,5 @@
import {m} from 'some-react-library';
export default function doAThing() {
return <span>foo</span>;
}