blog
blog copied to clipboard
不推荐使用 camelCase/PascalCase 命名文件
来源:https://medium.com/@martin_hotell/10-typescript-pro-tips-patterns-with-or-without-react-5799488d6680
Don't
SkaterBoy.tsx
userAccessHandlers.ts
Do
skater-boy.tsx
user-access-handlers.ts
-
可读性更好
文中说 my-half-fixed-deduped-dir-resolver vs MyHalfFixedDedupedDirResolver,我觉得差不多
-
git 更友好(git 默认不区分文件名大小写)
我觉得这个才是关键点
-
一致性(存疑)
consistency (I don’t have to think if this file is component or some helper or service. tsx extension tells me that)
文中原话,不是很理解
-
和组件名映射清晰(存疑)
nicely maps to component implementation name skater-boy.tsx 👉 const SkaterBoy = () => {}
文中原话,那
SkaterBoy.tsx不是映射关系更清晰么