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

react/boolean-prop-naming error #1700

Closed
JamyGolden opened this issue Feb 21, 2018 · 2 comments
Closed

react/boolean-prop-naming error #1700

JamyGolden opened this issue Feb 21, 2018 · 2 comments

Comments

@JamyGolden
Copy link

When using react/boolean-prop-naming I get an error when I assign the values given in boolean-prop-naming.md as an example. https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/boolean-prop-naming.md#rule

Error

user@User-MacBook-Pro /V/p/some-project> npm run lint

> some-project@1.0.0 lint /Volumes/projects/some-project
> eslint ./

Cannot read property 'name' of undefined
TypeError: Cannot read property 'name' of undefined
    at Program:exit.Object.keys.forEach.component (/Volumes/projects/some-project/node_modules/eslint-plugin-react/lib/rules/boolean-prop-naming.js:229:83)
    at Array.forEach (<anonymous>)
    at Program:exit (/Volumes/projects/some-project/node_modules/eslint-plugin-react/lib/rules/boolean-prop-naming.js:220:27)
    at listeners.(anonymous function).forEach.listener (/Volumes/projects/some-project/node_modules/eslint/lib/util/safe-emitter.js:47:58)
    at Array.forEach (<anonymous>)
    at Object.emit (/Volumes/projects/some-project/node_modules/eslint/lib/util/safe-emitter.js:47:38)
    at NodeEventGenerator.applySelector (/Volumes/projects/some-project/node_modules/eslint/lib/util/node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (/Volumes/projects/some-project/node_modules/eslint/lib/util/node-event-generator.js:280:22)
    at NodeEventGenerator.leaveNode (/Volumes/projects/some-project/node_modules/eslint/lib/util/node-event-generator.js:303:14)
    at CodePathAnalyzer.leaveNode (/Volumes/projects/some-project/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:630:23)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! some-project@1.0.0 lint: `eslint ./`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the some-project@1.0.0 lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/user/.npm/_logs/2018-02-21T12_05_37_865Z-debug.log

.eslintrc

{
    "parser": "babel-eslint",
    "plugins": ["react"],
    "rules": {
        "react/boolean-prop-naming": ["error", { "rule": "^is[A-Z]([A-Za-z0-9]?)+" }]
    }
}

Versions of tools I'm using

  • eslint: v4.18.1
  • MacOS 10.13.3
  • node v9.5.0
@ljharb
Copy link
Member

ljharb commented Feb 22, 2018

Any chance you could provide the code that it’s erroring on?

@JamyGolden
Copy link
Author

I looked into it and found what was causing it. This is the problem code:

// @flow
import * as React from "react";

function SomeComponent({
    something,
}: {
    something: string,
}) {
    return (
        <span>{something}</span>
    );
}

export default ExitButton;

Changing function SomeComponent({ to const SomeComponent = function({ fixed the issue for me. Parsing bug when it comes to flow inline typing?

This passed eslint tests

// @flow
import * as React from "react";
type test = {
    something: string,
};
function SomeComponent(prop: test) {
    return (
        <span>{prop.something}</span>
    );
}

export default ExitButton;

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

No branches or pull requests

2 participants