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

The valid-jsdoc rule and jsdoc comments for fields. #2938

Closed
mysticatea opened this issue Jul 7, 2015 · 4 comments · Fixed by DavidKindler/meteor#3
Closed

The valid-jsdoc rule and jsdoc comments for fields. #2938

mysticatea opened this issue Jul 7, 2015 · 4 comments · Fixed by DavidKindler/meteor#3
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules

Comments

@mysticatea
Copy link
Member

I tried to write a jsdoc comment for a field, but the comment seems to be bonded to a function in its right hand expression.

On the following code, I expected the comment "Description for this.xs" is bonded to this.xs, but actually the comment seems to be bonded to x => x != null.

/**
 * Description for A.
 */
class A {
  /**
   * Description for constructor.
   * @param {object[]} xs - xs
   */
  constructor(xs) {
    /**
     * Description for this.xs;
     * @type {object[]}
     */
    this.xs = xs.filter(x => x != null);
  }
}

> eslint -v
v0.24.0
> eslint test.js --env es6 --rule "valid-jsdoc:[2,{requireReturn:false}]" --reset --no-eslintrc

Actual

test.js
  10:4  error  Missing JSDoc for parameter 'x'  valid-jsdoc

✖ 1 problem (1 error, 0 warnings)

Expected

No errors.

@gyandeeps gyandeeps added the triage An ESLint team member will look at this issue soon label Jul 7, 2015
@ilyavolodin
Copy link
Member

Could be related to either eslint/espree#155 or eslint/espree#136

@gyandeeps
Copy link
Member

I dont think its related since the AST getting generated is correct. I verified it on my machine.
The issue is on this line https://github.com/eslint/eslint/blob/master/lib/eslint.js#L911
The second condition evaluates to true (actually it should be false) since the object being compared are not equal.
I think this check is bad as we are trying to compare 2 objects.
I think obj1 !== obj2 would always return true because javascript object comparison is not correct/perfect.

If we fix that line then the above scenario would work fine.

@gyandeeps gyandeeps added bug ESLint is working incorrectly rule Relates to ESLint's core rules core Relates to ESLint's core APIs and features and removed triage An ESLint team member will look at this issue soon labels Jul 7, 2015
@gyandeeps
Copy link
Member

UPDATE:
Once I removed the second check on line 911 (as mentioned above), all the unit test for all rules are passing including the scenario discussed in this issue.

Once issue gets accepted I will work on this.

@ilyavolodin ilyavolodin added accepted There is consensus among the team that this change meets the criteria for inclusion and removed core Relates to ESLint's core APIs and features labels Jul 7, 2015
@mysticatea
Copy link
Member Author

Thank you a lot!

I think obj1 !== obj2 would always return true because javascript object comparison is not correct/perfect.

In this case, I guess the comparison becomes false for IIFE, but becomes true for functions in the argument list :)

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 7, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants