首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >防止询问“缺少JSDoc注释”的标准反应方法在打字稿项目

防止询问“缺少JSDoc注释”的标准反应方法在打字稿项目
EN

Stack Overflow用户
提问于 2021-05-08 12:04:00
回答 1查看 1.8K关注 0票数 1

我们用打字稿对项目作出反应。我们使用TSDoc来标准化在TypeScript代码中使用的文档注释。

我们的eslint.trc文件如下:

代码语言:javascript
复制
{
    "env": {
        "browser": true,
        "es2021": true
    },
    "extends": [
        "plugin:react/recommended",
        "google",
        "plugin:@typescript-eslint/recommended",
        "plugin:prettier/recommended"
    ],
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "ecmaFeatures": {
            "jsx": true
        },
        "ecmaVersion": 12,
        "sourceType": "module"
    },
    "plugins": [
        "react",
        "@typescript-eslint/eslint-plugin",
        "eslint-plugin-tsdoc"
    ],
    "settings": {
        "react": {
            "version": "detect"
        }
    },
    "rules": {
        "tsdoc/syntax": "warn",
        "valid-jsdoc" : 0,
        "@typescript-eslint/explicit-module-boundary-types": "off"
    }
}

如何配置此配置文件,以便不询问ESLINT如何记录标准的react方法,如constructor(),static getDerivedStateFromProps(),render(),componentDidMount() and etc.

我们可以切换"require-jsdoc":"off",但它也不会在类中请求出用户定义的方法。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-16 13:29:04

我已经用这个插件https://www.npmjs.com/package/eslint-plugin-require-jsdoc-except?activeTab=readme解决了这个问题

您可以在“忽略”中添加函数名:

代码语言:javascript
复制
 "ignore":[
            "constructor", "render","componentDidUpdate","getDerivedStateFromProps","componentDidMount"
         ]
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67447335

复制
相关文章

相似问题

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