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

error 'App' is not defined no-undef #29

Closed
moroshko opened this issue Mar 4, 2015 · 10 comments
Closed

error 'App' is not defined no-undef #29

moroshko opened this issue Mar 4, 2015 · 10 comments

Comments

@moroshko
Copy link

moroshko commented Mar 4, 2015

Hi,

I get the following error:

var App = React.createClass({
  render: function() {
    return (
      <div>
        <h3>My Component Example</h3>
        <MyComponent />
      </div>
    );
  }
});

React.render(<App />, document.getElementById('app'));    // error  'App' is not defined  no-undef

Here is my .eslintrc file:

{
  "env": {
    "node": true,
    "browser": true
  },
  "parser": "babel-eslint",
  "rules": {
    "space-after-keywords": "always",
    "quotes": "single"
  }
}

I use babel-loader to run eslint with WebPack. Here is the relevant bit from webpack.config.js:

module: {
  loaders: [
    { test: /\.js$/, loaders: ["react-hot", "babel-loader", "eslint-loader"], exclude: /node_modules/ }
  ]
}

What am I doing wrong?

@sebmck
Copy link
Contributor

sebmck commented Mar 4, 2015

What am I doing wrong?

Nothing, it's a bug.

@gaearon
Copy link
Member

gaearon commented Mar 6, 2015

Seems to be a dupe of #8.

@gaearon
Copy link
Member

gaearon commented Mar 6, 2015

Nope. Actually it's a dupe of #15.

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
@MoOx
Copy link

MoOx commented Mar 19, 2015

Probably need to check this with eslint 0.17 changes for jsx and react.

@MoOx
Copy link

MoOx commented Mar 19, 2015

I am not having the issue anymore with eslint 0.17 and eslint-plugin-react 1.5.0

@sebmck
Copy link
Contributor

sebmck commented Apr 14, 2015

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

@hzoo
Copy link
Member

hzoo commented May 15, 2015

Is this still an issue after using eslint-plugin-react?

@MoOx
Copy link

MoOx commented May 15, 2015

Not at all. You can close this. Eslint doesn't handle this anymore & the plugin does this like a charm.

@hzoo
Copy link
Member

hzoo commented May 15, 2015

Ok great!

@CatzillaOrz
Copy link

From eslint docs we can find these rules,

Disallow Undeclared Variables (no-undef)
Any reference to an undeclared variable causes a warning, unless the variable is explicitly mentioned in a /global .../ comment.

/*global someFunction b:true*/
/*eslint no-undef: "error"*/

var a = someFunction();
b = 10;

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

No branches or pull requests

6 participants