Skip to content

Latest commit

 

History

History
56 lines (40 loc) · 1.32 KB

jsx-jcs-no-undef.md

File metadata and controls

56 lines (40 loc) · 1.32 KB

Disallow Undeclared Variables, While Treating Each and Index in For and keys in With statements as declared (jsx-jcs-no-undef)

This rule is the same as the generic eslint no-undef rule (see http://eslint.org/docs/rules/no-undef) except with an exception built in for variables that are implicitly declared by <For> and <With> statements. Note that this includes no-undef's code and completely replaces it rather than supplementing it - if this rule is on, no-undef should be off. It is compatible with no-undef's options and /* global */ declarations.

Rule Details

The following patterns are considered warnings:

var a = someFunction();
b = 10;
<For of={anArray}>
  {element}{index}
</For>
<With foo={47}>
  {bar}
</With>

The following patterns are not warnings:

<For of={anArray} each="element" index="index">
  {element}{index}
</For>
<With foo={47}>
  {foo}
</With>

Options

  • typeof set to true will warn for variables used inside typeof check (Default false).

When Not To Use It

You'll only need this if you're using or statements.

Compatibility

This rule is completely compatible with ESLint no-undef, except in the case of <For> and <With> statements.

Further Reading