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

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

我想在我的 .eslintrc.json 文件中为“默认”打字稿命名约定启用警告。你是怎么做到的?

//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-eslint/naming-convention”值
  "rules": {
    //..
    "@typescript-eslint/naming-convention": "warn",
    //..
  },

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