在终端上显示React prop类型验证错误消息

时间:2019-05-30 12:40:31

标签: reactjs eslint react-proptypes

我正在构建使用create-react-app开始的React应用程序。我以前工作的项目已经具有在浏览器控制台以及启动应用程序的终端窗口中显示道具类型验证错误消息的配置。我正在尝试使用相同的配置来处理新项目。但是我只能使用prop-types软件包在浏览器控制台上运行它。

我知道要在终端中获取它们,我必须添加.eslintrc文件。这是我的.eslintrc文件-

    {
  "extends": [
    "eslint:recommended",
    "plugin:react/recommended"
  ],
  "plugins": [
    "react"
  ],
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    },
  "rules": {
    "no-underscore-dangle": ["error", { "allow": ["_id", "b_codes_id"] }],
    "react/prop-types": "error"
  },
  "settings": {
    "import/resolver": "meteor"
  },
  "globals": {
    "_": true,
    "CSSModule": true,
    "Streamy": true,
    "ReactClass": true,
    "SyntheticKeyboardEvent": true,
  }
}

此外,在先前的项目中,过去还缺少道具验证警告。即使在浏览器控制台中也无法使用。

0 个答案:

没有答案
相关问题