Eslint-plugin-react: Cannot get react/prop-types or react/jsx-sort-prop-types to work at all (Definition for rule 'react/prop-types' was not found react/prop-types).

Created on 12 Apr 2017  路  7Comments  路  Source: yannickcr/eslint-plugin-react

I can't seem to get many of the rules working my config looks like this...

"react/prop-types": [2, {"skipUndeclared": false}]

Also tried...

"react/prop-types": 2

But I keep getting 'Definition for rule 'react/prop-types' was not found react/prop-types'

I have similar problems with this one...

"react/jsx-sort-prop-types": 0,

I can't see anything that looks wrong but, as I also can't get the 'jsx-uses-vars' rule to work either I'm not convinced that eslint-plugin-react is working at all.

Here's my whole package.json...

{
  "name": "esoterix-modle",
  "version": "1.0.0",
  "author": "Esoterix Systems Ltd",
  "private": true,
  "repository": {
    "type": "git",
    "url": "https://esoterix.visualstudio.com/_git/MODLE%20Operations"
  },
  "devDependencies": {
    "babel-core": "^6.17.0",
    "babel-eslint": "^7.0.0",
    "babel-loader": "^6.2.5",
    "babel-preset-airbnb": "^2.1.1",
    "babel-preset-es2015": "^6.16.0",
    "babel-preset-react": "^6.16.0",
    "babel-preset-stage-0": "^6.16.0",
    "babelify": "7.3.0",
    "bootstrap-sass": "3.3.7",
    "browserify": "^13.1.0",
    "browserify-shim": "^3.8.12",
    "chai": "^3.5.0",
    "enzyme": "^2.8.0",
    "eslint": "^3.19.0",
    "eslint-config-defaults": "^9.0.0",
    "eslint-plugin-react": "^6.10.3",
    "gulp": "^3.9.1",
    "gulp-babel": "^6.1.2",
    "gulp-clean": "^0.3.1",
    "gulp-clean-css": "^2.0.13",
    "gulp-eslint": "^3.0.1",
    "gulp-if": "^2.0.2",
    "gulp-jshint": "^2.0.1",
    "gulp-rename": "^1.2.2",
    "gulp-sass": "^2.3.2",
    "gulp-sourcemaps": "^2.0.1",
    "gulp-uglify": "^1.2.0",
    "gulp-util": "^3.0.7",
    "jsdom": "^9.6.0",
    "jshint": "^2.9.3",
    "karma": "^1.3.0",
    "karma-browserify": "^5.1.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-firefox-launcher": "^1.0.0",
    "karma-htmlfile-reporter": "^0.3.4",
    "karma-ie-launcher": "^1.0.0",
    "karma-junit-reporter": "^1.1.0",
    "karma-mocha": "^1.2.0",
    "karma-phantomjs-launcher": "^1.0.2",
    "mocha": "^3.1.2",
    "mocha-jsdom": "^1.1.0",
    "phantomjs-polyfill-find": "github:ptim/phantomjs-polyfill-find",
    "react-addons-test-utils": "15.4.2",
    "reactify": "^1.1.1",
    "sinon": "^1.17.6",
    "vinyl-buffer": "^1.0.0",
    "vinyl-source-stream": "^1.1.0",
    "watchify": "^3.7.0",
    "webpack": "^1.13.2"
  },
  "dependencies": {
    "bootbox": "^4.4.0",
    "domready": "^1.0.8",
    "escape-string-regexp": "^1.0.5",
    "font-awesome": "^4.3.0",
    "google-maps": "^3.2.1",
    "google-maps-react": "^1.0.19",
    "jquery": "^2.2.0",
    "jquery-validation": "^1.15.1",
    "jquery-validation-unobtrusive": "^3.2.6",
    "react": "15.4.2",
    "react-dom": "15.4.2"
  },
  "babel": {
    "presets": [
      "react",
      "es2015",
      "stage-0"
    ]
  },
  "browserify-shim": {
    "./node_modules/jquery/dist/jquery.js": "$",
    "react": "global:React",
    "react-dom": "global:ReactDOM"
  },
  "eslintConfig": {
    "extends": "eslint:recommended",
    "env": {
      "browser": true,
      "node": false,
      "jquery": true,
      "prototypejs": true,
      "mocha": true
    },
    "parserOptions": {
      "ecmaVersion": 6,
      "sourceType": "module",
      "ecmaFeatures": {
        "jsx": true
      }
    },
    "rules": {
      "strict": [
        2,
        "safe"
      ],
      "no-extra-parens": 2,
      "no-alert": 2,
      "no-else-return": 2,
      "no-invalid-this": 2,
      "no-unused-vars": 0,
      "no-var": 2,
      "prefer-const": 1,
      "semi": [
        2,
        "never"
      ],
      "block-scoped-var": 2,
      "dot-notation": 2,
      "no-extend-native": 1,
      "no-proto": 2,
      "vars-on-top": 1,
      "no-use-before-define": 2,
      "new-parens": 2,
      "react/require-extensions": 0,
      "react/jsx-sort-prop-types": 0,
      "react/prop-types": [2, {"skipUndeclared": false}]
    },
    "globals": {
      "require": false,
      "module": true,
      "addLoadEvent": false,
      "React": false,
      "ReactDOM": false,
      "$": false,
      "jQuery": false
    }
  }
}

documentation help wanted

Most helpful comment

giphy 1

We'd be happy to review a PR that improves documentation in a way that would have saved you some time!

All 7 comments

Sussed it - My Config was missing...

    "plugins": [
      "react"
    ],

This could do with being added to the docs as a setup step.

Sure, that'd help. However, that's a requirement to use any eslint plugin; it's in eslint's own docs.

That's where I found it eventually after half a day of pulling my hair out followed by a resounding face slapping exercise.

giphy 1

We'd be happy to review a PR that improves documentation in a way that would have saved you some time!

That would be great - when I've got a spare 5 minutes I'll throw something together!

Can this be assigned to me? (I have a memory like a sieve these days)

Fixed in e6326281303ec03b8d6f09d50899e1fca92fabd8

Quote:

Add "react" to the plugins section.

{
  "plugins": [
    "react"
  ]
}
Was this page helpful?
0 / 5 - 0 ratings