typescript-book icon indicating copy to clipboard operation
typescript-book copied to clipboard

Reconsider my file naming convention and default exports

Open basarat opened this issue 7 years ago • 5 comments

If this React React.lazy RFC lands will change the naming convention to be Buttons.tsx (instead of buttons.tsx) and sunset the default exports issues, probably move into a blog post with a mention of its okay as the conventions beat personal preference :rose:

basarat avatar Oct 22 '18 00:10 basarat

Reference : https://github.com/reactjs/rfcs/pull/64#issuecomment-431395596 :rose:

basarat avatar Oct 22 '18 00:10 basarat

@basarat The RFC is merged, but by skimming over the long thread I fail to understand what impact it has on your recommendation to avoid named exports. I would still want to use named exports because I create barrel files etc, but could add a default export if required for lazy imports.

As far as file naming goes I'm convinced that all lower case file naming is superior. I wish you would use the style guide to at least point users to some of the benefits, instead of just saying camel-casing is the convention so you should use that. But maybe I should just write an article to try and persuade people :)

0x80 avatar Sep 16 '20 15:09 0x80

You and I see eye to eye 🤗

My new objective : add a section "When its okay to use export default" and simply point to when you want to use some API that works with it e.g. React.lazy :rose:

I also eye eye to eye on file naming. I recommend camelCase here https://basarat.gitbook.io/typescript/styleguide#filename and I don't see myself adding confusing-anything-is-fine (which is how I view most things personally, life is too short) comments to a styleguide so will leave it as is :+1:

basarat avatar Sep 16 '20 19:09 basarat

My point was not to hint on "anything is fine" but more the contrary. Consistency is important and I think its harder to achieve with camel-cased file names.

But I will just start by spreading the word myself.

0x80 avatar Sep 18 '20 08:09 0x80

I was just thinking out aloud 🌹

basarat avatar Sep 18 '20 20:09 basarat