Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Definition for rule 'jsx-uses-vars' was not found. #21

Closed
jesstelford opened this issue Mar 16, 2015 · 4 comments
Closed

Error: Definition for rule 'jsx-uses-vars' was not found. #21

jesstelford opened this issue Mar 16, 2015 · 4 comments

Comments

@jesstelford
Copy link

I am getting the following error:

$ ./node_modules/.bin/eslint index.js
Error: Definition for rule 'jsx-uses-vars' was not found.
    at /dev/tmp/node_modules/eslint/lib/eslint.js:657:27
    at Array.forEach (native)
    at EventEmitter.module.exports.api.verify (/dev/tmp/node_modules/eslint/lib/eslint.js:630:16)
    at processFile (/dev/tmp/node_modules/eslint/lib/cli-engine.js:193:27)
    at /dev/tmp/node_modules/eslint/lib/cli-engine.js:293:26
    at walk (/dev/tmp/node_modules/eslint/lib/util/traverse.js:81:9)
    at /dev/tmp/node_modules/eslint/lib/util/traverse.js:102:9
    at Array.forEach (native)
    at traverse (/dev/tmp/node_modules/eslint/lib/util/traverse.js:101:11)
    at CLIEngine.executeOnFiles (/dev/tmp/node_modules/eslint/lib/cli-engine.js:284:9)

I have the following setup:

package.json:

{
  ...
  "devDependencies": {
    "eslint": "^0.17.0",
    "eslint-plugin-react": "^1.5.0"
  }
}

.eslintrc:

{
    "plugins": [
        "eslint-plugin-react"
    ],
    "ecmaFeatures": {
        "jsx": true
    },
    "env": {
        "es6": true
    },
    "rules": {
        "jsx-uses-vars": 1,
        "react-in-jsx-scope": 1
    }
}

index.js:

var React = require('react');

module.exports = React.createElement({
  render() {
    return <div>Foo</div>
  }
});

Any insights on what I'm doing wrong?

@jesstelford
Copy link
Author

Ah-hah! I have to prefix the rules with the plugin name:

{
    ...
    "rules": {
        "jsx-uses-vars": 1,
        "react-in-jsx-scope": 1
    }
}

should be:

{
    ...
    "rules": {
        "react/jsx-uses-vars": 1,
        "react/react-in-jsx-scope": 1
    }
}

@davis
Copy link

davis commented Jun 30, 2015

i'm still running into the error...
my eslintrc:

{
  // I want to use babel-eslint for parsing!
  "parser": "babel-eslint",
  "env": {
    // I write for browser
    "browser": true,
    // in CommonJS
    "node": true
  },
  {
    "ecmaFeatures": {
      "jsx": true
    }
  },
  {
    "plugins": [
      "react"
    ]
  },
  // To give you an idea how to override rule options:
  "rules": {
    "quotes": [2, "single"],
    "eol-last": [0],
    "no-mixed-requires": [0],
    "no-underscore-dangle": [0],
    "react/display-name": 1,
    "react/jsx-boolean-value": 1,
    "react/jsx-no-undef": 1,
    "react/jsx-quotes": 1,
    "react/jsx-sort-prop-types": 1,
    "react/jsx-sort-props": 1,
    "react/jsx-uses-react": 1,
    "react/jsx-uses-vars": 1,
    "react/no-did-mount-set-state": 1,
    "react/no-did-update-set-state": 1,
    "react/no-multi-comp": 1,
    "react/no-unknown-property": 1,
    "react/prop-types": 1,
    "react/react-in-jsx-scope": 1,
    "react/require-extension": 1,
    "react/self-closing-comp": 1,
    "react/sort-comp": 1,
    "react/wrap-multilines": 1
  }
}

@amio
Copy link

amio commented Feb 23, 2016

Strange thing is, the error/warning is reported by the rule it self.
image
here's my config:

{
  "env": {
    "es6": true,
    "browser": true
  },
  "extends": ["standard", "standard-react"],
  "plugins": [
    "react",
  ],
  "rules": {
    "react/jsx-no-undef": 1,
    "react/jsx-equals-spacing": [1, "always"],
    "react/prop-types": [1, {"ignore": ["children"]} ],
    "arrow-parens": [2, "as-needed"],
    "camelcase": 2
  }
}

@amio
Copy link

amio commented Feb 23, 2016

Ooops, my miss,
After update eslint-plugin-react from '3.15.0' to '4.0.0', problem solved :D
(I'm using eslint@2.2.0)

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

No branches or pull requests

3 participants