Skip to content

Latest commit

 

History

History
55 lines (35 loc) · 1.5 KB

inferno-in-jsx-scope.md

File metadata and controls

55 lines (35 loc) · 1.5 KB

Disallow missing Inferno when using JSX (inferno/inferno-in-jsx-scope)

🚫 This rule is disabled in the 🏃 jsx-runtime config.

💼 This rule is enabled in the following configs: all. This rule is disabled in the following configs: jsx-runtime.

Note: This rule is not part of recommended set, because babel-plugin-inferno can handle inferno import declaration automatically. Import inferno only if your code needs it.

When using JSX, <a /> expands to Inferno.createElement("a"). Therefore, the Inferno variable must be in scope.

If you are using the @jsx pragma this rule will check the designated variable and not the Inferno one.

Rule Details

Examples of incorrect code for this rule:

var Hello = <div>Hello {this.props.name}</div>;
/** @jsx Foo.bar */
var Inferno = require('inferno');

var Hello = <div>Hello {this.props.name}</div>;

Examples of correct code for this rule:

import Inferno from 'inferno';

var Hello = <div>Hello {this.props.name}</div>;
var Inferno = require('inferno');

var Hello = <div>Hello {this.props.name}</div>;
/** @jsx Foo.bar */
var Foo = require('foo');

var Hello = <div>Hello {this.props.name}</div>;

When Not To Use It

If you are setting Inferno as a global variable you can disable this rule.