首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在typescript eslint配置中启用标准命名约定的警告?

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

Stack Overflow用户
提问于 2021-05-28 08:06:30
回答 1查看 76关注 0票数 0

我想在我的.eslintrc.json文件中启用对“默认”typescript命名约定的警告。您如何做到这一点?

代码语言:javascript
复制
//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",
    //..
代码语言:javascript
复制
//.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"
    }
  }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-28 08:08:20

只需在.eslintrc.json的“@typescript-eslint/命名约定”值中添加"warn“即可

代码语言:javascript
复制
  "rules": {
    //..
    "@typescript-eslint/naming-convention": "warn",
    //..
  },

了解有关@typescript-eslint/命名约定设置here的更多信息

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67731339

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档