jsx-eslint / eslint-plugin-react

React-specific linting rules for ESLint
MIT License
9k stars 2.77k forks source link

Warning: React version not specified in eslint-plugin-react settings. #2170

Closed janryWang closed 5 years ago

janryWang commented 5 years ago

This is my config file.Is there any problem?

{
  "parser": "babel-eslint",
  "extends": ["standard", "standard-react"],
  "env": {
    "es6": true
  },
  "settings": {
    "react": {
      "version": "16.8.2"
    }
  },
  "plugins": ["react", "react-hooks"],
  "parserOptions": {
    "ecmaVersion": 6,
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true
    }
  },
  "rules": {
    // don't force es6 functions to include space before paren
    "space-before-function-paren": 0,
    "react/prop-types": 0,
    // allow specifying true explicitly for boolean props
    "react/jsx-boolean-value": 0,
    "react-hooks/rules-of-hooks": "error",
    "react/no-did-update-set-state": 0
  }
}

 "eslint": "^5.14.1",
 "eslint-config-standard": "^12.0.0",
 "eslint-config-standard-react": "^7.0.2",
  "eslint-plugin-import": "^2.13.0",
  "eslint-plugin-node": "^7.0.1",
  "eslint-plugin-promise": "^4.0.0",
  "eslint-plugin-react": "^7.12.4",
  "eslint-plugin-react-hooks": "^1.0.2",
  "eslint-plugin-standard": "^4.0.0",
ljharb commented 5 years ago

Nope, looks fine. Why do you think there's a problem?

janryWang commented 5 years ago

No matter how I configure it, it will print this error. @ljharb

ljharb commented 5 years ago

What error?

janryWang commented 5 years ago

Warning: React version not specified in eslint-plugin-react settings.

ljharb commented 5 years ago

What does eslint --print-config show?

ljharb commented 5 years ago

Did you figure it out?

janryWang commented 5 years ago

I don't know where I changed, it just work.thanks 😅

mk0y commented 5 years ago

After adding

settings:
  react:
    pragma: React
    version: 16.8.6

to .eslintrc.yaml there's no error anymore. But this means we have to update this every time React version changes.

ljharb commented 5 years ago

@markzero set it to “detect”

mk0y commented 5 years ago

Great thanks @ljharb it works with detect.

