blog icon indicating copy to clipboard operation
blog copied to clipboard

不推荐使用 camelCase/PascalCase 命名文件

Open nmsn opened this issue 3 years ago • 0 comments

来源: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
  1. 可读性更好

    文中说 my-half-fixed-deduped-dir-resolver vs MyHalfFixedDedupedDirResolver,我觉得差不多

  2. git 更友好(git 默认不区分文件名大小写)

    我觉得这个才是关键点

  3. 一致性(存疑)

    consistency (I don’t have to think if this file is component or some helper or service. tsx extension tells me that)

    文中原话,不是很理解

  4. 和组件名映射清晰(存疑)

    nicely maps to component implementation name skater-boy.tsx 👉 const SkaterBoy = () => {}

    文中原话,那 SkaterBoy.tsx 不是映射关系更清晰么

nmsn avatar Jul 11 '22 13:07 nmsn