Node.js project naming conventions for files & folders

后端 未结 7 1622
清酒与你
清酒与你 2020-12-04 04:41

What are the naming conventions for files and folders in a large Node.js project?

Should I capitalize, camelCase, or under-score?

Ie. is this considered vali

7条回答
  •  醉梦人生
    2020-12-04 05:22

    According to me: For files, use lower camel case if module.exports is an object, I mean a singleton module. This is also applicable to JSON files as they are also in a way single ton. Use upper camel case if module.exports returns a constructor function where it acts like a class.

    For folders use short names. If there is need to have multiple words, let it be completely lower case separated by "-" so that it works across all platforms consistently.

提交回复
热议问题