node.jsnpmnaming-conventionspackage.json

What naming convention do I use for scripts in package.json?


In package.json I have this script name with two words lint and fix. How should I make a right name?

There are options:

  1. lowerCamelCase - lintFix
  2. UpperCamelCase - LintFix
  3. snake_case - lint_fix
  4. kebab-case - lint-fix
  5. gulp-style with a colon delimiter - lint:fix
  6. Any another delimiter.

What option is right? And why?


Solution

  • There is no official naming convention. Before npm@v4 standard scripts had only one word, for example test, start, prestart. npm@v4 introduced a new script prepublishOnly*.

    So now, the best practice is use lowerCamelCase.

    *Reference: https://iamakulov.com/notes/npm-4-prepublish/