question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

require-jsdoc false positive on first property after static field within class

See original GitHub issue

Tell us about your environment

  • ESLint Version: 3.14.0
  • Node Version: 6.10,3
  • npm Version: 3.10.5

What parser (default, Babel-ESLint, etc.) are you using? babel-eslint running from Visual Studio Code

Please show your full configuration:

Configuration

{
  "parser": "babel-eslint",
  "extends": [
    "airbnb"
  ],
  "plugins": [
    "no-unused-vars-rest"
  ],
  "env": {
    "browser": true,
    "jest": true
  },
  "globals": {
    "__DEV__": true,
    "__PROD__": true,
    "__DEBUG__": true,
    "__COVERAGE__": true,
    "__BASENAME__": true
  },
  "settings": {
    "import/resolver": {
      "webpack": {
        "config": "webpack.config.js"
      }
    }
  },
  "rules": {
    "arrow-body-style": 0,
    "arrow-parens": 0,
    "comma-dangle": 0,
    "global-require": 0,
    "import/no-dynamic-require": 0,
    "import/no-extraneous-dependencies": 0,
    "import/prefer-default-export": 0,
    "import/no-named-as-default": 0,
    "indent": ["error", 2],
    "linebreak-style": 0,
    "max-len": 0,
    "no-shadow": 0,
    "no-unused-expressions": 0,
    "no-confusing-arrow": 0,
    "no-console": [2, { "allow": ["warn", "error"] }],
    "no-unused-vars": 0,
    "no-unused-vars-rest/no-unused-vars": [2, {"ignoreDestructuredVarsWithRest": true}],
    "react/require-default-props": 0,
    "react/forbid-prop-types": 0,
    "react/prop-types": 1,
    "react/jsx-filename-extension": [2, {"extensions": [".js", ".jsx"]}],
    "react/jsx-curly-spacing": [1, "always"],
    "require-jsdoc": [2, {
      "require": {
          "FunctionDeclaration": true,
          "MethodDefinition": true,
          "ClassDeclaration": true,
          "ArrowFunctionExpression": true
      }
    }],
    "semi": [2, "always"],
    "space-infix-ops": 0,
    "space-before-blocks": 0
  }
}


What did you do? Please include the actual source code causing the issue.

/**
 * Employee component
 */
export class Employee extends React.Component {
  /** @type {Object} component prop types */
  static propTypes = {
    match: PropTypes.object.isRequired,
    title: PropTypes.string.isRequired,
    children: PropTypes.any.isRequired
  }

  /**
   * Construct component
   * @param {*} props - component properties
   */
  constructor(props){
    super(props);

    this.name = null;
  }

  /**
   * Pre-render
   */
  componentWillMount(){
    this.name = this.fetchName();
  }
}


What did you expect to happen? No Errors regarding require-jsdoc

What actually happened? Please include the actual, raw output from ESLint. “Missing JSDoc comment”

Code is currently being marked in error due to (what the parser thinks) missing jsdoc block above my constructor(){}. The jsdoc block is there but the code is being marked with what I believe to be a false positive. If I remove the static propTypes = {} then the false positive goes away but triggers another one of my eslint rules. The two should be exclusive, so I am not sure what is going on.

Thanks for your hard work and your help.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
platinumazurecommented, Sep 27, 2017

@designbystephen Thanks for the issue. It looks like this might be a babel-eslint issue. Can you open up an issue there? They need to make sure they’re including the comment (with correct location data) when parsing your code. If they can confirm that the comment and location data are all correct, then we can take a look at our JSDoc comment detection logic.

P.S. Hope it’s okay that I edited the issue title to reflect what you have said in your most recent post.

0reactions
nzakascommented, Nov 28, 2018

Thanks for the suggestion. As of yesterday, we have decided to officially end-of-life JSDoc support in ESLint. All JSDoc features are now deprecated and we won’t be fixing bugs or making any further improvements to those features.

We are recommending that people transition over to use the eslint-plugin-jsdoc plugin instead of the built-in rules in ESLint.

Thanks for understanding and we apologize for any inconvenience.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Eslint does not allow static class properties - Stack Overflow
Static class properties are already supported on JS and on Node. How can this rule be disable? I also have the following .eslintrc.json...
Read more >
Diff - plugins/checks - Google Git
Merge branch 'stable-3.1' into stable-3.2 * stable-3.1: Fix test due to change in Gerrit core ChecksSubmitRule.Module: Demote base class to AbstractModule ...
Read more >
Rules - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
eslint-plugin-jsdoc - NPM Package Overview - Socket.dev
eslint-plugin-jsdoc options, if present, are generally in the form of an object supplied as the second argument in an array after the error ......
Read more >
@thibaudcolas/eslint-plugin-cookbook - Package Manager
Changelog. All notable changes to this project will be documented in this file. The format is based on Keep a Changelog and this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found