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
getJSDocComment causing crash for eslint-plugin-react #9101
Comments
Thanks for the report. It looks like the For example, if you do something like this in a rule: return {
MemberExpression(node) {
// do something with `node`
}
} At the time when the This can sometimes be a bit inconvenient/confusing. In eslint/eslint-scope#27 there was some discussion about adding all the |
Thanks for the thorough explanation. If this is working as intended then I will close the issue. However, using the The Anyway, I have some ideas how to work around it. 😄 |
From I figured I'd try and explain the use-case to you. Then So MyComponent.propTypes = {} // GOOD
MyComponent.PROPTYPES = {} // BAD In order to do that, we look at the One of the ways to detect React components is to parse the JSDoc and look for /** @extends React.Component */
class MyComponent extends BaseComponent Now what happens is when the code is structured like this: MyComponent.PROPTYPES = {} // BAD
/** @extends React.Component */
class MyComponent extends BaseComponent
I think |
There are a few possible approaches you could take:
|
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using?
babel-eslint
Please show your full configuration:
Configuration
What did you do? Please include the actual source code causing the issue.
A rule in eslint-plugin-react is crashing (jsx-eslint/eslint-plugin-react#1353). See the source code below. We call the
sourceCode.getJSDocComment(node)
with a node of typeFunctionDeclaration
.https://github.com/yannickcr/eslint-plugin-react/blob/master/lib/util/Components.js#L218
In eslint source code, we then check if the parent of that node "looks like an export". Now... it turns out that the parent of this specific
FunctionDeclaration
is undefined.https://github.com/eslint/eslint/blob/master/lib/util/source-code.js#L311
What did you expect to happen?
No error. Can we guard with an additional
undefined
check? Or is there something else wrong here?What actually happened? Please include the actual, raw output from ESLint.
The text was updated successfully, but these errors were encountered: