Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Variable is not defined when used in JSX as a parameter #15

Closed
kompot opened this issue Feb 28, 2015 · 4 comments
Closed

Variable is not defined when used in JSX as a parameter #15

kompot opened this issue Feb 28, 2015 · 4 comments

Comments

@kompot
Copy link

kompot commented Feb 28, 2015

Given

import React from 'react/lib/ReactWithAddons';
import App from './App';

React.initializeTouchEvents(true);
React.render(<App />, document.body);

leads to

5:14  error  'App' is not defined  no-undef
@kompot kompot changed the title Variable as not defined when used as JSX as a parameter Variable is not defined when used in JSX as a parameter Mar 4, 2015
BenoitZugmeyer added a commit to BenoitZugmeyer/babel-eslint that referenced this issue Mar 7, 2015
When specifying "module" to escope sourceType option, defined variables
will be stored in "module" scope instead of the "global" scope. Because
eslint doesn't support module scopes yet, it will ignore this scope when
the rule "no-undef" gets the current scope to check for JSX variables
definitions.

Fixes babel#15 and babel#29
BenoitZugmeyer added a commit to BenoitZugmeyer/babel-eslint that referenced this issue Mar 7, 2015
eslint does not support an escope "module" scope but we need it to
support modules syntax.

Simply pushing all variables from the "module" scope in the "global"
scope should fix many issues: babel#8, babel#15, babel#17, babel#21, babel#29
@sebmck
Copy link
Contributor

sebmck commented Apr 14, 2015

Can you please verify that this issue still exists on 3.0.1?

@kompot
Copy link
Author

kompot commented Apr 14, 2015

Now it's
2:7 error App is defined but never used no-unused-vars
with babel-eslint 3.0.1 and eslint 0.19.0.

@sebmck
Copy link
Contributor

sebmck commented Apr 14, 2015

Not sure I can do anything about this. I'd recommend using the eslint-plugin-react rules.

@sebmck sebmck closed this as completed Apr 14, 2015
@kompot
Copy link
Author

kompot commented Apr 14, 2015

Thanks, worked like a charm!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants