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.

eslint + babel-eslint + ArrowFunctionExpression as class method = inaccurate getJSDocComment

See original GitHub issue

https://github.com/brokentone/eslint/tree/bug/babel-eslint-arrow-jsdoc Tell us about your environment

  • ESLint Version: master
  • Node Version: v8.11.3
  • npm Version: 5.6.0

What parser (default, Babel-ESLint, etc.) are you using? babel-eslint

Please show your full configuration:

Configuration
{ rules: { checker: "error" }, parser: "babel-eslint", parserOptions: { ecmaVersion: 6, ecmaFeatures: { jsx: true } } }

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

/** Merges two objects together.*/
class A {
    constructor(xs) {}

    methodOne = () => {}
};
./node_modules/.bin/mocha tests/lib/util/source-code.js

What did you expect to happen? Not to associate the comment with the arrow function with sourceCode.getJSDocComment(node);

What actually happened? Please include the actual, raw output from ESLint. Comment returned.

I have a test case built here: https://github.com/brokentone/eslint/tree/bug/babel-eslint-arrow-jsdoc

I added the babel-eslint parser to all the other rules in the file as a second commit, and the only violation is this new case I added.

I attempted to dig through getJSDocComment and I couldn’t quite figure out the issue. In fairness, it may very well be a babel-eslint issue.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
platinumazurecommented, Aug 23, 2018

I don’t know if the rest of the team feels the same way necessarily, but I would be open to a change to getJSDocComment for your use case. In my view, the intention of the rule policy is that we want users to create custom rules for experimental language features. But in this case, a core API is being hamstrung by this limitation and so writing a custom rule is more difficult than it should be for this case. So I’m hoping we can do something here.

That said, the team may ultimately suggest a different solution.

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

Why does ESLint not recognize my class arrow functions?
I think you are getting that linting error because you are not using ECMA ... I think it might be because babel-eslint is...
Read more >
@babel/eslint-parser | Yarn - Package Manager
Intro. Babel is a tool that helps you write code in the latest version of JavaScript. When your supported environments don't support certain...
Read more >
eslint-plugin-sort-class-members - npm package - Snyk
e.g., propertyType: "ArrowFunctionExpression" to match properties whose value is initialized to an arrow function. accessorPair : true|false . True to match ...
Read more >
Fixing eslint no-invalid-this error for fat arrow class methods
Was looking for some time for how to fix the error. “Fixing eslint no-invalid-this error for fat arrow class methods” is published by...
Read more >
eslint-plugin-jsdoc: Versions - Openbase
Full version history for eslint-plugin-jsdoc including change logs. ... Object destructuring in function parameters if key is string (#599) (64e1b64) ...
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