1

we have React project with Typescript. We use TSDoc to standardize the doc comments used in TypeScript code

Our eslint.trc file as follow:

{
    "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"
    }
}

How to configure this configuration file, for not asking ESLINT about documenting standard react methods, like constructor(),static getDerivedStateFromProps(),render(),componentDidMount() and etc.

We can switch "require-jsdoc":"off", but it also will not ask out user defined methods in class.

1
  • FWIW: It's "standard" (with "d" at the end, not a "t"). Commented May 8, 2021 at 12:06

2 Answers 2

3

I've resolved this problem with this plugin https://www.npmjs.com/package/eslint-plugin-require-jsdoc-except?activeTab=readme

You can add your function names at ignore:

 "ignore":[
            "constructor", "render","componentDidUpdate","getDerivedStateFromProps","componentDidMount"
         ]
Sign up to request clarification or add additional context in comments.

Comments

1

Add this to your .eslintrc.js rules:

rules: {
  'require-jsdoc': [
    'error',
    {
      require: {
        FunctionDeclaration: false,
        MethodDefinition: false,
        ClassDeclaration: false,
        ArrowFunctionExpression: false,
        FunctionExpression: false,
      },
    },
  ],
},

Read more: https://eslint.org/docs/latest/rules/require-jsdoc

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.