Skip to content

Latest commit

History

History
63 lines (44 loc) 路 1.23 KB

File metadata and controls

63 lines (44 loc) 路 1.23 KB

react/jsx-no-undef

馃摑 Disallow undeclared variables in JSX.

馃捈 This rule is enabled in the 鈽戯笍 recommended config.

This rule helps locate potential ReferenceErrors resulting from misspellings or missing components.

Rule Details

Examples of incorrect code for this rule:

<Hello name="John" />;
// will ignore Text in the global scope and warn
var Hello = React.createClass({
  render: function() {
    return <Text>Hello</Text>;
  }
});
module.exports = Hello;

Examples of correct code for this rule:

var Hello = require('./Hello');

<Hello name="John" />;

Rule Options

...
"react/jsx-no-undef": [<enabled>, { "allowGlobals": <boolean> }]
...

allowGlobals

When true the rule will consider the global scope when checking for defined Components.

Examples of correct code for this rule, when "allowGlobals" is true:

var Text = require('./Text');
var Hello = React.createClass({
  render: function() {
    return <Text>Hello</Text>;
  }
});
module.exports = Hello;

When Not To Use It

If you are not using JSX then you can disable this rule.