ntucker commented 5 years ago
npx eslint --print-config .
{
  "globals": {
    "afterAll": false,
    "afterEach": false,
    "beforeAll": false,
    "beforeEach": false,
    "describe": false,
    "expect": false,
    "fdescribe": false,
    "fit": false,
    "it": false,
    "jest": false,
    "pit": false,
    "require": false,
    "test": false,
    "xdescribe": false,
    "xit": false,
    "xtest": false
  },
  "env": {
    "jest": true
  },
  "rules": {
    "@typescript-eslint/adjacent-overload-signatures": "error",
    "@typescript-eslint/array-type": "error",
    "@typescript-eslint/ban-types": "error",
    "camelcase": "off",
    "@typescript-eslint/camelcase": "error",
    "@typescript-eslint/class-name-casing": "error",
    "@typescript-eslint/explicit-function-return-type": "off",
    "@typescript-eslint/explicit-member-accessibility": "off",
    "indent": "off",
    "@typescript-eslint/indent": "off",
    "@typescript-eslint/interface-name-prefix": "error",
    "@typescript-eslint/member-delimiter-style": "off",
    "@typescript-eslint/no-angle-bracket-type-assertion": "error",
    "no-array-constructor": "off",
    "@typescript-eslint/no-array-constructor": "error",
    "@typescript-eslint/no-empty-interface": "error",
    "@typescript-eslint/no-explicit-any": "off",
    "@typescript-eslint/no-inferrable-types": "error",
    "@typescript-eslint/no-misused-new": "error",
    "@typescript-eslint/no-namespace": "error",
    "@typescript-eslint/no-non-null-assertion": "error",
    "@typescript-eslint/no-object-literal-type-assertion": "error",
    "@typescript-eslint/no-parameter-properties": "error",
    "@typescript-eslint/no-triple-slash-reference": "error",
    "no-unused-vars": "off",
    "@typescript-eslint/no-unused-vars": "warn",
    "no-use-before-define": "off",
    "@typescript-eslint/no-use-before-define": "warn",
    "@typescript-eslint/no-var-requires": "error",
    "@typescript-eslint/prefer-interface": "error",
    "@typescript-eslint/prefer-namespace-keyword": "error",
    "@typescript-eslint/type-annotation-spacing": "off",
    "react/display-name": 2,
    "react/jsx-key": 2,
    "react/jsx-no-comment-textnodes": 2,
    "react/jsx-no-duplicate-props": 2,
    "react/jsx-no-target-blank": 2,
    "react/jsx-no-undef": 2,
    "react/jsx-uses-react": 2,
    "react/jsx-uses-vars": 2,
    "react/no-children-prop": 2,
    "react/no-danger-with-children": 2,
    "react/no-deprecated": 2,
    "react/no-direct-mutation-state": 2,
    "react/no-find-dom-node": 2,
    "react/no-is-mounted": 2,
    "react/no-render-return-value": 2,
    "react/no-string-refs": 2,
    "react/no-unescaped-entities": 2,
    "react/no-unknown-property": 2,
    "react/no-unsafe": 0,
    "react/prop-types": 2,
    "react/react-in-jsx-scope": 2,
    "react/require-render-return": 2,
    "arrow-body-style": 0,
    "curly": 0,
    "lines-around-comment": 0,
    "max-len": 0,
    "no-confusing-arrow": 0,
    "no-mixed-operators": 0,
    "no-tabs": 0,
    "no-unexpected-multiline": 0,
    "prefer-arrow-callback": 0,
    "quotes": 0,
    "array-bracket-newline": "off",
    "array-bracket-spacing": "off",
    "array-element-newline": "off",
    "arrow-parens": "off",
    "arrow-spacing": "off",
    "block-spacing": "off",
    "brace-style": "off",
    "comma-dangle": "off",
    "comma-spacing": "off",
    "comma-style": "off",
    "computed-property-spacing": "off",
    "dot-location": "off",
    "eol-last": "off",
    "func-call-spacing": "off",
    "function-paren-newline": "off",
    "generator-star": "off",
    "generator-star-spacing": "off",
    "implicit-arrow-linebreak": "off",
    "indent-legacy": "off",
    "jsx-quotes": "off",
    "key-spacing": "off",
    "keyword-spacing": "off",
    "linebreak-style": "off",
    "multiline-ternary": "off",
    "newline-per-chained-call": "off",
    "new-parens": "off",
    "no-arrow-condition": "off",
    "no-comma-dangle": "off",
    "no-extra-parens": "off",
    "no-extra-semi": "off",
    "no-floating-decimal": "off",
    "no-mixed-spaces-and-tabs": "off",
    "no-multi-spaces": "off",
    "no-multiple-empty-lines": "off",
    "no-reserved-keys": "off",
    "no-space-before-semi": "off",
    "no-spaced-func": "off",
    "no-trailing-spaces": "off",
    "no-whitespace-before-property": "off",
    "no-wrap-func": "off",
    "nonblock-statement-body-position": "off",
    "object-curly-newline": "off",
    "object-curly-spacing": "off",
    "object-property-newline": "off",
    "one-var-declaration-per-line": "off",
    "operator-linebreak": "off",
    "padded-blocks": "off",
    "quote-props": "off",
    "rest-spread-spacing": "off",
    "semi": "off",
    "semi-spacing": "off",
    "semi-style": "off",
    "space-after-function-name": "off",
    "space-after-keywords": "off",
    "space-before-blocks": "off",
    "space-before-function-paren": "off",
    "space-before-function-parentheses": "off",
    "space-before-keywords": "off",
    "space-in-brackets": "off",
    "space-in-parens": "off",
    "space-infix-ops": "off",
    "space-return-throw-case": "off",
    "space-unary-ops": "off",
    "space-unary-word-ops": "off",
    "switch-colon-spacing": "off",
    "template-curly-spacing": "off",
    "template-tag-spacing": "off",
    "unicode-bom": "off",
    "wrap-iife": "off",
    "wrap-regex": "off",
    "yield-star-spacing": "off",
    "@typescript-eslint/func-call-spacing": "off",
    "@typescript-eslint/no-extra-parens": "off",
    "@typescript-eslint/semi": "off",
    "react/jsx-child-element-spacing": "off",
    "react/jsx-closing-bracket-location": "off",
    "react/jsx-closing-tag-location": "off",
    "react/jsx-curly-spacing": "off",
    "react/jsx-equals-spacing": "off",
    "react/jsx-first-prop-new-line": "off",
    "react/jsx-indent": "off",
    "react/jsx-indent-props": "off",
    "react/jsx-max-props-per-line": "off",
    "react/jsx-one-expression-per-line": "off",
    "react/jsx-props-no-multi-spaces": "off",
    "react/jsx-space-before-closing": "off",
    "react/jsx-tag-spacing": "off",
    "react/jsx-wrap-multilines": "off",
    "react/self-closing-comp": "off",
    "react-hooks/rules-of-hooks": "error"
  },
  "parserOptions": {
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true
    }
  },
  "parser": "/mnt/e/Webdesign/salted-vagrant/rest-hooks/node_modules/@typescript-eslint/parser/dist/parser.js",
  "plugins": [
    "@typescript-eslint",
    "react",
    "react-hooks"
  ],
  "extends": [
    "./configs/base.json",
    "plugin:@typescript-eslint/recommended",
    "plugin:react/recommended",
    "prettier",
    "prettier/@typescript-eslint",
    "prettier/react"
  ],
  "settings": {
    "react": {
      "version": "detect"
    }
  }
}