Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get require-jsdoc-on-export rule to work #5

Open
mnezh opened this issue Aug 15, 2017 · 4 comments
Open

Can't get require-jsdoc-on-export rule to work #5

mnezh opened this issue Aug 15, 2017 · 4 comments

Comments

@mnezh
Copy link

mnezh commented Aug 15, 2017

I'm trying to use the benderthecrime/require-jsdoc-on-export rule to work, by adding it to the .eslintrc file as:

"rules": {
    "benderthecrime/require-jsdoc-on-export": [
      2,
      {
        "ClassDeclaration": false,
        "FunctionDeclaration": true,
        "MethodDefinition": false
      }
    ]
  }

However, eslint is not happy with the configuration:

Error: /Users/andrey.mishustin/Gits/iflix/foreplay/.eslintrc:
	Configuration for rule "benderthecrime/require-jsdoc-on-export" is invalid:
	Value "[object Object]" should be number.

    at validateRuleOptions (/Users/andrey.mishustin/Gits/iflix/foreplay/node_modules/eslint/lib/config/config-validator.js:113:15)
    at Object.keys.forEach.id (/Users/andrey.mishustin/Gits/iflix/foreplay/node_modules/eslint/lib/config/config-validator.js:153:9)
    at Array.forEach (native)
    at validateRules (/Users/andrey.mishustin/Gits/iflix/foreplay/node_modules/eslint/lib/config/config-validator.js:152:30)
    at Object.validate (/Users/andrey.mishustin/Gits/iflix/foreplay/node_modules/eslint/lib/config/config-validator.js:230:5)
    at loadFromDisk (/Users/andrey.mishustin/Gits/iflix/foreplay/node_modules/eslint/lib/config/config-file.js:549:19)
    at Object.load (/Users/andrey.mishustin/Gits/iflix/foreplay/node_modules/eslint/lib/config/config-file.js:592:20)
    at Config.getLocalConfigHierarchy (/Users/andrey.mishustin/Gits/iflix/foreplay/node_modules/eslint/lib/config.js:228:44)
    at Config.getConfigHierarchy (/Users/andrey.mishustin/Gits/iflix/foreplay/node_modules/eslint/lib/config.js:182:43)
    at Config.getConfigVector (/Users/andrey.mishustin/Gits/iflix/foreplay/node_modules/eslint/lib/config.js:287:21)
error Command failed with exit code 1.

I guess the reason might be the rule schema, which doesn't make sense to me at the first glance:

I was trying to get rid of the standard-jsdoc eslint behaviour requiring comments for virtually everything to more reasonable documenting the exports only.

eslint is v4.4.1, eslint-plugin-benderthecrime is ^2.1.0

@benderTheCrime
Copy link
Owner

benderTheCrime commented Aug 15, 2017

This in interesting, thanks for raising an issue.

On a personal note, I've mostly stopped using JSDoc in favor of an approach that has no comments as of a year and a half ago (hence the benderthecrime/no-comment rule) in favor of external documentation and code that is self-explanatory. This rule should have been marked deprecated then, but it wasn't broken at the time.

I'm going to tell you right now that I have no idea what the original intent for the schema taking a number as it's second argument was or what configuring the types to false by default achieved.

I think perhaps I'm going to show this rule some love by enabling all types by default and restructuring the rule to visit export AST types, checking against an "excludes" type list as a configuration parameter.

example:

{
    "benderthecrime/require-jsdoc-on-export": [
        2,
        {
             "excludes": [
                  "VariableDeclaration"
              ]
         }
     ]
}

any thoughts on this?

@mnezh
Copy link
Author

mnezh commented Aug 15, 2017

Yes, I think it makes sense, since the rule already introduces reasonable limit on jsdoc requirements, enabling it for all exported entities by default is a good choice. If someone for any reason needs to limit it even more, excludes seems to be semantically adequate.

@benderTheCrime
Copy link
Owner

benderTheCrime commented Aug 15, 2017 via email

@benderTheCrime
Copy link
Owner

@mnezh #6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants