Tag: 命名约定

我在package.json中使用什么命名约定?

在package.json我有两个字lint和fix这个脚本名称。 我应该怎样做一个正确的名字? 有以下选项: lowerCamelCase – lintFix UpperCamelCase – LintFix snake_case – lint_fix kebab案件 – lint-fix 吞咽风格与冒号定界符 – lint:fix 任何其他分隔符。 什么select是正确的? 为什么?

nodeJS中的双下划线与单下划线

我在使用nodeJS时遇到了两个冲突的命名约定。 一些variables以_temp开头,下划线开始,而__dirname 。 我一直在试图寻找这个命名约定差异的答案。 我检查了一个variables前面的Double __dirname ,但是答案是非常具体的__dirname和__filename 。 它没有解决冲突的命名约定。 如果有人能够为我提供这方面的资源,这将是非常好的。

Nodejs命名模块的约定

鉴于这种模式: 模块定义了一个公共API,但需要运行时信息。 // Contrived example for a module abstracting a db module.exports = function (host, schema, …) { // A "module-level", private, instance of an object // that will be used by the public API of the module var connection = getConnection(host, schema, …); return { queryItems : function (arg) { // Something that uses […]

命名约定来区分节点JS中的模块/实例/方法variables

假设我有这样的代码: var moduleVar = "I belong to this module, you could also call me a static var"; var ClassName = function() { var instanceVar = "I belong to this instance"; function someFunction(functionVar) { var anotherFunctionVar = "I belong to this function"; return 1; } } module.exports = ClassName; 我已经四处寻找节点的命名约定,但我还没有发现任何事情,甚至处理这个问题。 我喜欢用下划线(例如“_instanceVar”)为实例variables加上前缀,但是我仍然停留在函数和模块variables之间的区别。 那里是否有一个命名惯例区分这些?