eslint-plugin-react: no-undef mark JSX elements as not defined
With
var React =require('react'),
Router = require('react-router'),
Route = Router.Route,
DefaultRoute = Router.DefaultRoute;
at the top and using eslint@0.17.0 and eslint-plugin-react@1.5.0 with
"react/jsx-uses-react": 1, "react/jsx-uses-vars": 1
This works fine.
var routes = React.createClass({
render: function() {
return (
<Route
name='app'
path='/'
handler={ App }>
<Route
name='bonfires'
path='/bonfires/?:bonfires?'
handler={ Bonfires } />
<DefaultRoute
handler={ Bonfires } />
</Route>
);
}
});
But this barphs all over the place
var routes = (
<Route
name='app'
path='/'
handler={ App }>
<Route
name='bonfires'
path='/bonfires/?:bonfires?'
handler={ Bonfires } />
<DefaultRoute
handler={ Bonfires } />
</Route>
);

About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 18 (8 by maintainers)
Commits related to this issue
- hack for globalReturn bug in eslint see: https://github.com/yannickcr/eslint-plugin-react/issues/19 — committed to freeCodeCamp/freeCodeCamp by deleted user 9 years ago
adding these rules fixed it for me:
Official answer is here https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/FAQ.md#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors and it says indeed to add them to globals or to disable the no-undef rule because typescript has already its own checks
Using the
nodeenvironment setglobalReturntotruehttps://github.com/eslint/eslint/blob/master/conf/environments.js#L17-L19 so your issue seems related.You can force
globalReturntofalseby adding:But this is just a workaround for now. Hope this issue will be resolved soon.