File and folder naming convention for React.js components
/actions/...
/components/common/Link.js
/components/common/...
/components/forms/TextBox.js
/components/forms/TextBox.res/style.css
/components/forms/TextBox.locale/en-US/...
/components/forms/...
/components/layout/App.js - The top-level React component
/components/layout/App.res/style.css
/components/layout/App.locale/en-US/...
/components/layout/Navigation.js
/components/layout/Navigation.res/style.css
/components/layout/Navigation.res/data.json
/components/layout/Navigation.locale/en-US/...
/components/layout/...
/components/pages/Home.js
/components/pages/Home.css
/components/pages/Account/index.js
/components/pages/Account/index.css
/components/pages/...
/core/...
/constants/...
/stores/...
/actions/...
/components.common/Link.js
/components.common/...
/components.forms/TextBox.js
/components.forms/TextBox.css
/components.forms/...
/components.layout/App.js
/components.layout/Navigation.js
/components.layout/...
/components.pages/Home.js
/components.pages/Home.css
/components.pages/Account/index.js
/components.pages/Account/index.css
/components.pages/...
/core/...
/constants/...
/stores/...
CSS class names should be prefixed with a single letter corresponding to the component's type.
For example:
Component: /components/forms/TextBox.js, CSS class name: f-textbox { ... }
Component: /components/layout/Navigation.js, CSS class name: l-nagiation { ... }
The discussions in this gist are valuable to me. Just FYI, here are some of my troubles caused by uppercase filename on Mac:
Use case 1: dev on Mac and build on Linux
Assume there’re
a.jsandb.js, and a line of codeimport { someFunc } from 'a.js';inb.js;a.jsasA.js,importinb.jscan be always resolved to the same dependency successfully, no matter in Node.js UT or in Webpack bundling;importinb.jswould only be resolved asa.js;A.jswill be considered as a totally different file, lack ofa.jswill cause build failure (no matter UT or Webpack bundling).Use case 2: Git rename on Mac
No matter it’s a Git or Apple Git, no matter it’s prior to version 2.0.1 or newer, changing the filename case causes various troubles on macOS.
E.g.
git mv myfile.txt MyFile.txtfollowed by agit reset(you don’t want to try it with production code...)I'm confident that myself won't run into those troubles again, but it's often too late to warn junior members in my team.