react-webpack-generators / react-webpack-template

Simple react webpack template
MIT License
82 stars 43 forks source link

V2 -- Pick eslint-compatible arrow body for --stateless #37

Closed sthzg closed 8 years ago

sthzg commented 8 years ago

When creating --stateless components the template creates:

const Footer = () => {
  return (
    // jsx here
  );
};

With the current eslint settings, this won't compile:

3:22 error Unexpected block statement surrounding arrow body arrow-body-style

In terms of the eslint rules, this is intended as stated here. The reason is, that the arrow body only consists of the return statement, thus eslint would only validate it as:

const Footer = () => (
  // jsx here
);

Obviously this isn't hard to fix, either by altering the eslint config, adding some variable into the body or refactoring the arrow to return with (). The more important question is, what's better for users of the generator, will they be more likely to extend the body or use it as a plain return stmt.

I am against weakening the eslint rules, and IMO both use cases are equally important, so maybe another option to the generator makes sense. Otherwise we should probably pick (whichever) default that validates out-of-the-box. As over-engineering is not a good habit, I am +1 for picking a default.

I will provide the PR based on a decision in this issue.

sthzg commented 8 years ago

Closing here, since the templates are created as part of the component sub generator in the generator project.