Eslint-plugin-react: Error: Definition for rule 'jsx-uses-vars' was not found.

Created on 16 Mar 2015  路  4Comments  路  Source: yannickcr/eslint-plugin-react

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?

Most helpful comment

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
    }
}

All 4 comments

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
    }
}

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
  }
}

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
  }
}

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

Was this page helpful?
0 / 5 - 0 ratings