繁体   English   中英

如何在 typescript eslint 配置中启用标准命名约定的警告?

[英]How to enable warnings for standard naming conventions in typescript eslint config?

我想在我的.eslintrc.json文件中为“默认” typescript 命名约定启用警告。 你怎么做到这一点?

//package.json
    //...
    "@typescript-eslint/eslint-plugin": "^4.25.0",
    "@typescript-eslint/parser": "^4.25.0",
    "easy-peasy": "^5.0.3",
    "eslint-plugin-react": "^7.23.2",
    "eslint-plugin-react-hooks": "^4.2.0",
    //..
//.eslintrc.json
//
{
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaVersion": 2018,
    "sourceType": "module"
  },
  "plugins": ["@typescript-eslint", "react-hooks"],
  "extends": [
    "plugin:react/recommended",
    "plugin:@typescript-eslint/recommended"
  ],
  "rules": {
    "react-hooks/rules-of-hooks": "error",
    "react-hooks/exhaustive-deps": "warn",
    "react/prop-types": "off",
    //enable warnings for default naming convetions?
    "@typescript-eslint/explicit-function-return-type": [
      "warn",
      {
        "allowExpressions": true
      }
    ]
  },
  "settings": {
    "react": {
      "pragma": "React",
      "version": "detect"
    }
  }
}


只需将“警告”添加到 .eslintrc.json 中的“@typescript- .eslintrc.json /naming-convention”值:

  "rules": {
    //..
    "@typescript-eslint/naming-convention": "warn",
    //..
  },

在此处了解有关 @typescript-eslint/naming-convention 设置的更多信息

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM