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

Exception for space-before-keywords? #713

Open
olalonde opened this issue Feb 3, 2016 · 2 comments
Open

Exception for space-before-keywords? #713

olalonde opened this issue Feb 3, 2016 · 2 comments

Comments

@olalonde
Copy link

olalonde commented Feb 3, 2016

Writing a React/redux app, I am occasionally declaring anonymous classes inside function calls:

export default connect()(class extends Component {
  // React component class definition
});

which gives this error: Missing space before keyword "class". (space-before-keywords).

If I put a space there:

export default connect()( class extends Component {
  // React component class definition
});

It fails another rule: There should be no spaces inside this paren. (space-in-parens).

Was wondering if that was an unintended effect of the space-before-keywords or if everything is working as expected.

@tleunen
Copy link

tleunen commented Feb 3, 2016

I think the styleguide should specify to avoid anonymous classes. Especially in case of React where the class name is used as a "display name".

@ljharb
Copy link
Collaborator

ljharb commented Feb 3, 2016

I agree one should avoid anonymous classes - but also, aggressive inlining. I'd recommend defining the class first, and then exporting the connected value in a second line.

Specifically, I think this is a bug with the space-before-keywords linter rule, that perhaps should be filed to eslint directly.

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

3 participants