If is not defined
Alvazz opened this issue · 4 comments
.babelrc like this:
{
"plugins": [
"jsx-control-statements",
[
"import",
{
"libraryName": "antd",
"style": true
}
]
]
}
I tried this but still I am getting error.
Error: Can't resolve 'jsx-control-statements' in
my babel.config.js file is below
module.exports = api => {
const presets = ['@babel/env', '@babel/react'];
const plugins = [
'@babel/proposal-class-properties',
'@babel/proposal-optional-chaining',
'@babel/proposal-export-default-from',
"jsx-control-statements",
[
"import",
{
libraryName: "antd",
style: true
}
]
];
return { presets, plugins };
};
and my package.json is below
"devDependencies": {
"@babel/core": "7.3.4",
"@babel/plugin-proposal-class-properties": "7.5.0",
"@babel/plugin-proposal-export-default-from": "7.5.2",
"@babel/plugin-proposal-optional-chaining": "7.2.0",
"@babel/preset-env": "7.5.2",
"@testing-library/jest-dom": "4.0.0",
"@testing-library/react": "8.0.5",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "10.0.2",
"babel-jest": "24.8.0",
"babel-loader": "8.0.6",
"babel-plugin-react-remove-properties": "0.3.0",
"babel-plugin-styled-components": "1.10.6",
"babel-plugin-transform-react-remove-prop-types": "0.4.24",
"@babel/preset-react": "^7.7.4",
"babel-plugin-jsx-control-statements": "^4.0.0",
"babel-preset-react-app": "7.0.2"
}
I created a react project with create-react-app and then did an eject and edited the package.json
in package.json I have
"eslintConfig": {
"plugins": [
"jsx-control-statements"
],
"extends": [
"plugin:jsx-control-statements/recommended",
"react-app"
],
"rules": {
"react/jsx-no-undef": [2, { "allowGlobals": true }]
}
}
eslint is as expected complaining if y use ternary operators instead of
and
"babel": {
"presets": [
"@babel/preset-env",
"react-app"
],
"plugins": [
"jsx-control-statements"
]
}
but I'm still getting 'If' is not defined react/jsx-no-undef
... what am I missing?
full code on my repo
OMG, did like said in #86 I deleted node_modules and redid a yarn install
and now it works